@Test public void testEqualsTrue() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); DoubleLinkedList dll2 = new DoubleLinkedList(); dll2.pushBack(6); dll2.pushBack(5); assertEquals(true, dll.equals(dll2)); }
// null exception expected @Test public void testPushBackNullPointerException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); try { dll.pushBack((Comparable) null); dll.pushBack("String"); } catch (NullPointerException ex) { return; } fail("Exception expected!"); }
// exception expected @Test public void testPushBackException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); try { dll.pushBack(5); dll.pushBack("String"); } catch (ValueException ex) { return; } fail("Exception expected!"); }
@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 testToString() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(1); dll.pushBack(2); System.out.println(dll.toString()); }
@Test public void testPushBack() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(5); assertEquals(1, dll.elements()); }
// Null Exception expected @Test public void testPushBackDoubleLinkedListNullPointerException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(5); dll.pushBack(6); DoubleLinkedList dll2 = new DoubleLinkedList(); dll2.pushBack("dssdf"); dll2.pushBack("sdfsd"); dll2.pushBack("sdf"); try { dll.pushBack((DoubleLinkedList) null); } catch (NullPointerException ex) { return; } fail("Exception expected!"); }
// no exception expected @Test public void testPushBackDoubleLinkedList() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(5); dll.pushBack(6); DoubleLinkedList dll2 = new DoubleLinkedList(); dll2.pushBack(1); dll2.pushBack(2); dll2.pushBack(3); try { dll.pushBack(dll2); assertEquals(5, dll.elements()); } catch (ValueException ex) { fail("No Exception expected!"); } }
@Test public void testSearchFalse() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); dll.pushFront(3); dll.pushFront(2); assertEquals(false, dll.search(4)); }
@Test public void testSearchTrue() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); dll.pushFront(new Integer(3)); dll.pushFront(2); assertEquals(true, dll.search(new Integer(3))); }
@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()); }
@Test public void testElements() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); dll.pushFront(1); dll.pushFront(2); assertEquals(4, dll.elements()); }
// 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()); } }
// no Exception expected @Test public void testSearchNoException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); dll.pushFront(3); dll.pushFront(2); try { assertEquals(false, dll.search(4)); } catch (NullPointerException ex) { fail("No Exception expected!"); } }
// Exception expected @Test public void testSearchException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); dll.pushFront(3); dll.pushFront(2); try { assertEquals(false, dll.search("String")); } catch (ValueException ex) { return; } fail("Exception expected!"); }
// Exception expected @Test public void testEqualsException() throws ValueException { DoubleLinkedList dll = new DoubleLinkedList(); dll.pushBack(6); dll.pushBack(5); DoubleLinkedList dll2 = new DoubleLinkedList(); dll2.pushFront(6); dll2.pushFront(5); try { assertEquals(false, dll.equals(null)); } catch (NullPointerException ex) { return; } fail("Exception expected!"); }