tests/test_kv_list.c

changeset 1383
3db28cb1e5ec
parent 1382
f61119884dcd
equal deleted inserted replaced
1382:f61119884dcd 1383:3db28cb1e5ec
455 CX_TEST_ASSERT(*y == 47); 455 CX_TEST_ASSERT(*y == 47);
456 } 456 }
457 cxListFree(list); 457 cxListFree(list);
458 } 458 }
459 459
460 CX_TEST(test_kv_list_set_key_again) {
461 CxList *list = cxKvListCreateSimple(sizeof(int));
462 int x;
463 CX_TEST_DO {
464 x = 47;
465 cxListAdd(list, &x);
466 x = 11;
467 cxListAdd(list, &x);
468 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 1, "xyz"));
469 // calling it twice is also okay!
470 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 1, "xyz"));
471
472 CxMap *map = cxKvListAsMap(list);
473
474 CX_TEST_ASSERT(cxMapSize(map) == 1);
475
476 int *y = cxMapGet(map, "xyz");
477 CX_TEST_ASSERT(y != NULL);
478 CX_TEST_ASSERT(*y == 11);
479
480 CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz"));
481 CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL);
482 CX_TEST_ASSERT(cxListSize(list) == 1);
483 }
484 cxListFree(list);
485 }
486
460 CX_TEST(test_kv_list_remove_key) { 487 CX_TEST(test_kv_list_remove_key) {
461 CxList *list = cxKvListCreateSimple(sizeof(int)); 488 CxList *list = cxKvListCreateSimple(sizeof(int));
462 int x; 489 int x;
463 CX_TEST_DO { 490 CX_TEST_DO {
464 CxMap *map = cxKvListAsMap(list); 491 CxMap *map = cxKvListAsMap(list);
797 cx_test_register(suite, test_kv_list_map_put_not_hashed); 824 cx_test_register(suite, test_kv_list_map_put_not_hashed);
798 cx_test_register(suite, test_kv_list_map_remove); 825 cx_test_register(suite, test_kv_list_map_remove);
799 cx_test_register(suite, test_kv_list_map_remove_and_get); 826 cx_test_register(suite, test_kv_list_map_remove_and_get);
800 cx_test_register(suite, test_kv_list_set_key); 827 cx_test_register(suite, test_kv_list_set_key);
801 cx_test_register(suite, test_kv_list_set_key_already_exists); 828 cx_test_register(suite, test_kv_list_set_key_already_exists);
829 cx_test_register(suite, test_kv_list_set_key_again);
802 cx_test_register(suite, test_kv_list_remove_key); 830 cx_test_register(suite, test_kv_list_remove_key);
803 cx_test_register(suite, test_kv_list_insert_with_key); 831 cx_test_register(suite, test_kv_list_insert_with_key);
804 cx_test_register(suite, test_kv_list_insert_ptr_with_key); 832 cx_test_register(suite, test_kv_list_insert_ptr_with_key);
805 cx_test_register(suite, test_kv_list_insert_array_and_set_keys); 833 cx_test_register(suite, test_kv_list_insert_array_and_set_keys);
806 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); 834 cx_test_register(suite, test_kv_list_list_remove_destr_in_list);

mercurial