@Test public void testDeleteAllDoubleNodes() throws Exception { DoubleNode<String> node = new DoubleNode<>("First"); node.appendToTail("Second"); DoubleNode<String> nodeWithOneElement = node.deleteNode("First"); DoubleNode<String> nodeWithoutElements = nodeWithOneElement.deleteNode("Second"); assertTrue(nodeWithoutElements == null); }
@Test public void testDeletingNonExistingItem() throws Exception { DoubleNode<String> node = new DoubleNode<>("First"); node.appendToTail("Second"); DoubleNode<String> newDoubleNode = node.deleteNode("Non-existing-item"); assertEquals("First", newDoubleNode.getData()); assertEquals("Second", newDoubleNode.getNext().getData()); }
@Test public void testDeleteDoubleNode() throws Exception { DoubleNode<String> node = new DoubleNode<>("First"); node.appendToTail("Second"); node.appendToTail("Third"); DoubleNode<String> newDoubleNode = node.deleteNode("Second"); assertEquals("First", newDoubleNode.getData()); assertEquals("Third", newDoubleNode.getNext().getData()); }