aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-14 22:17:01 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-14 22:17:01 +0200
commitfb502903411401200ebf77c0ab0b559f83db7a09 (patch)
tree7d36bbacc414d0b151d53dbdbf3f45f328c2a701 /tests
parent7fa873fb964156e71a00174f50e3f4bc343bcc04 (diff)
downloadliberty-fb502903411401200ebf77c0ab0b559f83db7a09.tar.gz
liberty-fb502903411401200ebf77c0ab0b559f83db7a09.tar.xz
liberty-fb502903411401200ebf77c0ab0b559f83db7a09.zip
Add "str_map_unset_iter"
Diffstat (limited to 'tests')
-rw-r--r--tests/liberty.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/liberty.c b/tests/liberty.c
index 349ee78..ac4b315 100644
--- a/tests/liberty.c
+++ b/tests/liberty.c
@@ -306,6 +306,30 @@ test_str_map (void)
soft_assert (*b == 1);
free_counter (a);
free_counter (b);
+
+ // Iterator test with a high number of items
+ str_map_init (&m);
+ m.free = free;
+
+ for (size_t i = 0; i < 100 * 100; i++)
+ {
+ char *x = xstrdup_printf ("%zu", i);
+ str_map_set (&m, x, x);
+ }
+
+ struct str_map_unset_iter unset_iter;
+ str_map_unset_iter_init (&unset_iter, &m);
+ while ((str_map_unset_iter_next (&unset_iter)))
+ {
+ unsigned long x;
+ hard_assert (xstrtoul (&x, unset_iter.link->key, 10));
+ if (x >= 100)
+ str_map_set (&m, unset_iter.link->key, NULL);
+ }
+ str_map_unset_iter_free (&unset_iter);
+
+ soft_assert (m.len == 100);
+ str_map_free (&m);
}
static void