Skip to content

Instantly share code, notes, and snippets.

@mchayapol
Created October 14, 2015 02:22
Show Gist options
  • Select an option

  • Save mchayapol/cc0f56895bc371dd0430 to your computer and use it in GitHub Desktop.

Select an option

Save mchayapol/cc0f56895bc371dd0430 to your computer and use it in GitHub Desktop.
Test cases for Doubly Linked List
package edu.au.scitech.sc2101;
import static org.junit.Assert.*;
import org.junit.Test;
public class DoublyLinkedListTest {
@Test
public void test01() {
DoublyLinkedList list = new DoublyLinkedList();
list.add(10); list.add(5); list.add(7);
list.add(1); list.add(8);
// expect [10 5 7 1 8]
String s = list.toString();
assertEquals("[10 5 7 1 8]",s);
System.out.println(s);
assertEquals(5, list.size());
}
@Test
public void test02() {
DoublyLinkedList list = new DoublyLinkedList();
list.add(10); list.add(5); list.add(7);
list.add(1); list.add(8);
list.delete(0);
assertEquals(4, list.size());
String s = list.toString();
assertEquals("[5 7 1 8]",s);
System.out.println(s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment