# HG changeset patch # User Mike Becker # Date 1757364528 -7200 # Node ID 70ce877c838a3d9d3361f99b14113693ee6d4b16 # Parent e4135791687e1429121d7ad9b421a3679240a028 add failing test case test_kv_list_set_key() relates to #461 diff -r e4135791687e -r 70ce877c838a tests/test_kv_list.c --- a/tests/test_kv_list.c Sun Sep 07 17:08:26 2025 +0200 +++ b/tests/test_kv_list.c Mon Sep 08 22:48:48 2025 +0200 @@ -119,6 +119,31 @@ cxListFree(list); } +CX_TEST(test_kv_list_set_key) { + CxList *list = cxKvListCreateSimple(sizeof(int)); + int x; + CX_TEST_DO { + x = 47; + cxListAdd(list, &x); + CX_TEST_ASSERT(0 == cxKvListSetKey(list, 0, "xyz")); + + CxMap *map = cxKvListAsMap(list); + + CX_TEST_ASSERT(cxMapSize(map) == 1); + + int *y = cxMapGet(map, "xyz"); + CX_TEST_ASSERT(y != NULL); + CX_TEST_ASSERT(*y == 47); + + CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz")); + CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL); + + CX_TEST_ASSERT(cxListSize(list) == 0); + } + cxListFree(list); +} + + static int kv_list_test_destr_val; static void kv_list_test_destr(void *data) { kv_list_test_destr_val = *(int*)data; @@ -256,6 +281,7 @@ cx_test_register(suite, test_kv_list_free_as_list); cx_test_register(suite, test_kv_list_map_put); cx_test_register(suite, test_kv_list_map_remove); + cx_test_register(suite, test_kv_list_set_key); cx_test_register(suite, test_kv_list_list_remove_destr_in_list); cx_test_register(suite, test_kv_list_list_remove_destr_in_map); cx_test_register(suite, test_kv_list_map_remove_destr_in_list);