348 CX_TEST_ASSERT(cxListSize(list) == 0); |
348 CX_TEST_ASSERT(cxListSize(list) == 0); |
349 } |
349 } |
350 cxListFree(list); |
350 cxListFree(list); |
351 } |
351 } |
352 |
352 |
|
353 CX_TEST(test_kv_list_remove_key) { |
|
354 CxList *list = cxKvListCreateSimple(sizeof(int)); |
|
355 int x; |
|
356 CX_TEST_DO { |
|
357 CxMap *map = cxKvListAsMap(list); |
|
358 |
|
359 x = 47; |
|
360 cxMapPut(map, "xyz", &x); |
|
361 x = 11; |
|
362 cxMapPut(map, "abc", &x); |
|
363 x = 1337; |
|
364 cxMapPut(map, "efg", &x); |
|
365 CX_TEST_ASSERT(cxMapSize(map) == 3); |
|
366 |
|
367 int *y = cxMapGet(map, "abc"); |
|
368 CX_TEST_ASSERT(y != NULL); |
|
369 CX_TEST_ASSERT(*y == 11); |
|
370 |
|
371 cxKvListRemoveKey(list, 1); |
|
372 CX_TEST_ASSERT(cxMapGet(map, "abc") == NULL); |
|
373 CX_TEST_ASSERT(cxMapSize(map) == 2); |
|
374 CX_TEST_ASSERT(cxListSize(list) == 3); |
|
375 |
|
376 CX_TEST_ASSERT(*(int*)cxListAt(list, 1) == 11); |
|
377 |
|
378 y = cxMapGet(map, "xyz"); |
|
379 CX_TEST_ASSERT(y != NULL); |
|
380 CX_TEST_ASSERT(*y == 47); |
|
381 |
|
382 y = cxMapGet(map, "efg"); |
|
383 CX_TEST_ASSERT(y != NULL); |
|
384 CX_TEST_ASSERT(*y == 1337); |
|
385 } |
|
386 cxListFree(list); |
|
387 } |
|
388 |
353 CX_TEST(test_kv_list_insert_array_and_set_keys) { |
389 CX_TEST(test_kv_list_insert_array_and_set_keys) { |
354 CxList *list = cxKvListCreateSimple(sizeof(int)); |
390 CxList *list = cxKvListCreateSimple(sizeof(int)); |
355 CX_TEST_DO { |
391 CX_TEST_DO { |
356 int arr[] = { 13, 21, 34, 55, 89 }; |
392 int arr[] = { 13, 21, 34, 55, 89 }; |
357 CX_TEST_ASSERT(5 == cxListAddArray(list, arr, 5)); |
393 CX_TEST_ASSERT(5 == cxListAddArray(list, arr, 5)); |
531 cx_test_register(suite, test_kv_list_remove_array_and_get); |
567 cx_test_register(suite, test_kv_list_remove_array_and_get); |
532 cx_test_register(suite, test_kv_list_map_put); |
568 cx_test_register(suite, test_kv_list_map_put); |
533 cx_test_register(suite, test_kv_list_map_put_ptr); |
569 cx_test_register(suite, test_kv_list_map_put_ptr); |
534 cx_test_register(suite, test_kv_list_map_remove); |
570 cx_test_register(suite, test_kv_list_map_remove); |
535 cx_test_register(suite, test_kv_list_set_key); |
571 cx_test_register(suite, test_kv_list_set_key); |
|
572 cx_test_register(suite, test_kv_list_remove_key); |
536 cx_test_register(suite, test_kv_list_insert_array_and_set_keys); |
573 cx_test_register(suite, test_kv_list_insert_array_and_set_keys); |
537 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
574 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
538 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
575 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
539 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
576 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
540 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
577 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |