Advertisement
vmeansdev

AddInTailTest

Sep 11th, 2019
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1.     private static void testLinkedListAddInTailWorksProperly() {
  2.         LinkedList list = new LinkedList();
  3.         Node node = new Node(0);
  4.         list.addInTail(node);
  5.         test(
  6.                 list.count() == 1,
  7.                 "List should have at least one element after adding one node to it"
  8.         );
  9.         test(
  10.                 list.head == node,
  11.                 "List head should be equal to node"
  12.         );
  13.         test(
  14.                 list.tail == node,
  15.                 "List tail should be equal to node"
  16.         );
  17.  
  18.         Node node1 = new Node(1);
  19.         list.addInTail(node1);
  20.         test(
  21.                 list.count() == 2,
  22.                 "List should have two elements after adding two nodes to it"
  23.         );
  24.         test(
  25.                 list.head == node,
  26.                 "List head still should be equal to node"
  27.         );
  28.         test(
  29.                 list.tail == node1,
  30.                 "List tail should become node1"
  31.         );
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement