MCPcopy Index your code
hub / github.com/git/git / t_remove

Function t_remove

t/unit-tests/u-hashmap.c:181–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181static void t_remove(struct hashmap *map, unsigned int ignore_case)
182{
183 struct test_entry *entry, *removed;
184 const char *key_val[][2] = { { "key1", "value1" },
185 { "key2", "value2" },
186 { "fooBarFrotz", "value3" } };
187 const char *remove[][2] = { { ignore_case ? "Key1" : "key1", "value1" },
188 { ignore_case ? "keY2" : "key2", "value2" } };
189
190 for (size_t i = 0; i < ARRAY_SIZE(key_val); i++) {
191 entry = alloc_test_entry(key_val[i][0], key_val[i][1], ignore_case);
192 cl_assert_equal_p(hashmap_put_entry(map, entry, ent), NULL);
193 }
194
195 for (size_t i = 0; i < ARRAY_SIZE(remove); i++) {
196 entry = alloc_test_entry(remove[i][0], "", ignore_case);
197 removed = hashmap_remove_entry(map, entry, ent, remove[i][0]);
198 cl_assert(removed != NULL);
199 cl_assert_equal_s(get_value(removed), remove[i][1]);
200 free(entry);
201 free(removed);
202 }
203
204 entry = alloc_test_entry("notInMap", "", ignore_case);
205 cl_assert_equal_p(hashmap_remove_entry(map, entry, ent, "notInMap"), NULL);
206 free(entry);
207
208 cl_assert_equal_i(map->tablesize, 64);
209 cl_assert_equal_i(hashmap_get_size(map),
210 ARRAY_SIZE(key_val) - ARRAY_SIZE(remove));
211}
212
213static void t_iterate(struct hashmap *map, unsigned int ignore_case)
214{

Callers

nothing calls this directly

Calls 3

hashmap_get_sizeFunction · 0.85
alloc_test_entryFunction · 0.70
get_valueFunction · 0.70

Tested by

no test coverage detected