---
unit/test-hashmap.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/unit/test-hashmap.c b/unit/test-hashmap.c
index 51d03ba..e9c4541 100644
--- a/unit/test-hashmap.c
+++ b/unit/test-hashmap.c
@@ -236,6 +236,39 @@ static void foreach_cb(const void *key, void *value, void
*user_data)
}
}
+static unsigned int find_called = 0;
+
+static bool find_cb(const void *key, void *value, void *user_data)
+{
+ struct l_hashmap *hashmap = user_data;
+ static bool removed;
+ static unsigned int entries;
+ char *str, *mykey = "b";
+ bool ret;
+
+ if (!removed) {
+ printf("Removing entry in find\n");
+
+ str = l_hashmap_remove(hashmap, "world");
+ assert(str);
+
+ assert(!l_hashmap_lookup(hashmap, "world"));
+
+ entries = l_hashmap_size(hashmap);
+
+ removed = true;
+ }
+
+ find_called++;
+
+ if (!(find_called % 2)) {
+ assert(entries == 3);
+ return true;
+ }
+
+ return false;
+}
+
static void test_reentrant(const void *test_data)
{
struct l_hashmap *hashmap;
@@ -261,6 +294,9 @@ static void test_reentrant(const void *test_data)
l_hashmap_foreach(hashmap, foreach_cb, hashmap);
+ l_hashmap_find(hashmap, find_cb, hashmap);
+ assert(find_called == 2);
+
l_hashmap_destroy(hashmap, NULL);
}
--
1.8.3.1