[systemd-commits] src/test

Martin Pitt martin at kemper.freedesktop.org
Tue Jan 13 23:05:28 PST 2015


 src/test/test-hashmap-plain.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 435fc3176520a58f1c20ccb983c9fb40b30a1471
Author: Martin Pitt <martin.pitt at ubuntu.com>
Date:   Sat Dec 13 04:22:28 2014 +0100

    test: hashmap_put behaviour for equal keys
    
    Check string ops hashmap_put() for keys with a different pointer but the same
    value.

diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c
index 6f0910a..84b508f 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);
 }



More information about the systemd-commits mailing list