test/test_list.c

changeset 488
9138acaa494b
parent 487
4bd19279778c
child 489
af6be1e123aa
equal deleted inserted replaced
487:4bd19279778c 488:9138acaa494b
568 568
569 cxLinkedListDestroy(list); 569 cxLinkedListDestroy(list);
570 CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 570 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
571 } 571 }
572 572
573 void test_hl_linked_list_from_array(void) {
574 cxTestingAllocatorReset();
575
576 int data[] = {2, 4, 5, 7, 10, 15};
577
578 CxList expected = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
579 for (int i = 0; i < 5; i++) cxListAdd(expected, &data[i]);
580
581 CxList list = cxLinkedListFromArray(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int), 5, data);
582
583 CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
584 }
585
573 void test_hl_linked_list_add(void) { 586 void test_hl_linked_list_add(void) {
574 cxTestingAllocatorReset(); 587 cxTestingAllocatorReset();
575 588
576 int data; 589 int data;
577 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); 590 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
992 cu_add_test(suite, test_linked_list_reverse); 1005 cu_add_test(suite, test_linked_list_reverse);
993 1006
994 suite = CU_add_suite("high level linked list", NULL, NULL); 1007 suite = CU_add_suite("high level linked list", NULL, NULL);
995 1008
996 cu_add_test(suite, test_hl_linked_list_create); 1009 cu_add_test(suite, test_hl_linked_list_create);
1010 cu_add_test(suite, test_hl_linked_list_from_array);
997 cu_add_test(suite, test_hl_linked_list_add); 1011 cu_add_test(suite, test_hl_linked_list_add);
998 cu_add_test(suite, test_hl_linked_list_insert); 1012 cu_add_test(suite, test_hl_linked_list_insert);
999 cu_add_test(suite, test_hl_linked_list_remove); 1013 cu_add_test(suite, test_hl_linked_list_remove);
1000 cu_add_test(suite, test_hl_linked_list_at); 1014 cu_add_test(suite, test_hl_linked_list_at);
1001 cu_add_test(suite, test_hl_linked_list_find); 1015 cu_add_test(suite, test_hl_linked_list_find);

mercurial