コード例 #1
0
 @Test
 public void testToString() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(1);
   dll.pushBack(2);
   System.out.println(dll.toString());
 }
コード例 #2
0
  @Test
  public void testPushFront() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushFront(5);
    assertEquals(1, dll.elements());
  }
コード例 #3
0
 @Test
 public void testClone() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(6);
   dll.pushBack(5);
   DoubleLinkedList dll2 = dll.clone();
   assertEquals(true, dll.equals(dll2));
 }
コード例 #4
0
 @Test
 public void testSearchFalse() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(6);
   dll.pushBack(5);
   dll.pushFront(3);
   dll.pushFront(2);
   assertEquals(false, dll.search(4));
 }
コード例 #5
0
  @Test
  public void testPopBackCount() throws InvalidAccessException, ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(6);
    dll.pushBack(5);
    assertEquals(5, dll.popBack());
    assertEquals(1, dll.elements());
  }
コード例 #6
0
 @Test
 public void testSearchTrue() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(6);
   dll.pushBack(5);
   dll.pushFront(new Integer(3));
   dll.pushFront(2);
   assertEquals(true, dll.search(new Integer(3)));
 }
コード例 #7
0
  @Test
  public void testPopFrontCaunt() throws InvalidAccessException, ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushFront(5);
    dll.pushFront(6);
    dll.pushFront(7);
    assertEquals(7, dll.popFront());
    assertEquals(2, dll.elements());
  }
コード例 #8
0
 // Exception expected
 @Test
 public void testPopFrontEmpty() throws InvalidAccessException {
   DoubleLinkedList dll = new DoubleLinkedList();
   try {
     dll.popFront();
   } catch (InvalidAccessException ex) {
     return;
   }
   fail("ExceptionExpected");
 }
コード例 #9
0
  @Test
  public void testElements() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(6);
    dll.pushBack(5);
    dll.pushFront(1);
    dll.pushFront(2);
    assertEquals(4, dll.elements());
  }
コード例 #10
0
  @Test
  public void testEqualsFalse() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(6);
    dll.pushBack(5);
    DoubleLinkedList dll2 = new DoubleLinkedList();
    dll2.pushFront(6);
    dll2.pushFront(5);
    assertEquals(false, dll.equals(dll2));
  }
コード例 #11
0
  // no exception expected
  @Test
  public void testPeekBack() throws InvalidAccessException, ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(6);
    dll.pushBack(5);
    try {
      assertEquals(5, dll.popBack());
    } catch (InvalidAccessException ex) {
      fail(ex.getMessage());
    }
  }
コード例 #12
0
  // null exception expected
  @Test
  public void testPushFrontNullPointerException() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    try {
      dll.pushFront((Comparable) null);
      dll.pushFront("String");
    } catch (NullPointerException ex) {
      return;
    }
    fail("Exception expected!");
  }
コード例 #13
0
  // No Exception
  @Test
  public void testPushFrontNoException() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    try {
      dll.pushFront(5);
      dll.pushFront(6);
      assertEquals(2, dll.elements());
    } catch (ValueException ex) {
      fail("No Exception expected!");
    }
  }
コード例 #14
0
  // exception expected
  @Test
  public void testPushFrontException() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    try {
      dll.pushFront(5);
      dll.pushFront("String");
    } catch (ValueException ex) {
      return;
    }
    fail("Exception expected!");
  }
コード例 #15
0
 // no Exception expected
 @Test
 public void testSearchNoException() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(6);
   dll.pushBack(5);
   dll.pushFront(3);
   dll.pushFront(2);
   try {
     assertEquals(false, dll.search(4));
   } catch (NullPointerException ex) {
     fail("No Exception expected!");
   }
 }
コード例 #16
0
 // no Exception
 @Test
 public void testDoubleLinkedList() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushFront(1);
   dll.pushFront(2);
   dll.pushFront(3);
   DoubleLinkedList dll2;
   try {
     dll2 = new DoubleLinkedList(dll);
     assertEquals(3, dll2.elements());
   } catch (NullPointerException ex) {
     fail("No Exception expected");
   }
 }
コード例 #17
0
 // Exception expected
 @Test
 public void testSearchException() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(6);
   dll.pushBack(5);
   dll.pushFront(3);
   dll.pushFront(2);
   try {
     assertEquals(false, dll.search("String"));
   } catch (ValueException ex) {
     return;
   }
   fail("Exception expected!");
 }
コード例 #18
0
  // Exception expected
  @Test
  public void testEqualsException() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(6);
    dll.pushBack(5);
    DoubleLinkedList dll2 = new DoubleLinkedList();
    dll2.pushFront(6);
    dll2.pushFront(5);
    try {
      assertEquals(false, dll.equals(null));
    } catch (NullPointerException ex) {
      return;
    }
    fail("Exception expected!");
  }
コード例 #19
0
 @Test
 public void testMultipleReverse() throws InvalidAccessException, ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushBack(1);
   dll.pushBack(2);
   dll.pushBack(3);
   dll.pushBack(4);
   dll.reverse();
   assertEquals(1, dll.popBack());
   assertEquals(2, dll.popBack());
   dll.reverse();
   assertEquals(4, dll.popBack());
   assertEquals(3, dll.popBack());
 }
コード例 #20
0
 // null exception expected
 @Test
 public void testPushFrontDoubleLinkedListNullPointerException() throws ValueException {
   DoubleLinkedList dll = new DoubleLinkedList();
   dll.pushFront(5);
   dll.pushFront(6);
   DoubleLinkedList dll2 = new DoubleLinkedList();
   dll2.pushFront("String");
   dll2.pushFront("ssdf");
   dll2.pushFront("sdf");
   try {
     dll.pushFront((DoubleLinkedList) null);
   } catch (NullPointerException ex) {
     return;
   }
   fail("Exceptione expected!");
 }
コード例 #21
0
  // no exception expected
  @Test
  public void testPushBackDoubleLinkedList() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(5);
    dll.pushBack(6);
    DoubleLinkedList dll2 = new DoubleLinkedList();
    dll2.pushBack(1);
    dll2.pushBack(2);
    dll2.pushBack(3);
    try {
      dll.pushBack(dll2);
      assertEquals(5, dll.elements());
    } catch (ValueException ex) {
      fail("No Exception expected!");
    }
  }
コード例 #22
0
  // Null Exception expected
  @Test
  public void testPushBackDoubleLinkedListNullPointerException() throws ValueException {

    DoubleLinkedList dll = new DoubleLinkedList();
    dll.pushBack(5);
    dll.pushBack(6);
    DoubleLinkedList dll2 = new DoubleLinkedList();
    dll2.pushBack("dssdf");
    dll2.pushBack("sdfsd");
    dll2.pushBack("sdf");
    try {
      dll.pushBack((DoubleLinkedList) null);
    } catch (NullPointerException ex) {
      return;
    }
    fail("Exception expected!");
  }
コード例 #23
0
 @Test
 public void testDoubleLinkedListEmpty() {
   DoubleLinkedList dll = new DoubleLinkedList();
   assertEquals(0, dll.elements());
 }
コード例 #24
0
 @Test
 public void testEmptyToString() {
   DoubleLinkedList dll = new DoubleLinkedList();
   assertEquals("No Nodes in that list!", dll.toString());
 }