summaryrefslogtreecommitdiff
path: root/p11-kit/tests/conf-test.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-01-23 14:29:25 +0100
committerStef Walter <stefw@gnome.org>2013-01-23 14:29:25 +0100
commitb28c936bd281c4b7ff9ed0f621b840f6d5a4b328 (patch)
tree9645b90b794908d378970aafd73e7726c5267341 /p11-kit/tests/conf-test.c
parent4671352fe2a4f56c6707322dcab0015e2e8600c4 (diff)
Use the stdbool.h C99 bool type
It was getting really wild knowing whether a function returning an int would return -1 on failure or 0 or whether the int return value was actually a number etc..
Diffstat (limited to 'p11-kit/tests/conf-test.c')
-rw-r--r--p11-kit/tests/conf-test.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/p11-kit/tests/conf-test.c b/p11-kit/tests/conf-test.c
index ab3b31d..704313d 100644
--- a/p11-kit/tests/conf-test.c
+++ b/p11-kit/tests/conf-test.c
@@ -107,7 +107,7 @@ test_merge_defaults (CuTest *tc)
p11_dict_set (defaults, strdup ("two"), strdup ("default2"));
p11_dict_set (defaults, strdup ("three"), strdup ("default3"));
- if (_p11_conf_merge_defaults (values, defaults) < 0)
+ if (!_p11_conf_merge_defaults (values, defaults))
CuFail (tc, "should not be reached");
p11_dict_free (defaults);
@@ -247,13 +247,11 @@ test_load_globals_user_sets_invalid (CuTest *tc)
p11_dict_free (config);
}
-static int
+static bool
assert_msg_contains (const char *msg,
const char *text)
{
- if (msg == NULL)
- return 0;
- return strstr (msg, text) ? 1 : 0;
+ return (msg && strstr (msg, text)) ? true : false;
}
static void
@@ -378,6 +376,16 @@ test_load_modules_no_user (CuTest *tc)
p11_dict_free (configs);
}
+static void
+test_parse_boolean (CuTest *tc)
+{
+ p11_message_quiet ();
+
+ CuAssertIntEquals (tc, true, _p11_conf_parse_boolean ("yes", false));
+ CuAssertIntEquals (tc, false, _p11_conf_parse_boolean ("no", true));
+ CuAssertIntEquals (tc, true, _p11_conf_parse_boolean ("!!!", true));
+}
+
int
main (void)
{
@@ -402,6 +410,7 @@ main (void)
SUITE_ADD_TEST (suite, test_load_modules_no_user);
SUITE_ADD_TEST (suite, test_load_modules_user_only);
SUITE_ADD_TEST (suite, test_load_modules_user_none);
+ SUITE_ADD_TEST (suite, test_parse_boolean);
p11_kit_be_quiet ();