Invalid boolean values should fall back to the default

Previously, an invalid value was always false
This commit is contained in:
Nikos Tsipinakis 2016-12-15 19:13:08 +02:00
parent a2e0a6efe7
commit 187d3f9ab9
2 changed files with 2 additions and 1 deletions

View File

@ -175,7 +175,7 @@ int ini_get_bool(char *section, char *key, int def)
case '0':
return false;
default:
return false;
return def;
}
}
}

View File

@ -33,6 +33,7 @@ TEST test_ini_get_bool(void)
ASSERT(ini_get_bool(bool_section, "boolbin1", false));
ASSERT_FALSE(ini_get_bool(bool_section, "boolbin0", true));
ASSERT(ini_get_bool(bool_section, "boolinvalid", true));
ASSERT_FALSE(ini_get_bool(bool_section, "boolinvalid", false));
ASSERT(ini_get_bool(bool_section, "nonexistent", true));