void test_hashset_iter_remove() { HashSet *hs = hashset_new(); char *a = "foo"; char *b = "bar"; char *c = "baz"; hashset_add(hs, a); hashset_add(hs, b); hashset_add(hs, c); HashSetIter iter; hashset_iter_init(&iter, hs); while (hashset_iter_has_next(&iter)) { char const *e = hashset_iter_next(&iter); if (!strcmp(e, "bar")) hashset_iter_remove(&iter); } cc_assert(hashset_size(hs) == 2, cc_msg("hashset_iter: Expected size 2 but got %d ", hashset_size(hs))); cc_assert(!hashset_contains(hs, "bar"), cc_msg("hashset_iter: Element (%s) still pressent " "after removal", "bar")); hashset_destroy(hs); }
void test_hashset_iter_remove() { HashSet *hs; hashset_new(&hs); char *a = "foo"; char *b = "bar"; char *c = "baz"; hashset_add(hs, a); hashset_add(hs, b); hashset_add(hs, c); HashSetIter iter; hashset_iter_init(&iter, hs); char *e; while (hashset_iter_next(&iter, (void*) &e) != CC_ITER_END) { if (!strcmp(e, "bar")) hashset_iter_remove(&iter, NULL); } cc_assert(hashset_size(hs) == 2, cc_msg("hashset_iter: Expected size 2 but got %d ", hashset_size(hs))); cc_assert(!hashset_contains(hs, "bar"), cc_msg("hashset_iter: Element (%s) still pressent " "after removal", "bar")); hashset_destroy(hs); }