-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDoublyLinkedListTest.java
More file actions
90 lines (62 loc) · 2.25 KB
/
DoublyLinkedListTest.java
File metadata and controls
90 lines (62 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package dataStructures.doublyLinkedList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class DoublyLinkedListTest {
@Test
@DisplayName("add value to the end of the list")
public void testAppend() {
DoublyLinkedList actualList = new DoublyLinkedList();
actualList.append(4);
actualList.append(0);
actualList.append(9);
String actual = actualList.printHead();
String expected = "[null<-(4)->0] <-> [4<-(0)->9] <-> [0<-(9)->null]";
assertEquals(expected , actual, "append(data) should work");
System.out.println("Test - Doubly Linked List : append(data) - passed ok");
}
@Test
@DisplayName("add value to the start of the list")
public void testPreppend() {
DoublyLinkedList actualList = new DoublyLinkedList();
actualList.preppend(1);
actualList.preppend(3);
actualList.preppend(7);
String actual = actualList.printHead();
String expected = "[null<-(7)->3] <-> [7<-(3)->1] <-> [3<-(1)->null]";
assertEquals(expected , actual, "preppend(data) should work");
System.out.println("Test - Doubly Linked List : preppend(data) - passed ok");
}
@Test
@DisplayName("remove element from the head of the list")
public void testDeleteFirst() throws Exception {
DoublyLinkedList actualList = new DoublyLinkedList();
actualList.preppend(1);
actualList.preppend(3);
actualList.preppend(7);
actualList.deleteFirst();
String actual = actualList.printHead();
String expected = "[null<-(3)->1] <-> [3<-(1)->null]";
assertEquals(expected , actual, "deleteFirst() should work");
System.out.println("Test - Doubly Linked List : deleteFirst() - passed ok");
}
@Test
@DisplayName("remove element from the end of the list")
public void testDeleteLast() throws Exception {
DoublyLinkedList actualList = new DoublyLinkedList();
actualList.preppend(1);
actualList.preppend(3);
actualList.preppend(7);
actualList.deleteLast();
String actual = actualList.printHead();
String expected = "[null<-(7)->3] <-> [7<-(3)->null]";
assertEquals(expected , actual, "deleteLast() should work");
System.out.println("Test - Doubly Linked List : deleteLast() - passed ok");
}
@Test
void testIsEmpty() {
}
@Test
void testLength() {
}
}