diff -r f61119884dcd -r 3db28cb1e5ec tests/test_kv_list.c --- a/tests/test_kv_list.c Sat Sep 20 12:27:36 2025 +0200 +++ b/tests/test_kv_list.c Sat Sep 20 12:30:07 2025 +0200 @@ -457,6 +457,33 @@ cxListFree(list); } +CX_TEST(test_kv_list_set_key_again) { + CxList *list = cxKvListCreateSimple(sizeof(int)); + int x; + CX_TEST_DO { + x = 47; + cxListAdd(list, &x); + x = 11; + cxListAdd(list, &x); + CX_TEST_ASSERT(0 == cxKvListSetKey(list, 1, "xyz")); + // calling it twice is also okay! + CX_TEST_ASSERT(0 == cxKvListSetKey(list, 1, "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 == 11); + + CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz")); + CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL); + CX_TEST_ASSERT(cxListSize(list) == 1); + } + cxListFree(list); +} + CX_TEST(test_kv_list_remove_key) { CxList *list = cxKvListCreateSimple(sizeof(int)); int x; @@ -799,6 +826,7 @@ cx_test_register(suite, test_kv_list_map_remove_and_get); cx_test_register(suite, test_kv_list_set_key); cx_test_register(suite, test_kv_list_set_key_already_exists); + cx_test_register(suite, test_kv_list_set_key_again); cx_test_register(suite, test_kv_list_remove_key); cx_test_register(suite, test_kv_list_insert_with_key); cx_test_register(suite, test_kv_list_insert_ptr_with_key);