@Test
  public void testFinal() {
    String values[] = {"A", "B", "C", "D", "E"};

    MyReversableLinkedList<String> list = new MyReversableLinkedList<>();

    constructList(list, values);

    list.clear();

    constructList(list, values);

    while (!list.isEmpty()) {
      list.remove(0);
    }

    constructList(list, values);

    list.reverse();

    String afterReverse[] = {"E", "D", "C", "B", "A"};

    for (int i = 0; i < list.getSize(); ++i) {
      assertEquals("test final", list.get(i), afterReverse[i]);
    }

    list.remove(0);
    list.remove(2);

    String afterRemove[] = {"D", "C", "A"};
    for (int i = 0; i < list.getSize(); ++i) {
      assertEquals("test final remove", list.get(i), afterRemove[i]);
    }

    int oldSize = list.getSize();
    for (int i = 0; i < oldSize; ++i) {
      list.add(list.get(i));
    }

    list.reverse();

    String finalResult[] = {"A", "C", "D", "A", "C", "D"};
    for (int i = 0; i < finalResult.length; ++i) {
      assertEquals("test final result", list.get(i), finalResult[i]);
    }
  }
 private void constructList(MyReversableLinkedList<String> list, String[] values) {
   for (String s : values) {
     list.add(s);
   }
 }