Ejemplo n.º 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);
  }
Ejemplo n.º 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());
  }
Ejemplo n.º 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());
  }