Ejemplo n.º 1
0
 @Test
 public void testNumLinkedListContains() {
   NumLinkedList list = new NumLinkedList();
   assertNotNull(
       "Method CONTAINS return true if the list contains value," + " false if it doesn’t.",
       list.contains(7.0));
 }
Ejemplo n.º 2
0
 @Test
 public void testNumLinkedListRemove() {
   NumLinkedList list = new NumLinkedList();
   list.add(7.0);
   list.remove(0);
   assertTrue("Method REMOVE remove the i-th element of the sequence.", true);
 }
Ejemplo n.º 3
0
 // Tests for NumLinkedList's fundamental functions
 @Test
 public void testNumLinkedListConstructorAndToString() {
   NumLinkedList list = new NumLinkedList();
   assertEquals(
       "With no parameters, your constructors should initialize an list size 0. "
           + "It also can be the problem in method TOSTRING.",
       "",
       list.toString());
 }
Ejemplo n.º 4
0
 @Test
 public void testNumLinkedListRemoveDuplicates() {
   NumLinkedList list = new NumLinkedList();
   list.removeDuplicates();
   assertTrue(
       "Method REMOVEDUPLICATES remove all duplicates except the first "
           + "element in the list to preseve the list order.",
       true);
 }
Ejemplo n.º 5
0
 @Test
 public void testNumLinkedListInsert() {
   NumLinkedList list = new NumLinkedList();
   list.insert(7, 7.0);
   assertTrue(
       "Method INSERT put a new element before the i-th element"
           + " of the sequence (using 0 for the index of the first element).",
       true);
 }
Ejemplo n.º 6
0
  @Test
  public void testNumLinkedListEquals() {
    NumLinkedList listA = new NumLinkedList();
    NumLinkedList listB = new NumLinkedList();
    NumLinkedList listC = new NumLinkedList();

    listA.add(1.0);
    listA.add(3.0);

    assertFalse(
        "EQUALS method should return FALSE, when two lists are not the same.", listA.equals(listB));

    listB.add(1.0);
    listB.add(3.0);

    assertTrue(
        "EQUALS method should return TRUE, when two lists are the same.", listA.equals(listB));

    listC.add(3.0);
    listC.add(1.0);

    assertFalse(
        "EQUALS method should return FALSE, even if the same "
            + "numbers are in different order in two lists.",
        listA.equals(listC));
  }
Ejemplo n.º 7
0
 @Test
 public void testNumLinkedListLookup() {
   NumLinkedList list = new NumLinkedList();
   list.add(7.0);
   try {
     assertNotNull(
         "Method LOOKUP return the i-th element of the sequence"
             + " (raise an exception if the sequence has fewer than i elements).",
         list.lookup(0));
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
 }
Ejemplo n.º 8
0
  @Test
  public void testNumLinkedListAddAndToString() {
    NumLinkedList list = new NumLinkedList();

    list.add(1.0);
    list.add(3.0);
    list.add(2.0);

    assertEquals(
        "Add method should add element to the end of list each time. "
            + "It's also can be the problem in method TOSTRING.",
        "1.0 3.0 2.0",
        list.toString());
  }
Ejemplo n.º 9
0
  @Test
  public void testNumLinkedListSize() {
    NumLinkedList list = new NumLinkedList();

    assertEquals(
        "Method SIZE should return 0, when list is constructed by default constructor.",
        0,
        list.size());

    list.add(1.0);
    list.add(2.0);
    list.add(3.0);

    assertEquals(
        "Method SIZE should return the size of the list, "
            + "i.e. the number of elements, in the sequence.",
        3,
        list.size());
  }