1.1 --- a/test/test_list.c Sun Oct 03 16:02:53 2021 +0200 1.2 +++ b/test/test_list.c Sun Oct 03 16:30:47 2021 +0200 1.3 @@ -127,8 +127,27 @@ 1.4 CU_ASSERT_PTR_NULL(nodes[1].prev) 1.5 } 1.6 1.7 +void test_linked_list_last(void) { 1.8 + CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, -1)) 1.9 + CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, 0)) 1.10 1.11 -void test_linked_list_create(void) { 1.12 + struct node { 1.13 + int data; 1.14 + void *next; 1.15 + }; 1.16 + ptrdiff_t loc = offsetof(struct node, next); 1.17 + 1.18 + struct node third = {3, NULL}; 1.19 + struct node second = {2, &third}; 1.20 + struct node first = {1, &second}; 1.21 + 1.22 + CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&first, loc), &third) 1.23 + CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&second, loc), &third) 1.24 + CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&third, loc), &third) 1.25 +} 1.26 + 1.27 + 1.28 +void test_hl_linked_list_create(void) { 1.29 cxTestingAllocatorReset(); 1.30 1.31 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); 1.32 @@ -166,10 +185,17 @@ 1.33 1.34 cu_add_test(suite, test_linked_list_at); 1.35 cu_add_test(suite, test_linked_list_add); 1.36 + cu_add_test(suite, test_linked_list_last); 1.37 1.38 suite = CU_add_suite("high level linked list suite", NULL, NULL); 1.39 1.40 - cu_add_test(suite, test_linked_list_create); 1.41 + cu_add_test(suite, test_hl_linked_list_create); 1.42 + /* 1.43 + cu_add_test(suite, test_hl_linked_list_add); 1.44 + cu_add_test(suite, test_hl_linked_list_last); 1.45 + cu_add_test(suite, test_hl_linked_list_insert); 1.46 + cu_add_test(suite, test_hl_linked_list_remove); 1.47 + cu_add_test(suite, test_hl_linked_list_find);*/ 1.48 1.49 CU_basic_set_mode(UCX_CU_BRM); 1.50