public void testAddElements(int size) { List<Integer> src = makeRandomNumberList(size); SinglyLinkedList l = new SinglyLinkedList(); copy(src, l); ListIterator it = src.listIterator(src.size()); while (it.hasPrevious()) assertEquals(it.previous(), l.pop_back()); }
private static void copy(List<Integer> from, SinglyLinkedList to) { for (Integer n : from) to.push_back(n); }