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

Function t_get

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

Source from the content-addressed store, hash-verified

104}
105
106static void t_get(struct hashmap *map, unsigned int ignore_case)
107{
108 struct test_entry *entry;
109 const char *key_val[][2] = { { "key1", "value1" },
110 { "key2", "value2" },
111 { "fooBarFrotz", "value3" },
112 { ignore_case ? "key4" : "foobarfrotz",
113 "value4" } };
114 const char *query[][2] = {
115 { ignore_case ? "Key1" : "key1", "value1" },
116 { ignore_case ? "keY2" : "key2", "value2" },
117 { ignore_case ? "FOObarFrotz" : "fooBarFrotz", "value3" },
118 { ignore_case ? "FOObarFrotz" : "foobarfrotz",
119 ignore_case ? "value3" : "value4" }
120 };
121
122 for (size_t i = 0; i < ARRAY_SIZE(key_val); i++) {
123 entry = alloc_test_entry(key_val[i][0], key_val[i][1],
124 ignore_case);
125 cl_assert_equal_p(hashmap_put_entry(map, entry, ent), NULL);
126 }
127
128 for (size_t i = 0; i < ARRAY_SIZE(query); i++) {
129 entry = get_test_entry(map, query[i][0], ignore_case);
130 cl_assert(entry != NULL);
131 cl_assert_equal_s(get_value(entry), query[i][1]);
132 }
133
134 cl_assert_equal_p(get_test_entry(map, "notInMap", ignore_case), NULL);
135 cl_assert_equal_i(map->tablesize, 64);
136 cl_assert_equal_i(hashmap_get_size(map), ARRAY_SIZE(key_val));
137}
138
139static void t_add(struct hashmap *map, unsigned int ignore_case)
140{

Callers

nothing calls this directly

Calls 4

get_test_entryFunction · 0.85
hashmap_get_sizeFunction · 0.85
alloc_test_entryFunction · 0.70
get_valueFunction · 0.70

Tested by

no test coverage detected