| 337 CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL); |
337 CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL); |
| 338 } |
338 } |
| 339 cxListFree(list); |
339 cxListFree(list); |
| 340 } |
340 } |
| 341 |
341 |
| |
342 CX_TEST(test_kv_list_map_put_overwrite) { |
| |
343 CxList *list = cxKvListCreateSimple(CX_STORE_POINTERS); |
| |
344 CxTestingAllocator talloc; |
| |
345 cx_testing_allocator_init(&talloc); |
| |
346 CxAllocator *al = &talloc.base; |
| |
347 int *x, *y; |
| |
348 CX_TEST_DO { |
| |
349 CxMap *map = cxKvListAsMap(list); |
| |
350 cxDefineAdvancedDestructor(map, cxFree, al); |
| |
351 x = cxMalloc(al, sizeof(int)); |
| |
352 y = cxMalloc(al, sizeof(int)); |
| |
353 *x = 13; |
| |
354 *y = 37; |
| |
355 CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", x)); |
| |
356 CX_TEST_ASSERT(cxCollectionSize(map) == 1); |
| |
357 CX_TEST_ASSERT(cxCollectionSize(list) == 1); |
| |
358 CX_TEST_ASSERT(*(int*)cxListAt(list, 0) == 13); |
| |
359 CX_TEST_ASSERT(*(int*)cxMapGet(map, "xyz") == 13); |
| |
360 CX_TEST_ASSERT(0 == cxMapPut(map, "xyz", y)); |
| |
361 CX_TEST_ASSERT(cxCollectionSize(map) == 1); |
| |
362 CX_TEST_ASSERT(cxCollectionSize(list) == 1); |
| |
363 CX_TEST_ASSERT(*(int*)cxListAt(list, 0) == 37); |
| |
364 CX_TEST_ASSERT(*(int*)cxMapGet(map, "xyz") == 37); |
| |
365 cxMapClear(map); |
| |
366 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
| |
367 } |
| |
368 cx_testing_allocator_destroy(&talloc); |
| |
369 cxListFree(list); |
| |
370 } |
| |
371 |
| 342 CX_TEST(test_kv_list_map_remove) { |
372 CX_TEST(test_kv_list_map_remove) { |
| 343 CxList *list = cxKvListCreateSimple(sizeof(int)); |
373 CxList *list = cxKvListCreateSimple(sizeof(int)); |
| 344 int x; |
374 int x; |
| 345 CX_TEST_DO { |
375 CX_TEST_DO { |
| 346 CxMap *map = cxKvListAsMap(list); |
376 CxMap *map = cxKvListAsMap(list); |
| 1019 cx_test_register(suite, test_kv_list_remove_array); |
1049 cx_test_register(suite, test_kv_list_remove_array); |
| 1020 cx_test_register(suite, test_kv_list_remove_array_and_get); |
1050 cx_test_register(suite, test_kv_list_remove_array_and_get); |
| 1021 cx_test_register(suite, test_kv_list_map_put); |
1051 cx_test_register(suite, test_kv_list_map_put); |
| 1022 cx_test_register(suite, test_kv_list_map_put_ptr); |
1052 cx_test_register(suite, test_kv_list_map_put_ptr); |
| 1023 cx_test_register(suite, test_kv_list_map_put_not_hashed); |
1053 cx_test_register(suite, test_kv_list_map_put_not_hashed); |
| |
1054 cx_test_register(suite, test_kv_list_map_put_overwrite); |
| 1024 cx_test_register(suite, test_kv_list_map_remove); |
1055 cx_test_register(suite, test_kv_list_map_remove); |
| 1025 cx_test_register(suite, test_kv_list_map_remove_and_get); |
1056 cx_test_register(suite, test_kv_list_map_remove_and_get); |
| 1026 cx_test_register(suite, test_kv_list_set_key); |
1057 cx_test_register(suite, test_kv_list_set_key); |
| 1027 cx_test_register(suite, test_kv_list_set_key_already_exists); |
1058 cx_test_register(suite, test_kv_list_set_key_already_exists); |
| 1028 cx_test_register(suite, test_kv_list_set_key_again); |
1059 cx_test_register(suite, test_kv_list_set_key_again); |