test/test_list.c

changeset 456
227c2eabbef8
parent 455
8168e16cd1e9
child 459
c0e2e9f83399
--- a/test/test_list.c	Sun Oct 03 16:02:53 2021 +0200
+++ b/test/test_list.c	Sun Oct 03 16:30:47 2021 +0200
@@ -127,8 +127,27 @@
     CU_ASSERT_PTR_NULL(nodes[1].prev)
 }
 
+void test_linked_list_last(void) {
+    CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, -1))
+    CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, 0))
 
-void test_linked_list_create(void) {
+    struct node {
+        int data;
+        void *next;
+    };
+    ptrdiff_t loc = offsetof(struct node, next);
+
+    struct node third = {3, NULL};
+    struct node second = {2, &third};
+    struct node first = {1, &second};
+
+    CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&first, loc), &third)
+    CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&second, loc), &third)
+    CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&third, loc), &third)
+}
+
+
+void test_hl_linked_list_create(void) {
     cxTestingAllocatorReset();
 
     CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
@@ -166,10 +185,17 @@
 
     cu_add_test(suite, test_linked_list_at);
     cu_add_test(suite, test_linked_list_add);
+    cu_add_test(suite, test_linked_list_last);
 
     suite = CU_add_suite("high level linked list suite", NULL, NULL);
 
-    cu_add_test(suite, test_linked_list_create);
+    cu_add_test(suite, test_hl_linked_list_create);
+    /*
+    cu_add_test(suite, test_hl_linked_list_add);
+    cu_add_test(suite, test_hl_linked_list_last);
+    cu_add_test(suite, test_hl_linked_list_insert);
+    cu_add_test(suite, test_hl_linked_list_remove);
+    cu_add_test(suite, test_hl_linked_list_find);*/
 
     CU_basic_set_mode(UCX_CU_BRM);
 

mercurial