示例#1
0
  @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);
  }
示例#2
0
  @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());
  }
示例#3
0
  @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());
  }