|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+import org.junit.Ignore;
|
|
|
2
|
+import org.junit.Test;
|
|
1
|
3
|
|
|
2
|
4
|
import java.util.NoSuchElementException;
|
|
3
|
|
-import static org.assertj.core.api.Assertions.assertThat;
|
|
4
|
|
-import org.junit.Test;
|
|
5
|
|
-import org.junit.Ignore;
|
|
|
5
|
+
|
|
|
6
|
+import static org.hamcrest.CoreMatchers.*;
|
|
|
7
|
+import static org.junit.Assert.*;
|
|
6
|
8
|
|
|
7
|
9
|
public class SimpleLinkedListTest {
|
|
8
|
10
|
|
|
|
@@ -10,7 +12,7 @@ public class SimpleLinkedListTest {
|
|
10
|
12
|
@Test
|
|
11
|
13
|
public void aNewListIsEmpty() {
|
|
12
|
14
|
SimpleLinkedList list = new SimpleLinkedList();
|
|
13
|
|
- assertThat(list.size()).isEqualTo(0);
|
|
|
15
|
+ assertThat(list.size(), is(0));
|
|
14
|
16
|
}
|
|
15
|
17
|
|
|
16
|
18
|
@Ignore
|
|
|
@@ -18,7 +20,7 @@ public class SimpleLinkedListTest {
|
|
18
|
20
|
public void canCreateFromArray() {
|
|
19
|
21
|
Integer[] values = new Integer[]{1, 2, 3};
|
|
20
|
22
|
SimpleLinkedList list = new SimpleLinkedList(values);
|
|
21
|
|
- assertThat(list.size()).isEqualTo(3);
|
|
|
23
|
+ assertThat(list.size(), is(3));
|
|
22
|
24
|
}
|
|
23
|
25
|
|
|
24
|
26
|
@Ignore
|
|
|
@@ -34,10 +36,10 @@ public class SimpleLinkedListTest {
|
|
34
|
36
|
SimpleLinkedList list = new SimpleLinkedList();
|
|
35
|
37
|
list.push(9);
|
|
36
|
38
|
list.push(8);
|
|
37
|
|
- assertThat(list.size()).isEqualTo(2);
|
|
38
|
|
- assertThat(list.pop()).isEqualTo(8);
|
|
39
|
|
- assertThat(list.pop()).isEqualTo(9);
|
|
40
|
|
- assertThat(list.size()).isEqualTo(0);
|
|
|
39
|
+ assertThat(list.size(), is(2));
|
|
|
40
|
+ assertThat(list.pop(), is(8));
|
|
|
41
|
+ assertThat(list.pop(), is(9));
|
|
|
42
|
+ assertThat(list.size(), is(0));
|
|
41
|
43
|
}
|
|
42
|
44
|
|
|
43
|
45
|
@Ignore
|
|
|
@@ -50,11 +52,11 @@ public class SimpleLinkedListTest {
|
|
50
|
52
|
list.push(6);
|
|
51
|
53
|
list.push(5);
|
|
52
|
54
|
list.reverse();
|
|
53
|
|
- assertThat(list.pop()).isEqualTo(9);
|
|
54
|
|
- assertThat(list.pop()).isEqualTo(8);
|
|
55
|
|
- assertThat(list.pop()).isEqualTo(7);
|
|
56
|
|
- assertThat(list.pop()).isEqualTo(6);
|
|
57
|
|
- assertThat(list.pop()).isEqualTo(5);
|
|
|
55
|
+ assertThat(list.pop(), is(9));
|
|
|
56
|
+ assertThat(list.pop(), is(8));
|
|
|
57
|
+ assertThat(list.pop(), is(7));
|
|
|
58
|
+ assertThat(list.pop(), is(6));
|
|
|
59
|
+ assertThat(list.pop(), is(5));
|
|
58
|
60
|
}
|
|
59
|
61
|
|
|
60
|
62
|
@Ignore
|
|
|
@@ -67,7 +69,7 @@ public class SimpleLinkedListTest {
|
|
67
|
69
|
list.push(6);
|
|
68
|
70
|
list.push(5);
|
|
69
|
71
|
Integer[] expected = {5, 6, 7, 8, 9};
|
|
70
|
|
- assertThat(list.asArray(Integer.class)).containsExactly(expected);
|
|
|
72
|
+ assertEquals(list.asArray(Integer.class), expected);
|
|
71
|
73
|
}
|
|
72
|
74
|
|
|
73
|
75
|
@Ignore
|
|
|
@@ -75,7 +77,7 @@ public class SimpleLinkedListTest {
|
|
75
|
77
|
public void canReturnEmptyListAsEmptyArray() {
|
|
76
|
78
|
SimpleLinkedList list = new SimpleLinkedList();
|
|
77
|
79
|
Object[] expected = {};
|
|
78
|
|
- assertThat(list.asArray(Object.class)).containsExactly(expected);
|
|
|
80
|
+ assertEquals(list.asArray(Object.class), expected);
|
|
79
|
81
|
}
|
|
80
|
82
|
|
|
81
|
83
|
}
|