test/map_tests.c

changeset 52
34f50d0bada4
parent 51
1c78cd19fb6b
child 53
e533c170bfb8
equal deleted inserted replaced
51:1c78cd19fb6b 52:34f50d0bada4
298 values[i][5] = 48+i; values[i][6] = 0; 298 values[i][5] = 48+i; values[i][6] = 0;
299 299
300 ucx_map_cstr_put(map, keys[i], values[i]); 300 ucx_map_cstr_put(map, keys[i], values[i]);
301 } 301 }
302 302
303 map = ucx_map_rehash(map); 303 ucx_map_rehash(map);
304 304
305 UCX_TEST_BEGIN 305 UCX_TEST_BEGIN
306 UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count"); 306 UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count");
307 UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect"); 307 UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect");
308 for (int i = 0 ; i < 10 ; i++) { 308 for (int i = 0 ; i < 10 ; i++) {
309 char *value = ucx_map_cstr_get(map, keys[i]); 309 char *value = ucx_map_cstr_get(map, keys[i]);
310 UCX_TEST_ASSERT(value != NULL, "new map is missing old keys"); 310 UCX_TEST_ASSERT(value != NULL, "new map is missing old keys");
311 UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0, 311 UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0,
312 "new map contains incorrect values"); 312 "new map contains incorrect values");
313 } 313 }
314 UcxMap *samemap = ucx_map_rehash(map); 314 ucx_map_rehash(map);
315 UCX_TEST_ASSERT(samemap == map, 315 UCX_TEST_ASSERT(map->size == 25,
316 "subsequent rehashing call shall do nothing");
317 UCX_TEST_ASSERT(samemap->size == 25,
318 "subsequent rehashing call shall not change size"); 316 "subsequent rehashing call shall not change size");
319 UCX_TEST_END 317 UCX_TEST_END
320 318
321 ucx_map_free(map); 319 ucx_map_free(map);
322 } 320 }

mercurial