add test_kv_list_map_remove()

Tue, 02 Sep 2025 20:26:10 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 02 Sep 2025 20:26:10 +0200
changeset 1359
fd7bbda93c7f
parent 1358
dda9c330e3e5
child 1360
8b29d732f97b

add test_kv_list_map_remove()

relates to #461

tests/test_kv_list.c file | annotate | diff | comparison | revisions
--- a/tests/test_kv_list.c	Mon Sep 01 20:20:12 2025 +0200
+++ b/tests/test_kv_list.c	Tue Sep 02 20:26:10 2025 +0200
@@ -65,11 +65,37 @@
     cxListFree(list);
 }
 
+CX_TEST(test_kv_list_map_remove) {
+    CxList *list = cxKvListCreateSimple(sizeof(int));
+    int x;
+    CX_TEST_DO {
+        CxMap *map = cxKvListAsMap(list);
+
+        x = 13;
+        CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", &x));
+
+        x = 37;
+        CX_TEST_ASSERT(0 == cxMapPut(map, "abc", &x));
+
+        CX_TEST_ASSERT(cxMapSize(map) == 2);
+
+        CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz"));
+        CX_TEST_ASSERT(cxMapSize(map) == 1);
+        CX_TEST_ASSERT(cxMapGet(map, "abc") != NULL);
+        CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL);
+
+        CX_TEST_ASSERT(cxListSize(list) == 1);
+        CX_TEST_ASSERT(*(int*)cxListAt(list, 0) == 37);
+    }
+    cxListFree(list);
+}
+
 CxTestSuite *cx_test_suite_kv_list_specifics(void) {
     CxTestSuite *suite = cx_test_suite_new("kv_list specifics");
 
     cx_test_register(suite, test_kv_list_map_as_list);
     cx_test_register(suite, test_kv_list_map_put);
+    cx_test_register(suite, test_kv_list_map_remove);
 
     return suite;
 }

mercurial