90 CX_TEST_ASSERT(*(int*)cxListAt(list, 1) == 37); |
90 CX_TEST_ASSERT(*(int*)cxListAt(list, 1) == 37); |
91 } |
91 } |
92 cxListFree(list); |
92 cxListFree(list); |
93 } |
93 } |
94 |
94 |
|
95 CX_TEST(test_kv_list_map_put_ptr) { |
|
96 CxList *list = cxKvListCreateSimple(CX_STORE_POINTERS); |
|
97 int x; |
|
98 CX_TEST_DO { |
|
99 CxMap *map = cxKvListAsMap(list); |
|
100 x = 13; |
|
101 CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", &x)); |
|
102 x = 37; |
|
103 CX_TEST_ASSERT((int*)cxListAt(list, 0) == &x); |
|
104 CX_TEST_ASSERT((int*)cxMapGet(map, "xyz") == &x); |
|
105 } |
|
106 cxListFree(list); |
|
107 } |
|
108 |
95 CX_TEST(test_kv_list_map_remove) { |
109 CX_TEST(test_kv_list_map_remove) { |
96 CxList *list = cxKvListCreateSimple(sizeof(int)); |
110 CxList *list = cxKvListCreateSimple(sizeof(int)); |
97 int x; |
111 int x; |
98 CX_TEST_DO { |
112 CX_TEST_DO { |
99 CxMap *map = cxKvListAsMap(list); |
113 CxMap *map = cxKvListAsMap(list); |
267 |
281 |
268 cxDefineDestructor(map, kv_list_test_destr); |
282 cxDefineDestructor(map, kv_list_test_destr); |
269 kv_list_test_destr_val = 0; |
283 kv_list_test_destr_val = 0; |
270 cxMapClear(map); |
284 cxMapClear(map); |
271 CX_TEST_ASSERT(kv_list_test_destr_val == 0xabcd); |
285 CX_TEST_ASSERT(kv_list_test_destr_val == 0xabcd); |
|
286 } |
|
287 cxMapFree(map); |
|
288 } |
|
289 |
|
290 CX_TEST(test_kv_list_destr_ptr) { |
|
291 CxMap *map = cxKvListCreateAsMapSimple(CX_STORE_POINTERS); |
|
292 cxDefineDestructor(map, kv_list_test_destr); |
|
293 int x; |
|
294 CX_TEST_DO { |
|
295 x = 0xabcd; |
|
296 CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", &x)); |
|
297 x = 0xef89; |
|
298 kv_list_test_destr_val = 0; |
|
299 CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz")); |
|
300 CX_TEST_ASSERT(kv_list_test_destr_val == 0xef89); |
272 } |
301 } |
273 cxMapFree(map); |
302 cxMapFree(map); |
274 } |
303 } |
275 |
304 |
276 CxTestSuite *cx_test_suite_kv_list_specifics(void) { |
305 CxTestSuite *cx_test_suite_kv_list_specifics(void) { |
278 |
307 |
279 cx_test_register(suite, test_kv_list_map_as_list); |
308 cx_test_register(suite, test_kv_list_map_as_list); |
280 cx_test_register(suite, test_kv_list_free_as_map); |
309 cx_test_register(suite, test_kv_list_free_as_map); |
281 cx_test_register(suite, test_kv_list_free_as_list); |
310 cx_test_register(suite, test_kv_list_free_as_list); |
282 cx_test_register(suite, test_kv_list_map_put); |
311 cx_test_register(suite, test_kv_list_map_put); |
|
312 cx_test_register(suite, test_kv_list_map_put_ptr); |
283 cx_test_register(suite, test_kv_list_map_remove); |
313 cx_test_register(suite, test_kv_list_map_remove); |
284 cx_test_register(suite, test_kv_list_set_key); |
314 cx_test_register(suite, test_kv_list_set_key); |
285 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
315 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
286 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
316 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
287 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
317 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
288 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
318 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
289 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |
319 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |
290 cx_test_register(suite, test_kv_list_list_clear_destr_in_map); |
320 cx_test_register(suite, test_kv_list_list_clear_destr_in_map); |
291 cx_test_register(suite, test_kv_list_map_clear_destr_in_list); |
321 cx_test_register(suite, test_kv_list_map_clear_destr_in_list); |
292 cx_test_register(suite, test_kv_list_map_clear_destr_in_map); |
322 cx_test_register(suite, test_kv_list_map_clear_destr_in_map); |
|
323 cx_test_register(suite, test_kv_list_destr_ptr); |
293 |
324 |
294 return suite; |
325 return suite; |
295 } |
326 } |