diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2014-12-13 04:22:28 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2015-01-14 08:05:16 +0100 |
commit | 435fc3176520a58f1c20ccb983c9fb40b30a1471 (patch) | |
tree | 6fd30f7d11427b8f645191a398bafff0eb643a00 /src/test | |
parent | b50191c23f4cb6bac1180491b52e1df1e6c79a0f (diff) |
test: hashmap_put behaviour for equal keys
Check string ops hashmap_put() for keys with a different pointer but the same
value.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-hashmap-plain.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index 6f0910aae7..84b508f874 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -245,6 +245,8 @@ static void test_hashmap_put(void) { Hashmap *m = NULL; int valid_hashmap_put; void *val1 = (void*) "val 1"; + void *val2 = (void*) "val 2"; + _cleanup_free_ char* key1 = NULL; assert_se(hashmap_ensure_allocated(&m, &string_hash_ops) >= 0); assert_se(m); @@ -252,7 +254,10 @@ static void test_hashmap_put(void) { valid_hashmap_put = hashmap_put(m, "key 1", val1); assert_se(valid_hashmap_put == 1); assert_se(hashmap_put(m, "key 1", val1) == 0); - assert_se(hashmap_put(m, "key 1", (void *)"val 2") == -EEXIST); + assert_se(hashmap_put(m, "key 1", val2) == -EEXIST); + key1 = strdup("key 1"); + assert_se(hashmap_put(m, key1, val1) == 0); + assert_se(hashmap_put(m, key1, val2) == -EEXIST); hashmap_free(m); } |