Mon, 24 Nov 2025 22:15:16 +0100
adjust test_hash_map_remove_via_iterator s.t. we achieve coverage for the case where we remove not the first element of a bucket
| tests/test_hash_map.c | file | annotate | diff | comparison | revisions |
--- a/tests/test_hash_map.c Sun Nov 23 13:30:07 2025 +0100 +++ b/tests/test_hash_map.c Mon Nov 24 22:15:16 2025 +0100 @@ -309,7 +309,7 @@ cx_testing_allocator_init(&talloc); CxAllocator *allocator = &talloc.base; CX_TEST_DO { - CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 4); + CxMap *map = cxHashMapCreate(allocator, CX_STORE_POINTERS, 3); cxMapPut(map, "key 1", (void *) "val 1"); cxMapPut(map, "key 2", (void *) "val 2"); @@ -317,13 +317,16 @@ cxMapPut(map, "key 4", (void *) "val 4"); cxMapPut(map, "key 5", (void *) "val 5"); cxMapPut(map, "key 6", (void *) "val 6"); + cxMapPut(map, "key 7", (void *) "val 7"); + cxMapPut(map, "key 8", (void *) "val 8"); + cxMapPut(map, "key 9", (void *) "val 9"); CxMapIterator iter = cxMapIterator(map); cx_foreach(CxMapEntry*, entry, iter) { if (((const char *)entry->key->data)[4] % 2 == 1) cxIteratorFlagRemoval(iter); } - CX_TEST_ASSERT(cxMapSize(map) == 3); - CX_TEST_ASSERT(iter.elem_count == 3); + CX_TEST_ASSERT(cxMapSize(map) == 4); + CX_TEST_ASSERT(iter.elem_count == 4); CX_TEST_ASSERT(iter.index == map->collection.size); CX_TEST_ASSERT(cxMapGet(map, "key 1") == NULL); @@ -332,6 +335,9 @@ CX_TEST_ASSERT(cxMapGet(map, "key 4") != NULL); CX_TEST_ASSERT(cxMapGet(map, "key 5") == NULL); CX_TEST_ASSERT(cxMapGet(map, "key 6") != NULL); + CX_TEST_ASSERT(cxMapGet(map, "key 7") == NULL); + CX_TEST_ASSERT(cxMapGet(map, "key 8") != NULL); + CX_TEST_ASSERT(cxMapGet(map, "key 9") == NULL); cxMapFree(map); CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));