Tue, 18 Apr 2023 19:15:50 +0200
tweak rehash test to achieve missing coverage
tests/test_map.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/tests/test_map.cpp Tue Apr 18 19:10:45 2023 +0200 1.2 +++ b/tests/test_map.cpp Tue Apr 18 19:15:50 2023 +0200 1.3 @@ -252,28 +252,34 @@ 1.4 1.5 TEST(CxHashMap, Rehash) { 1.6 CxTestingAllocator allocator; 1.7 - auto map = cxHashMapCreate(&allocator, CX_STORE_POINTERS, 8); 1.8 + auto map = cxHashMapCreate(&allocator, CX_STORE_POINTERS, 7); 1.9 1.10 cxMapPut(map, cx_hash_key_str("key 1"), (void *) "val 1"); 1.11 cxMapPut(map, cx_hash_key_str("key 2"), (void *) "val 2"); 1.12 cxMapPut(map, cx_hash_key_str("key 3"), (void *) "val 3"); 1.13 - cxMapPut(map, cx_hash_key_str("key 4"), (void *) "val 4"); 1.14 + cxMapPut(map, cx_hash_key_str("foo 4"), (void *) "val 4"); 1.15 cxMapPut(map, cx_hash_key_str("key 5"), (void *) "val 5"); 1.16 cxMapPut(map, cx_hash_key_str("key 6"), (void *) "val 6"); 1.17 - cxMapPut(map, cx_hash_key_str("key 7"), (void *) "val 7"); 1.18 + cxMapPut(map, cx_hash_key_str("bar 7"), (void *) "val 7"); 1.19 + cxMapPut(map, cx_hash_key_str("key 8"), (void *) "val 8"); 1.20 + cxMapPut(map, cx_hash_key_str("key 9"), (void *) "val 9"); 1.21 + cxMapPut(map, cx_hash_key_str("key 10"), (void *) "val 10"); 1.22 1.23 int result = cxMapRehash(map); 1.24 EXPECT_EQ(result, 0); 1.25 - EXPECT_EQ(reinterpret_cast<struct cx_hash_map_s *>(map)->bucket_count, 17); 1.26 - EXPECT_EQ(map->size, 7); 1.27 + EXPECT_EQ(reinterpret_cast<struct cx_hash_map_s *>(map)->bucket_count, 25); 1.28 + EXPECT_EQ(map->size, 10); 1.29 1.30 EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 1")), "val 1"), 0); 1.31 EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 2")), "val 2"), 0); 1.32 EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 3")), "val 3"), 0); 1.33 - EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 4")), "val 4"), 0); 1.34 + EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("foo 4")), "val 4"), 0); 1.35 EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 5")), "val 5"), 0); 1.36 EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 6")), "val 6"), 0); 1.37 - EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 7")), "val 7"), 0); 1.38 + EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("bar 7")), "val 7"), 0); 1.39 + EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 8")), "val 8"), 0); 1.40 + EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 9")), "val 9"), 0); 1.41 + EXPECT_EQ(strcmp((char *) cxMapGet(map, cx_hash_key_str("key 10")), "val 10"), 0); 1.42 1.43 cxMapDestroy(map); 1.44 EXPECT_TRUE(allocator.verify());