Ver código fonte

Merge pull request #219 from FridaTveit/SimpleLinkedListReplaceAssertjWithJunit

Issue #202: Replaced assertj assertions in simple-linked-list with jun…

(fixes #202)
John Ryan 9 anos atrás
pai
commit
edad18036b

+ 0
- 1
exercises/simple-linked-list/build.gradle Ver arquivo

8
 
8
 
9
 dependencies {
9
 dependencies {
10
   testCompile "junit:junit:4.12"
10
   testCompile "junit:junit:4.12"
11
-  testCompile "org.assertj:assertj-core:3.2.0"
12
 }
11
 }
13
 test {
12
 test {
14
   testLogging {
13
   testLogging {

+ 18
- 16
exercises/simple-linked-list/src/test/java/SimpleLinkedListTest.java Ver arquivo

1
+import org.junit.Ignore;
2
+import org.junit.Test;
1
 
3
 
2
 import java.util.NoSuchElementException;
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
 public class SimpleLinkedListTest {
9
 public class SimpleLinkedListTest {
8
 
10
 
10
     @Test
12
     @Test
11
     public void aNewListIsEmpty() {
13
     public void aNewListIsEmpty() {
12
         SimpleLinkedList list = new SimpleLinkedList();
14
         SimpleLinkedList list = new SimpleLinkedList();
13
-        assertThat(list.size()).isEqualTo(0);
15
+        assertThat(list.size(), is(0));
14
     }
16
     }
15
 
17
 
16
     @Ignore
18
     @Ignore
18
     public void canCreateFromArray() {
20
     public void canCreateFromArray() {
19
         Integer[] values = new Integer[]{1, 2, 3};
21
         Integer[] values = new Integer[]{1, 2, 3};
20
         SimpleLinkedList list = new SimpleLinkedList(values);
22
         SimpleLinkedList list = new SimpleLinkedList(values);
21
-        assertThat(list.size()).isEqualTo(3);
23
+        assertThat(list.size(), is(3));
22
     }
24
     }
23
 
25
 
24
     @Ignore
26
     @Ignore
34
         SimpleLinkedList list = new SimpleLinkedList();
36
         SimpleLinkedList list = new SimpleLinkedList();
35
         list.push(9);
37
         list.push(9);
36
         list.push(8);
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
     @Ignore
45
     @Ignore
50
         list.push(6);
52
         list.push(6);
51
         list.push(5);
53
         list.push(5);
52
         list.reverse();
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
     @Ignore
62
     @Ignore
67
         list.push(6);
69
         list.push(6);
68
         list.push(5);
70
         list.push(5);
69
         Integer[] expected = {5, 6, 7, 8, 9};
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
     @Ignore
75
     @Ignore
75
     public void canReturnEmptyListAsEmptyArray() {
77
     public void canReturnEmptyListAsEmptyArray() {
76
         SimpleLinkedList list = new SimpleLinkedList();
78
         SimpleLinkedList list = new SimpleLinkedList();
77
         Object[] expected = {};
79
         Object[] expected = {};
78
-        assertThat(list.asArray(Object.class)).containsExactly(expected);
80
+        assertEquals(list.asArray(Object.class), expected);
79
     }
81
     }
80
 
82
 
81
 }
83
 }