@Test public void testReverse() throws InvalidAccessException, ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(1); dll.pushBack(2); dll.pushBack(3); dll.pushBack(4); dll.reverse(); assertEquals(1, dll.popBack()); assertEquals(2, dll.popBack()); assertEquals(3, dll.popBack()); assertEquals(4, dll.popBack()); }
@Test public void testPopBackCount() throws InvalidAccessException, ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); assertEquals(5, dll.popBack()); assertEquals(1, dll.elements()); }
// exception expected @Test public void testPopBackEmpty() throws InvalidAccessException, ValueException { DoubleLinkedList dll = new DoubleLinkedList(); try { dll.popBack(); } catch (InvalidAccessException ex) { return; } fail("ExceptionExpected"); }
// no exception expected @Test public void testPeekBack() throws InvalidAccessException, ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); try { assertEquals(5, dll.popBack()); } catch (InvalidAccessException ex) { fail(ex.getMessage()); } }