From 2d1d7bd16100eb9d702ef67897b2f62a972d6426 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Thu, 12 Mar 2020 17:36:00 +0100 Subject: add hashmap_resolve which handles dot notation --- tests/test_hashmap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_hashmap.c b/tests/test_hashmap.c index 68b8d0c..d78f768 100644 --- a/tests/test_hashmap.c +++ b/tests/test_hashmap.c @@ -15,4 +15,18 @@ TEST(hashmap) { hashmap_free(hm); } + +TEST(dot_notation) { + + struct hashmap *user = hashmap_new(); + hashmap_insert(user, "name", "Danny"); + struct hashmap *hm = hashmap_new(); + hashmap_insert(hm, "user", user); + char *value = (char *) hashmap_resolve(hm, "user.name"); + assert(value != NULL, "expected value, got NULL"); + assert(strcmp(value, "Danny") == 0, "expected %s, got %s", "Danny", value); + + hashmap_free(hm); +} + END_TESTS \ No newline at end of file -- cgit v1.2.3