From fb502903411401200ebf77c0ab0b559f83db7a09 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 14 Jul 2015 22:17:01 +0200
Subject: Add "str_map_unset_iter"
---
tests/liberty.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
(limited to 'tests/liberty.c')
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
--
cgit v1.2.3-70-g09d2