forked from ucsd-cse15l-f23/lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkedListTests.java
50 lines (48 loc) · 1.27 KB
/
LinkedListTests.java
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
import static org.junit.Assert.*;
import org.junit.Test;
public class LinkedListTests {
LinkedList myList = new LinkedList();
@Test
public void testAppend() {
myList.append(2);
assertEquals(2, myList.root.value);
myList.append(3);
assertEquals(3, myList.root.next.value);
myList.append(4);
assertEquals(4, myList.root.next.next.value);
myList.append(5);
assertEquals(5, myList.root.next.next.next.value);
}
@Test
public void testPrepend() {
myList.prepend(2);
assertEquals(2, myList.root.value);
myList.prepend(3);
assertEquals(3, myList.root.value);
assertEquals(2, myList.root.next.value);
}
@Test
public void testFirst() {
myList.append(2);
myList.prepend(3);
assertEquals(3, myList.first());
}
@Test
public void testLast() {
myList.append(2);
myList.prepend(3);
assertEquals(2, myList.last());
}
@Test
public void testToString() {
myList.append(2);
myList.prepend(3);
assertEquals("3 2 ", myList.toString());
}
@Test
public void testLength() {
myList.append(2);
myList.prepend(3);
assertEquals(2, myList.length());
}
}