import static org.junit.Assert.*;
import org.junit.Test;
public class DoubleLinkedListTest {
@Test
public void testCreateDoubleLinkedList() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
assertNotNull(list);
}
@Test
public void testInsertNode() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
list.insert(5);
assertEquals(1, list.size());
}
@Test
public void testDeleteNode() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
list.insert(5);
list.delete(5);
assertEquals(0, list.size());
}
@Test
public void testFindNode() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
list.insert(5);
assertEquals(0, list.find(5));
}
@Test
public void testModifyNode() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
list.insert(5);
list.modify(0, 10);
assertEquals(10, (int)list.get(0));
}
@Test
public void testTraverseDoubleLinkedList() {
DoubleLinkedList<Integer> list = new DoubleLinkedList<>();
list.insert(5);
list.insert(10);
list.insert(15);
StringBuilder sb = new StringBuilder();
list.traverse(node -> sb.append(node).append(" "));
assertEquals("5 10 15 ", sb.toString());
}
}