summaryrefslogtreecommitdiff
path: root/p11-kit/tests/uri-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/uri-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/uri-test.c')
-rw-r--r--p11-kit/tests/uri-test.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/p11-kit/tests/uri-test.c b/p11-kit/tests/uri-test.c
index 1920412..11fdebe 100644
--- a/p11-kit/tests/uri-test.c
+++ b/p11-kit/tests/uri-test.c
@@ -210,18 +210,18 @@ test_uri_parse_with_bad_hex_encoding (CuTest *tc)
p11_kit_uri_free (uri);
}
-static int
+static bool
is_space_string (CK_UTF8CHAR_PTR string, CK_ULONG size, const char *check)
{
size_t i, len = strlen (check);
if (len > size)
- return 0;
+ return false;
if (memcmp (string, check, len) != 0)
- return 0;
+ return false;
for (i = len; i < size; ++i)
if (string[i] != ' ')
- return 0;
- return 1;
+ return false;
+ return true;
}
static void
@@ -909,6 +909,36 @@ test_uri_match_module (CuTest *tc)
}
static void
+test_uri_match_version (CuTest *tc)
+{
+ CK_INFO info;
+ P11KitUri *uri;
+ int ret;
+
+ memset (&info, 0, sizeof (info));
+
+ uri = p11_kit_uri_new ();
+ CuAssertPtrNotNull (tc, uri);
+
+ ret = p11_kit_uri_parse ("pkcs11:library-version=5.8", P11_KIT_URI_FOR_ANY, uri);
+ CuAssertIntEquals (tc, P11_KIT_URI_OK, ret);
+
+ info.libraryVersion.major = 5;
+ info.libraryVersion.minor = 8;
+
+ ret = p11_kit_uri_match_module_info (uri, &info);
+ CuAssertIntEquals (tc, 1, ret);
+
+ info.libraryVersion.major = 2;
+ info.libraryVersion.minor = 3;
+
+ ret = p11_kit_uri_match_module_info (uri, &info);
+ CuAssertIntEquals (tc, 0, ret);
+
+ p11_kit_uri_free (uri);
+}
+
+static void
test_uri_match_attributes (CuTest *tc)
{
CK_ATTRIBUTE attrs[4];
@@ -1208,6 +1238,7 @@ main (void)
SUITE_ADD_TEST (suite, test_uri_get_set_unrecognized);
SUITE_ADD_TEST (suite, test_uri_match_token);
SUITE_ADD_TEST (suite, test_uri_match_module);
+ SUITE_ADD_TEST (suite, test_uri_match_version);
SUITE_ADD_TEST (suite, test_uri_match_attributes);
SUITE_ADD_TEST (suite, test_uri_get_set_attribute);
SUITE_ADD_TEST (suite, test_uri_get_set_attributes);