// Launch unit test. EUnitTestResult test() { CALL CArray<Tsint> array; CListDC<Tsint> circle; CListDL<Tsint> list; // Fill the array. UT_ASSERT(array.insertLast(1)); UT_ASSERT(array.insertLast(2)); UT_ASSERT(array.insertLast(3)); UT_ASSERT(array.insertLast(4)); UT_ASSERT(array.insertLast(5)); UT_ASSERT(array.insertLast(6)); // Fill the double circled list. UT_ASSERT(circle.insertCurrentForward(1)); UT_ASSERT(circle.insertNext(6)); UT_ASSERT(circle.insertNext(5)); UT_ASSERT(circle.insertNext(4)); UT_ASSERT(circle.insertNext(3)); UT_ASSERT(circle.insertNext(2)); // Fill the double linked list. UT_ASSERT(list.insertLast(1)); UT_ASSERT(list.insertLast(2)); UT_ASSERT(list.insertLast(3)); UT_ASSERT(list.insertLast(4)); UT_ASSERT(list.insertLast(5)); UT_ASSERT(list.insertLast(6)); // Check counts. UT_ASSERT_EQUAL(count(array), 6); UT_ASSERT_EQUAL(countPrev(array.getItLast()), 6); UT_ASSERT_EQUAL(countNext(boundItForward(array.getItIndex(1), array.getItIndex(4))), 4); UT_ASSERT_EQUAL(countPrev(boundItBackward(array.getItIndex(3), array.getItIndex(2))), 2); UT_ASSERT_EQUAL(count(circle), 6); UT_ASSERT_EQUAL(countPrev(circle.getItCurrent().getBackward()), 6); UT_ASSERT_EQUAL(count(list), 6); UT_ASSERT_EQUAL(countPrev(list.getItLast()), 6); // Check conditional counts. UT_ASSERT_EQUAL(countIf(array, isOdd), 3); UT_ASSERT_EQUAL(countIfPrev(array.getItLast(), isOdd), 3); UT_ASSERT_EQUAL(countIfNext(boundItForward(array.getItIndex(1), array.getItIndex(4)), isOdd), 2); UT_ASSERT_EQUAL(countIfPrev(boundItBackward(array.getItIndex(3), array.getItIndex(2)), isOdd), 1); UT_ASSERT_EQUAL(countIf(circle, isOdd), 3); UT_ASSERT_EQUAL(countIfPrev(circle.getItCurrent().getBackward(), isOdd), 3); UT_ASSERT_EQUAL(countIf(list, isOdd), 3); UT_ASSERT_EQUAL(countIfPrev(list.getItLast(), isOdd), 3); UT_ACCEPT; }