test/test_list.c

changeset 495
2856c74e18ba
parent 494
6ce8cfa10a96
child 496
1a07e24801a9
--- a/test/test_list.c	Sat Jan 22 17:15:14 2022 +0100
+++ b/test/test_list.c	Sat Jan 22 18:49:06 2022 +0100
@@ -762,12 +762,19 @@
 void test_hl_linked_list_iterator_impl(CxList list) {
     int i = 0;
     for (CxIterator iter = cxListBegin(list); cxIteratorValid(&iter); cxIteratorNext(&iter)) {
-        CU_ASSERT_EQUAL(iter.index, (size_t) i)
+        CU_ASSERT_EQUAL(iter.index, (size_t) (i + 1) / 2)
         int *x = cxIteratorCurrent(&iter);
         CU_ASSERT_EQUAL(*x, i)
+        if (i % 2 == 1) iter.remove = true;
         i++;
     }
     CU_ASSERT_EQUAL(i, 10)
+    CU_ASSERT_EQUAL_FATAL(list->size, 5)
+    CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 0)
+    CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 2)
+    CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 4)
+    CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 6)
+    CU_ASSERT_EQUAL(*(int *) cxListAt(list, 4), 8)
     cxLinkedListDestroy(list);
     CU_ASSERT_TRUE(cxTestingAllocatorVerify())
 }

mercurial