diff -r a9989e16f7df -r 607f822c79fe tests/test_kv_list.c --- a/tests/test_kv_list.c Thu Sep 11 19:59:49 2025 +0200 +++ b/tests/test_kv_list.c Thu Sep 11 20:09:33 2025 +0200 @@ -92,6 +92,20 @@ cxListFree(list); } +CX_TEST(test_kv_list_map_put_ptr) { + CxList *list = cxKvListCreateSimple(CX_STORE_POINTERS); + int x; + CX_TEST_DO { + CxMap *map = cxKvListAsMap(list); + x = 13; + CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", &x)); + x = 37; + CX_TEST_ASSERT((int*)cxListAt(list, 0) == &x); + CX_TEST_ASSERT((int*)cxMapGet(map, "xyz") == &x); + } + cxListFree(list); +} + CX_TEST(test_kv_list_map_remove) { CxList *list = cxKvListCreateSimple(sizeof(int)); int x; @@ -273,6 +287,21 @@ cxMapFree(map); } +CX_TEST(test_kv_list_destr_ptr) { + CxMap *map = cxKvListCreateAsMapSimple(CX_STORE_POINTERS); + cxDefineDestructor(map, kv_list_test_destr); + int x; + CX_TEST_DO { + x = 0xabcd; + CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", &x)); + x = 0xef89; + kv_list_test_destr_val = 0; + CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz")); + CX_TEST_ASSERT(kv_list_test_destr_val == 0xef89); + } + cxMapFree(map); +} + CxTestSuite *cx_test_suite_kv_list_specifics(void) { CxTestSuite *suite = cx_test_suite_new("kv_list specifics"); @@ -280,6 +309,7 @@ cx_test_register(suite, test_kv_list_free_as_map); 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_put_ptr); 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); @@ -290,6 +320,7 @@ cx_test_register(suite, test_kv_list_list_clear_destr_in_map); cx_test_register(suite, test_kv_list_map_clear_destr_in_list); cx_test_register(suite, test_kv_list_map_clear_destr_in_map); + cx_test_register(suite, test_kv_list_destr_ptr); return suite; }