tweak rehash test to achieve missing coverage

Tue, 18 Apr 2023 19:15:50 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 18 Apr 2023 19:15:50 +0200
changeset 687
612ed521b1c5
parent 686
64919f63f059
child 688
c27fa8b67286

tweak rehash test to achieve missing coverage

tests/test_map.cpp file | annotate | diff | comparison | revisions
--- a/tests/test_map.cpp	Tue Apr 18 19:10:45 2023 +0200
+++ b/tests/test_map.cpp	Tue Apr 18 19:15:50 2023 +0200
@@ -252,28 +252,34 @@
 
 TEST(CxHashMap, Rehash) {
     CxTestingAllocator allocator;
-    auto map = cxHashMapCreate(&allocator, CX_STORE_POINTERS, 8);
+    auto map = cxHashMapCreate(&allocator, CX_STORE_POINTERS, 7);
 
     cxMapPut(map, cx_hash_key_str("key 1"), (void *) "val 1");
     cxMapPut(map, cx_hash_key_str("key 2"), (void *) "val 2");
     cxMapPut(map, cx_hash_key_str("key 3"), (void *) "val 3");
-    cxMapPut(map, cx_hash_key_str("key 4"), (void *) "val 4");
+    cxMapPut(map, cx_hash_key_str("foo 4"), (void *) "val 4");
     cxMapPut(map, cx_hash_key_str("key 5"), (void *) "val 5");
     cxMapPut(map, cx_hash_key_str("key 6"), (void *) "val 6");
-    cxMapPut(map, cx_hash_key_str("key 7"), (void *) "val 7");
+    cxMapPut(map, cx_hash_key_str("bar 7"), (void *) "val 7");
+    cxMapPut(map, cx_hash_key_str("key 8"), (void *) "val 8");
+    cxMapPut(map, cx_hash_key_str("key 9"), (void *) "val 9");
+    cxMapPut(map, cx_hash_key_str("key 10"), (void *) "val 10");
 
     int result = cxMapRehash(map);
     EXPECT_EQ(result, 0);
-    EXPECT_EQ(reinterpret_cast<struct cx_hash_map_s *>(map)->bucket_count, 17);
-    EXPECT_EQ(map->size, 7);
+    EXPECT_EQ(reinterpret_cast<struct cx_hash_map_s *>(map)->bucket_count, 25);
+    EXPECT_EQ(map->size, 10);
 
     EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 1")), "val 1"), 0);
     EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 2")), "val 2"), 0);
     EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 3")), "val 3"), 0);
-    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 4")), "val 4"), 0);
+    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("foo 4")), "val 4"), 0);
     EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 5")), "val 5"), 0);
     EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 6")), "val 6"), 0);
-    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 7")), "val 7"), 0);
+    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("bar 7")), "val 7"), 0);
+    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 8")), "val 8"), 0);
+    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 9")), "val 9"), 0);
+    EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 10")), "val 10"), 0);
 
     cxMapDestroy(map);
     EXPECT_TRUE(allocator.verify());

mercurial