1.1 --- a/test/test_list.c Tue Dec 28 14:16:04 2021 +0100 1.2 +++ b/test/test_list.c Tue Dec 28 14:25:05 2021 +0100 1.3 @@ -125,6 +125,31 @@ 1.4 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&d, 3, loc_prev, 1), &b) 1.5 } 1.6 1.7 +void test_linked_list_find(void) { 1.8 + int data[] = {2, 4, 6, 8}; 1.9 + void *list = create_test_data(4, data); 1.10 + int s; 1.11 + 1.12 + s = 2; 1.13 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.14 + false, (CxListComparator) cmp_int, &s), 0) 1.15 + s = 4; 1.16 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.17 + false, (CxListComparator) cmp_int, &s), 1) 1.18 + s = 6; 1.19 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.20 + false, (CxListComparator) cmp_int, &s), 2) 1.21 + s = 8; 1.22 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.23 + false, (CxListComparator) cmp_int, &s), 3) 1.24 + s = 10; 1.25 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.26 + false, (CxListComparator) cmp_int, &s), 4) 1.27 + s = -2; 1.28 + CU_ASSERT_EQUAL(cx_linked_list_find(list, loc_next, loc_data, 1.29 + false, (CxListComparator) cmp_int, &s), 4) 1.30 +} 1.31 + 1.32 void test_linked_list_compare(void) { 1.33 int a[] = {2, 4, 6, 8}; 1.34 int b[] = {2, 4, 6}; 1.35 @@ -135,19 +160,19 @@ 1.36 void *lc = create_test_data(4, c); 1.37 1.38 CU_ASSERT_TRUE(0 < cx_linked_list_compare(la, lb, loc_next, loc_data, 1.39 - 0, (CxListComparator) cmp_int) 1.40 + false, (CxListComparator) cmp_int) 1.41 ) 1.42 CU_ASSERT_TRUE(0 > cx_linked_list_compare(lb, la, loc_next, loc_data, 1.43 - 0, (CxListComparator) cmp_int) 1.44 + false, (CxListComparator) cmp_int) 1.45 ) 1.46 CU_ASSERT_TRUE(0 < cx_linked_list_compare(lc, la, loc_next, loc_data, 1.47 - 0, (CxListComparator) cmp_int) 1.48 + false, (CxListComparator) cmp_int) 1.49 ) 1.50 CU_ASSERT_TRUE(0 > cx_linked_list_compare(la, lc, loc_next, loc_data, 1.51 - 0, (CxListComparator) cmp_int) 1.52 + false, (CxListComparator) cmp_int) 1.53 ) 1.54 CU_ASSERT_TRUE(0 == cx_linked_list_compare(la, la, loc_next, loc_data, 1.55 - 0, (CxListComparator) cmp_int) 1.56 + false, (CxListComparator) cmp_int) 1.57 ) 1.58 1.59 destroy_test_data(la); 1.60 @@ -487,7 +512,7 @@ 1.61 void *end = cx_linked_list_last(begin, loc_next); 1.62 1.63 cx_linked_list_sort(&begin, &end, loc_prev, loc_next, loc_data, 1.64 - 0, (CxListComparator) cmp_int); 1.65 + false, (CxListComparator) cmp_int); 1.66 1.67 struct node *check = begin; 1.68 struct node *check_last = NULL; 1.69 @@ -952,6 +977,7 @@ 1.70 1.71 cu_add_test(suite, test_linked_list_link_unlink); 1.72 cu_add_test(suite, test_linked_list_at); 1.73 + cu_add_test(suite, test_linked_list_find); 1.74 cu_add_test(suite, test_linked_list_compare); 1.75 cu_add_test(suite, test_linked_list_prepend); 1.76 cu_add_test(suite, test_linked_list_add);