test/test_list.c

changeset 495
2856c74e18ba
parent 494
6ce8cfa10a96
child 496
1a07e24801a9
equal deleted inserted replaced
494:6ce8cfa10a96 495:2856c74e18ba
760 } 760 }
761 761
762 void test_hl_linked_list_iterator_impl(CxList list) { 762 void test_hl_linked_list_iterator_impl(CxList list) {
763 int i = 0; 763 int i = 0;
764 for (CxIterator iter = cxListBegin(list); cxIteratorValid(&iter); cxIteratorNext(&iter)) { 764 for (CxIterator iter = cxListBegin(list); cxIteratorValid(&iter); cxIteratorNext(&iter)) {
765 CU_ASSERT_EQUAL(iter.index, (size_t) i) 765 CU_ASSERT_EQUAL(iter.index, (size_t) (i + 1) / 2)
766 int *x = cxIteratorCurrent(&iter); 766 int *x = cxIteratorCurrent(&iter);
767 CU_ASSERT_EQUAL(*x, i) 767 CU_ASSERT_EQUAL(*x, i)
768 if (i % 2 == 1) iter.remove = true;
768 i++; 769 i++;
769 } 770 }
770 CU_ASSERT_EQUAL(i, 10) 771 CU_ASSERT_EQUAL(i, 10)
772 CU_ASSERT_EQUAL_FATAL(list->size, 5)
773 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 0)
774 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 2)
775 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 4)
776 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 6)
777 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 4), 8)
771 cxLinkedListDestroy(list); 778 cxLinkedListDestroy(list);
772 CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 779 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
773 } 780 }
774 781
775 void test_hl_linked_list_iterator(void) { 782 void test_hl_linked_list_iterator(void) {

mercurial