test/map_tests.c

changeset 206
58b77eb51afd
parent 192
1e51558b9d09
child 225
a1a068c2c4ef
equal deleted inserted replaced
205:54a7ceb9151f 206:58b77eb51afd
161 161
162 UCX_TEST_END 162 UCX_TEST_END
163 ucx_map_free(map); 163 ucx_map_free(map);
164 } 164 }
165 165
166 UCX_TEST(test_ucx_map_clear) {
167 UcxMap *map = ucx_map_new(4);
168
169 int value = 42;
170
171 ucx_map_cstr_put(map, "Key0", &value);
172 ucx_map_cstr_put(map, "Key1", &value);
173 ucx_map_cstr_put(map, "Key2", &value);
174 ucx_map_cstr_put(map, "Key3", &value);
175 ucx_map_cstr_put(map, "Key4", &value);
176 ucx_map_cstr_put(map, "Key5", &value);
177 ucx_map_cstr_put(map, "Key6", &value);
178 UCX_TEST_BEGIN
179
180 ucx_map_clear(map);
181
182 UCX_TEST_ASSERT(map->count == 0, "map has not been cleared");
183 UCX_TEST_ASSERT(map->size == 4, "map size has changed unexpectedly");
184
185 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key0")==NULL, "element not removed");
186 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key1")==NULL, "element not removed");
187 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key2")==NULL, "element not removed");
188 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key3")==NULL, "element not removed");
189 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key4")==NULL, "element not removed");
190 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key5")==NULL, "element not removed");
191 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key6")==NULL, "element not removed");
192
193 UCX_TEST_END
194 ucx_map_free(map);
195 }
196
166 UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, UcxMap *map) { 197 UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, UcxMap *map) {
167 int v1 = 10; 198 int v1 = 10;
168 int v2 = 15; 199 int v2 = 15;
169 int v3 = 7; 200 int v3 = 7;
170 int v4 = 9; 201 int v4 = 9;

mercurial