303 |
303 |
304 CxMapIterator iter = cxMapMutIterator(map); |
304 CxMapIterator iter = cxMapMutIterator(map); |
305 cx_foreach(CxMapEntry*, entry, iter) { |
305 cx_foreach(CxMapEntry*, entry, iter) { |
306 if (((const char *)entry->key->data)[4] % 2 == 1) cxIteratorFlagRemoval(iter); |
306 if (((const char *)entry->key->data)[4] % 2 == 1) cxIteratorFlagRemoval(iter); |
307 } |
307 } |
308 CX_TEST_ASSERT(map->collection.size == 3); |
308 CX_TEST_ASSERT(cxMapSize(map) == 3); |
|
309 CX_TEST_ASSERT(iter.elem_count == 3); |
309 CX_TEST_ASSERT(iter.index == map->collection.size); |
310 CX_TEST_ASSERT(iter.index == map->collection.size); |
310 |
311 |
311 CX_TEST_ASSERT(cxMapGet(map, "key 1") == NULL); |
312 CX_TEST_ASSERT(cxMapGet(map, "key 1") == NULL); |
312 CX_TEST_ASSERT(cxMapGet(map, "key 2") != NULL); |
313 CX_TEST_ASSERT(cxMapGet(map, "key 2") != NULL); |
313 CX_TEST_ASSERT(cxMapGet(map, "key 3") == NULL); |
314 CX_TEST_ASSERT(cxMapGet(map, "key 3") == NULL); |
401 |
402 |
402 // now remove k1 via key iterator and k5 (val 5) via value iterator |
403 // now remove k1 via key iterator and k5 (val 5) via value iterator |
403 v1[0] = 'y'; // mark v1 and check that destr is not called for previous val |
404 v1[0] = 'y'; // mark v1 and check that destr is not called for previous val |
404 { |
405 { |
405 CxMapIterator iter = cxMapMutIteratorKeys(map); |
406 CxMapIterator iter = cxMapMutIteratorKeys(map); |
|
407 CX_TEST_ASSERT(iter.elem_count == 4); |
|
408 CX_TEST_ASSERT(cxMapSize(map) == 4); |
406 cx_foreach(CxHashKey*, key, iter) { |
409 cx_foreach(CxHashKey*, key, iter) { |
407 if (((char*)key->data)[4] == '1') cxIteratorFlagRemoval(iter); |
410 if (((char*)key->data)[4] == '1') cxIteratorFlagRemoval(iter); |
408 } |
411 } |
|
412 CX_TEST_ASSERT(iter.elem_count == 3); |
|
413 CX_TEST_ASSERT(cxMapSize(map) == 3); |
409 } |
414 } |
410 { |
415 { |
411 CxMapIterator iter = cxMapMutIteratorValues(map); |
416 CxMapIterator iter = cxMapMutIteratorValues(map); |
412 cx_foreach(struct test_destr_struct*, v, iter) { |
417 cx_foreach(struct test_destr_struct*, v, iter) { |
413 if (v->str[4] == '5') cxIteratorFlagRemoval(iter); |
418 if (v->str[4] == '5') cxIteratorFlagRemoval(iter); |
414 } |
419 } |
|
420 CX_TEST_ASSERT(iter.elem_count == 2); |
|
421 CX_TEST_ASSERT(cxMapSize(map) == 2); |
415 } |
422 } |
416 |
423 |
417 CX_TEST_ASSERT(0 == strcmp(v1, "yK")); |
424 CX_TEST_ASSERT(0 == strcmp(v1, "yK")); |
418 CX_TEST_ASSERT(0 == strcmp(v2, "OK")); |
425 CX_TEST_ASSERT(0 == strcmp(v2, "OK")); |
419 CX_TEST_ASSERT(0 == strcmp(v3, "val 3")); |
426 CX_TEST_ASSERT(0 == strcmp(v3, "val 3")); |