diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conf-test.c | 64 | ||||
-rw-r--r-- | tests/hash-test.c | 158 |
2 files changed, 111 insertions, 111 deletions
diff --git a/tests/conf-test.c b/tests/conf-test.c index ac2a37d..a273c7b 100644 --- a/tests/conf-test.c +++ b/tests/conf-test.c @@ -47,55 +47,55 @@ static void test_parse_conf_1 (CuTest *tc) { - hash_t *ht; + hashmap *map; const char *value; - ht = _p11_conf_parse_file (SRCDIR "/files/test-1.conf", 0); - CuAssertPtrNotNull (tc, ht); + map = _p11_conf_parse_file (SRCDIR "/files/test-1.conf", 0); + CuAssertPtrNotNull (tc, map); - value = hash_get (ht, "key1"); + value = hash_get (map, "key1"); CuAssertStrEquals (tc, "value1", value); - value = hash_get (ht, "with-colon"); + value = hash_get (map, "with-colon"); CuAssertStrEquals (tc, "value-of-colon", value); - value = hash_get (ht, "with-whitespace"); + value = hash_get (map, "with-whitespace"); CuAssertStrEquals (tc, "value-with-whitespace", value); - value = hash_get (ht, "embedded-comment"); + value = hash_get (map, "embedded-comment"); CuAssertStrEquals (tc, "this is # not a comment", value); - hash_free (ht); + hash_free (map); } static void test_parse_ignore_missing (CuTest *tc) { - hash_t *ht; + hashmap *map; - ht = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", CONF_IGNORE_MISSING); - CuAssertPtrNotNull (tc, ht); + map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", CONF_IGNORE_MISSING); + CuAssertPtrNotNull (tc, map); - CuAssertIntEquals (tc, 0, hash_count (ht)); + CuAssertIntEquals (tc, 0, hash_size (map)); CuAssertPtrEquals (tc, NULL, (void*)p11_kit_message ()); - hash_free (ht); + hash_free (map); } static void test_parse_fail_missing (CuTest *tc) { - hash_t *ht; + hashmap *map; - ht = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0); - CuAssertPtrEquals (tc, ht, NULL); + map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0); + CuAssertPtrEquals (tc, map, NULL); CuAssertPtrNotNull (tc, p11_kit_message ()); } static void test_merge_defaults (CuTest *tc) { - hash_t *values; - hash_t *defaults; + hashmap *values; + hashmap *defaults; values = hash_create (hash_string_hash, hash_string_equal, free, free); defaults = hash_create (hash_string_hash, hash_string_equal, free, free); @@ -122,7 +122,7 @@ static void test_load_globals_merge (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; _p11_kit_clear_message (); @@ -144,7 +144,7 @@ static void test_load_globals_no_user (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; _p11_kit_clear_message (); @@ -166,7 +166,7 @@ static void test_load_globals_user_sets_only (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; _p11_kit_clear_message (); @@ -188,7 +188,7 @@ static void test_load_globals_system_sets_only (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; _p11_kit_clear_message (); @@ -210,7 +210,7 @@ static void test_load_globals_system_sets_invalid (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; int error; _p11_kit_clear_message (); @@ -230,7 +230,7 @@ static void test_load_globals_user_sets_invalid (CuTest *tc) { int user_mode = -1; - hash_t *config; + hashmap *config; int error; _p11_kit_clear_message (); @@ -249,8 +249,8 @@ test_load_globals_user_sets_invalid (CuTest *tc) static void test_load_modules_merge (CuTest *tc) { - hash_t *configs; - hash_t *config; + hashmap *configs; + hashmap *config; _p11_kit_clear_message (); @@ -281,8 +281,8 @@ test_load_modules_merge (CuTest *tc) static void test_load_modules_user_none (CuTest *tc) { - hash_t *configs; - hash_t *config; + hashmap *configs; + hashmap *config; _p11_kit_clear_message (); @@ -311,8 +311,8 @@ test_load_modules_user_none (CuTest *tc) static void test_load_modules_user_only (CuTest *tc) { - hash_t *configs; - hash_t *config; + hashmap *configs; + hashmap *config; _p11_kit_clear_message (); @@ -341,8 +341,8 @@ test_load_modules_user_only (CuTest *tc) static void test_load_modules_no_user (CuTest *tc) { - hash_t *configs; - hash_t *config; + hashmap *configs; + hashmap *config; _p11_kit_clear_message (); diff --git a/tests/hash-test.c b/tests/hash-test.c index 3349c26..73edeab 100644 --- a/tests/hash-test.c +++ b/tests/hash-test.c @@ -39,16 +39,16 @@ #include <stdio.h> #include <string.h> -#include "hash.h" +#include "hashmap.h" static void test_hash_create (CuTest *tc) { - hash_t *ht; + hashmap *map; - ht = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); - CuAssertPtrNotNull (tc, ht); - hash_free (ht); + map = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); + CuAssertPtrNotNull (tc, map); + hash_free (map); } static void @@ -74,15 +74,15 @@ destroy_value (void *data) static void test_hash_free_destroys (CuTest *tc) { - hash_t *ht; + hashmap *map; int key = 0; int value = 0; - ht = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); - CuAssertPtrNotNull (tc, ht); - if (!hash_set (ht, &key, &value)) + map = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); + CuAssertPtrNotNull (tc, map); + if (!hash_set (map, &key, &value)) CuFail (tc, "should not be reached"); - hash_free (ht); + hash_free (map); CuAssertIntEquals (tc, 1, key); CuAssertIntEquals (tc, 2, value); @@ -91,30 +91,30 @@ test_hash_free_destroys (CuTest *tc) static void test_hash_iterate (CuTest *tc) { - hash_t *ht; - hash_iter_t hi; + hashmap *map; + hashiter iter; int key = 1; int value = 2; void *pkey; void *pvalue; int ret; - ht = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); - CuAssertPtrNotNull (tc, ht); - if (!hash_set (ht, &key, &value)) + map = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); + CuAssertPtrNotNull (tc, map); + if (!hash_set (map, &key, &value)) CuFail (tc, "should not be reached"); - hash_iterate (ht, &hi); + hash_iterate (map, &iter); - ret = hash_next (&hi, &pkey, &pvalue); + ret = hash_next (&iter, &pkey, &pvalue); CuAssertIntEquals (tc, 1, ret); CuAssertPtrEquals (tc, pkey, &key); CuAssertPtrEquals (tc, pvalue, &value); - ret = hash_next (&hi, &pkey, &pvalue); + ret = hash_next (&iter, &pkey, &pvalue); CuAssertIntEquals (tc, 0, ret); - hash_free (ht); + hash_free (map); } static void @@ -123,14 +123,14 @@ test_hash_set_get (CuTest *tc) char *key = "KEY"; char *value = "VALUE"; char *check; - hash_t *ht; + hashmap *map; - ht = hash_create (hash_string_hash, hash_string_equal, NULL, NULL); - hash_set (ht, key, value); - check = hash_get (ht, key); + map = hash_create (hash_string_hash, hash_string_equal, NULL, NULL); + hash_set (map, key, value); + check = hash_get (map, key); CuAssertPtrEquals (tc, check, value); - hash_free (ht); + hash_free (map); } static void @@ -139,26 +139,26 @@ test_hash_set_get_remove (CuTest *tc) char *key = "KEY"; char *value = "VALUE"; char *check; - hash_t *ht; + hashmap *map; int ret; - ht = hash_create (hash_string_hash, hash_string_equal, NULL, NULL); + map = hash_create (hash_string_hash, hash_string_equal, NULL, NULL); - if (!hash_set (ht, key, value)) + if (!hash_set (map, key, value)) CuFail (tc, "should not be reached"); - check = hash_get (ht, key); + check = hash_get (map, key); CuAssertPtrEquals (tc, check, value); - ret = hash_remove (ht, key); + ret = hash_remove (map, key); CuAssertIntEquals (tc, ret, 1); - ret = hash_remove (ht, key); + ret = hash_remove (map, key); CuAssertIntEquals (tc, ret, 0); - check = hash_get (ht, key); + check = hash_get (map, key); CuAssert (tc, "should be null", check == NULL); - hash_free (ht); + hash_free (map); } static void @@ -167,38 +167,38 @@ test_hash_set_get_clear (CuTest *tc) char *key = "KEY"; char *value = "VALUE"; char *check; - hash_t *ht; + hashmap *map; - ht = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); + map = hash_create (hash_direct_hash, hash_direct_equal, NULL, NULL); - if (!hash_set (ht, key, value)) + if (!hash_set (map, key, value)) CuFail (tc, "should not be reached"); - check = hash_get (ht, key); + check = hash_get (map, key); CuAssertPtrEquals (tc, check, value); - hash_clear (ht); + hash_clear (map); - check = hash_get (ht, key); + check = hash_get (map, key); CuAssert (tc, "should be null", check == NULL); - hash_free (ht); + hash_free (map); } static void test_hash_remove_destroys (CuTest *tc) { - hash_t *ht; + hashmap *map; int key = 0; int value = 0; int ret; - ht = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); - CuAssertPtrNotNull (tc, ht); - if (!hash_set (ht, &key, &value)) + map = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); + CuAssertPtrNotNull (tc, map); + if (!hash_set (map, &key, &value)) CuFail (tc, "should not be reached"); - ret = hash_remove (ht, &key); + ret = hash_remove (map, &key); CuAssertIntEquals (tc, ret, 1); CuAssertIntEquals (tc, 1, key); CuAssertIntEquals (tc, 2, value); @@ -207,7 +207,7 @@ test_hash_remove_destroys (CuTest *tc) key = 0; value = 0; - ret = hash_remove (ht, &key); + ret = hash_remove (map, &key); CuAssertIntEquals (tc, ret, 0); CuAssertIntEquals (tc, 0, key); CuAssertIntEquals (tc, 0, value); @@ -216,7 +216,7 @@ test_hash_remove_destroys (CuTest *tc) key = 0; value = 0; - hash_free (ht); + hash_free (map); CuAssertIntEquals (tc, 0, key); CuAssertIntEquals (tc, 0, value); @@ -225,18 +225,18 @@ test_hash_remove_destroys (CuTest *tc) static void test_hash_set_destroys (CuTest *tc) { - hash_t *ht; + hashmap *map; int key = 0; int value = 0; int value2 = 0; int ret; - ht = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); - CuAssertPtrNotNull (tc, ht); - if (!hash_set (ht, &key, &value)) + map = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); + CuAssertPtrNotNull (tc, map); + if (!hash_set (map, &key, &value)) CuFail (tc, "should not be reached"); - ret = hash_set (ht, &key, &value2); + ret = hash_set (map, &key, &value2); CuAssertIntEquals (tc, ret, 1); CuAssertIntEquals (tc, 0, key); CuAssertIntEquals (tc, 2, value); @@ -246,7 +246,7 @@ test_hash_set_destroys (CuTest *tc) value = 0; value2 = 0; - hash_free (ht); + hash_free (map); CuAssertIntEquals (tc, 1, key); CuAssertIntEquals (tc, 0, value); @@ -257,16 +257,16 @@ test_hash_set_destroys (CuTest *tc) static void test_hash_clear_destroys (CuTest *tc) { - hash_t *ht; + hashmap *map; int key = 0; int value = 0; - ht = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); - CuAssertPtrNotNull (tc, ht); - if (!hash_set (ht, &key, &value)) + map = hash_create (hash_direct_hash, hash_direct_equal, destroy_key, destroy_value); + CuAssertPtrNotNull (tc, map); + if (!hash_set (map, &key, &value)) CuFail (tc, "should not be reached"); - hash_clear (ht); + hash_clear (map); CuAssertIntEquals (tc, 1, key); CuAssertIntEquals (tc, 2, value); @@ -274,7 +274,7 @@ test_hash_clear_destroys (CuTest *tc) key = 0; value = 0; - hash_clear (ht); + hash_clear (map); CuAssertIntEquals (tc, 0, key); CuAssertIntEquals (tc, 0, value); @@ -282,7 +282,7 @@ test_hash_clear_destroys (CuTest *tc) key = 0; value = 0; - hash_free (ht); + hash_free (map); CuAssertIntEquals (tc, 0, key); CuAssertIntEquals (tc, 0, value); @@ -298,83 +298,83 @@ test_hash_intptr_with_collisions (const void *data) static void test_hash_add_check_lots_and_collisions (CuTest *tc) { - hash_t *ht; + hashmap *map; int *value; int i; - ht = hash_create (test_hash_intptr_with_collisions, + map = hash_create (test_hash_intptr_with_collisions, hash_intptr_equal, NULL, free); for (i = 0; i < 20000; ++i) { value = malloc (sizeof (int)); *value = i; - if (!hash_set (ht, value, value)) + if (!hash_set (map, value, value)) CuFail (tc, "should not be reached"); } for (i = 0; i < 20000; ++i) { - value = hash_get (ht, &i); + value = hash_get (map, &i); CuAssertPtrNotNull (tc, value); CuAssertIntEquals (tc, i, *value); } - hash_free (ht); + hash_free (map); } static void test_hash_count (CuTest *tc) { - hash_t *ht; + hashmap *map; int *value; int i, ret; - ht = hash_create (hash_intptr_hash, hash_intptr_equal, NULL, free); + map = hash_create (hash_intptr_hash, hash_intptr_equal, NULL, free); - CuAssertIntEquals (tc, 0, hash_count (ht)); + CuAssertIntEquals (tc, 0, hash_size (map)); for (i = 0; i < 20000; ++i) { value = malloc (sizeof (int)); *value = i; - if (!hash_set (ht, value, value)) + if (!hash_set (map, value, value)) CuFail (tc, "should not be reached"); - CuAssertIntEquals (tc, i + 1, hash_count (ht)); + CuAssertIntEquals (tc, i + 1, hash_size (map)); } for (i = 0; i < 20000; ++i) { - ret = hash_remove (ht, &i); + ret = hash_remove (map, &i); CuAssertIntEquals (tc, 1, ret); - CuAssertIntEquals (tc, 20000 - (i + 1), hash_count (ht)); + CuAssertIntEquals (tc, 20000 - (i + 1), hash_size (map)); } - hash_clear (ht); - CuAssertIntEquals (tc, 0, hash_count (ht)); + hash_clear (map); + CuAssertIntEquals (tc, 0, hash_size (map)); - hash_free (ht); + hash_free (map); } static void test_hash_ulongptr (CuTest *tc) { - hash_t *ht; + hashmap *map; unsigned long *value; unsigned long i; - ht = hash_create (hash_ulongptr_hash, hash_ulongptr_equal, NULL, free); + map = hash_create (hash_ulongptr_hash, hash_ulongptr_equal, NULL, free); for (i = 0; i < 20000; ++i) { value = malloc (sizeof (unsigned long)); *value = i; - if (!hash_set (ht, value, value)) + if (!hash_set (map, value, value)) CuFail (tc, "should not be reached"); } for (i = 0; i < 20000; ++i) { - value = hash_get (ht, &i); + value = hash_get (map, &i); CuAssertPtrNotNull (tc, value); CuAssertIntEquals (tc, i, *value); } - hash_free (ht); + hash_free (map); } int |