MCPcopy Create free account
hub / github.com/git/git / t_iterate

Function t_iterate

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

Source from the content-addressed store, hash-verified

211}
212
213static void t_iterate(struct hashmap *map, unsigned int ignore_case)
214{
215 struct test_entry *entry;
216 struct hashmap_iter iter;
217 const char *key_val[][2] = { { "key1", "value1" },
218 { "key2", "value2" },
219 { "fooBarFrotz", "value3" } };
220 char seen[ARRAY_SIZE(key_val)] = { 0 };
221
222 for (size_t i = 0; i < ARRAY_SIZE(key_val); i++) {
223 entry = alloc_test_entry(key_val[i][0], key_val[i][1], ignore_case);
224 cl_assert_equal_p(hashmap_put_entry(map, entry, ent), NULL);
225 }
226
227 hashmap_for_each_entry(map, &iter, entry, ent /* member name */)
228 {
229 int ret = key_val_contains(key_val, seen,
230 ARRAY_SIZE(key_val),
231 entry);
232 cl_assert(ret == 0);
233 }
234
235 for (size_t i = 0; i < ARRAY_SIZE(seen); i++)
236 cl_assert_equal_i(seen[i], 1);
237
238 cl_assert_equal_i(hashmap_get_size(map), ARRAY_SIZE(key_val));
239}
240
241static void t_alloc(struct hashmap *map, unsigned int ignore_case)
242{

Callers

nothing calls this directly

Calls 3

hashmap_get_sizeFunction · 0.85
alloc_test_entryFunction · 0.70
key_val_containsFunction · 0.70

Tested by

no test coverage detected