import junit.framework.TestCase; /** The test class for the ComparableList composte classes. */ public class ComparableListTest extends TestCase { static ComparableList E = EmptyComparableList.ONLY; static ComparableList l1 = E.cons(17); // '(17) static ComparableList l2 = l1.cons(5); // '(5 17) static ComparableList l3 = E.cons(5); // '(5) static ComparableList l4 = l3.cons(5); // '(5 5) static ComparableList l5 = l3.cons(17); // '(17 5) static ComparableList l6 = l5.cons(-5).cons(100).cons(50); // '(50 100 -5 17 5) static ComparableList l7 = E.cons(100).cons(50).cons(17).cons(5).cons(-5); // '(-5 5 17 50 100) /** Tests the insert method. */ void testInsert() { assertEquals("empty insert test", l1, E.insert(17)); assertEquals("pre insert test", l2, l1.insert(5)); assertEquals("post insert test", l2, l3.insert(17)); assertEquals("equals insert test", l4, l3.insert(5)); } void testSort() { assertEquals("empty sort test", E, E.sort()); assertEquals("one elt test", l1, l1.sort()); assertEquals("two elts in order test", l2, l2.sort()); assertEquals("two elts out of order test", l2, l5.sort()); assertEquals("two equal elts test", l4, l4.sort()); } }