Esempio n. 1
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());
  }
Esempio n. 2
0
  @Test
  public void testAppendToTail() throws Exception {
    DoubleNode<String> node = new DoubleNode<>("First");
    node.appendToTail("Second");

    assertEquals("First", node.getData());
    assertEquals("Second", node.getNext().getData());
    assertEquals("First", node.getNext().getPrevious().getData());
  }
Esempio n. 3
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());
  }
Esempio n. 4
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);
  }