1
1
import org .junit .jupiter .api .Disabled ;
2
+ import org .junit .jupiter .api .DisplayName ;
2
3
import org .junit .jupiter .api .Test ;
3
4
4
5
import java .util .List ;
8
9
public class ListOpsTest {
9
10
10
11
@ Test
12
+ @ DisplayName ("empty lists" )
11
13
public void testAppendingEmptyLists () {
12
14
assertThat (ListOps .append (List .of (), List .of ())).isEmpty ();
13
15
}
14
16
15
17
@ Disabled ("Remove to run test" )
16
18
@ Test
19
+ @ DisplayName ("list to empty list" )
17
20
public void testAppendingListToEmptyList () {
18
21
assertThat (ListOps .append (List .of (), List .of ('1' , '2' , '3' , '4' )))
19
22
.containsExactly ('1' , '2' , '3' , '4' );
20
23
}
21
24
22
25
@ Disabled ("Remove to run test" )
23
26
@ Test
27
+ @ DisplayName ("empty list to list" )
24
28
public void testAppendingEmptyListToList () {
25
29
assertThat (ListOps .append (List .of ('1' , '2' , '3' , '4' ), List .of ()))
26
30
.containsExactly ('1' , '2' , '3' , '4' );
27
31
}
28
32
29
33
@ Disabled ("Remove to run test" )
30
34
@ Test
35
+ @ DisplayName ("non-empty lists" )
31
36
public void testAppendingNonEmptyLists () {
32
37
assertThat (ListOps .append (List .of ("1" , "2" ), List .of ("2" , "3" , "4" , "5" )))
33
38
.containsExactly ("1" , "2" , "2" , "3" , "4" , "5" );
34
39
}
35
40
36
41
@ Disabled ("Remove to run test" )
37
42
@ Test
43
+ @ DisplayName ("empty list" )
38
44
public void testConcatEmptyList () {
39
45
assertThat (ListOps .concat (List .of ())).isEmpty ();
40
46
}
41
47
42
48
@ Disabled ("Remove to run test" )
43
49
@ Test
50
+ @ DisplayName ("list of lists" )
44
51
public void testConcatListOfLists () {
45
52
List <List <Character >> listOfLists = List .of (
46
53
List .of ('1' , '2' ),
@@ -54,6 +61,7 @@ public void testConcatListOfLists() {
54
61
55
62
@ Disabled ("Remove to run test" )
56
63
@ Test
64
+ @ DisplayName ("list of nested lists" )
57
65
public void testConcatListOfNestedLists () {
58
66
List <List <List <Character >>> listOfNestedLists = List .of (
59
67
List .of (
@@ -82,45 +90,52 @@ public void testConcatListOfNestedLists() {
82
90
83
91
@ Disabled ("Remove to run test" )
84
92
@ Test
93
+ @ DisplayName ("empty list" )
85
94
public void testFilteringEmptyList () {
86
95
assertThat (ListOps .filter (List .<Integer >of (), integer -> integer % 2 == 1 ))
87
96
.isEmpty ();
88
97
}
89
98
90
99
@ Disabled ("Remove to run test" )
91
100
@ Test
101
+ @ DisplayName ("non-empty list" )
92
102
public void testFilteringNonEmptyList () {
93
103
assertThat (ListOps .filter (List .of (1 , 2 , 3 , 5 ), integer -> integer % 2 == 1 ))
94
104
.containsExactly (1 , 3 , 5 );
95
105
}
96
106
97
107
@ Disabled ("Remove to run test" )
98
108
@ Test
109
+ @ DisplayName ("empty list" )
99
110
public void testSizeOfEmptyList () {
100
111
assertThat (ListOps .size (List .of ())).isEqualTo (0 );
101
112
}
102
113
103
114
@ Disabled ("Remove to run test" )
104
115
@ Test
116
+ @ DisplayName ("non-empty list" )
105
117
public void testSizeOfNonEmptyList () {
106
118
assertThat (ListOps .size (List .of ("one" , "two" , "three" , "four" ))).isEqualTo (4 );
107
119
}
108
120
109
121
@ Disabled ("Remove to run test" )
110
122
@ Test
123
+ @ DisplayName ("empty list" )
111
124
public void testTransformingEmptyList () {
112
125
assertThat (ListOps .map (List .<Integer >of (), integer -> integer + 1 )).isEmpty ();
113
126
}
114
127
115
128
@ Disabled ("Remove to run test" )
116
129
@ Test
130
+ @ DisplayName ("non-empty list" )
117
131
public void testTransformingNonEmptyList () {
118
132
assertThat (ListOps .map (List .of (1 , 3 , 5 , 7 ), integer -> integer + 1 ))
119
133
.containsExactly (2 , 4 , 6 , 8 );
120
134
}
121
135
122
136
@ Disabled ("Remove to run test" )
123
137
@ Test
138
+ @ DisplayName ("empty list" )
124
139
public void testFoldLeftEmptyList () {
125
140
assertThat (
126
141
ListOps .foldLeft (
@@ -132,6 +147,7 @@ public void testFoldLeftEmptyList() {
132
147
133
148
@ Disabled ("Remove to run test" )
134
149
@ Test
150
+ @ DisplayName ("direction independent function applied to non-empty list" )
135
151
public void testFoldLeftDirectionIndependentFunctionAppliedToNonEmptyList () {
136
152
assertThat (
137
153
ListOps .foldLeft (
@@ -143,6 +159,7 @@ public void testFoldLeftDirectionIndependentFunctionAppliedToNonEmptyList() {
143
159
144
160
@ Disabled ("Remove to run test" )
145
161
@ Test
162
+ @ DisplayName ("direction dependent function applied to non-empty list" )
146
163
public void testFoldLeftDirectionDependentFunctionAppliedToNonEmptyList () {
147
164
assertThat (
148
165
ListOps .foldLeft (
@@ -154,6 +171,7 @@ public void testFoldLeftDirectionDependentFunctionAppliedToNonEmptyList() {
154
171
155
172
@ Disabled ("Remove to run test" )
156
173
@ Test
174
+ @ DisplayName ("empty list" )
157
175
public void testFoldRightEmptyList () {
158
176
assertThat (
159
177
ListOps .foldRight (
@@ -165,6 +183,7 @@ public void testFoldRightEmptyList() {
165
183
166
184
@ Disabled ("Remove to run test" )
167
185
@ Test
186
+ @ DisplayName ("direction independent function applied to non-empty list" )
168
187
public void testFoldRightDirectionIndependentFunctionAppliedToNonEmptyList () {
169
188
assertThat (
170
189
ListOps .foldRight (
@@ -176,6 +195,7 @@ public void testFoldRightDirectionIndependentFunctionAppliedToNonEmptyList() {
176
195
177
196
@ Disabled ("Remove to run test" )
178
197
@ Test
198
+ @ DisplayName ("direction dependent function applied to non-empty list" )
179
199
public void testFoldRightDirectionDependentFunctionAppliedToNonEmptyList () {
180
200
assertThat (
181
201
ListOps .foldRight (
@@ -187,19 +207,22 @@ public void testFoldRightDirectionDependentFunctionAppliedToNonEmptyList() {
187
207
188
208
@ Disabled ("Remove to run test" )
189
209
@ Test
210
+ @ DisplayName ("empty list" )
190
211
public void testReversingEmptyList () {
191
212
assertThat (ListOps .reverse (List .of ())).isEmpty ();
192
213
}
193
214
194
215
@ Disabled ("Remove to run test" )
195
216
@ Test
217
+ @ DisplayName ("non-empty list" )
196
218
public void testReversingNonEmptyList () {
197
219
assertThat (ListOps .reverse (List .of ('1' , '3' , '5' , '7' )))
198
220
.containsExactly ('7' , '5' , '3' , '1' );
199
221
}
200
222
201
223
@ Disabled ("Remove to run test" )
202
224
@ Test
225
+ @ DisplayName ("list of lists is not flattened" )
203
226
public void testReversingListOfListIsNotFlattened () {
204
227
List <List <Character >> listOfLists = List .of (
205
228
List .of ('1' , '2' ),
0 commit comments