forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrainTest.java
More file actions
134 lines (118 loc) · 4.32 KB
/
StrainTest.java
File metadata and controls
134 lines (118 loc) · 4.32 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class StrainTest {
@Test
public void emptyKeep() {
List<Integer> input = new LinkedList<>();
List<Integer> expectedOutput = new LinkedList<>();
Assert.assertEquals(expectedOutput, Strain.keep(input, x -> x < 10));
}
@Ignore
@Test
public void keepEverything() {
List<Integer> input = Arrays.asList(1, 2, 3);
List<Integer> expectedOutput = Arrays.asList(1, 2, 3);
Assert.assertEquals(expectedOutput, Strain.keep(input, x -> x < 10));
}
@Ignore
@Test
public void keepFirstAndLast() {
List<Integer> input = Arrays.asList(1, 2, 3);
List<Integer> expectedOutput = Arrays.asList(1, 3);
Assert.assertEquals(expectedOutput, Strain.keep(input, x -> x % 2 != 0));
}
@Ignore
@Test
public void keepNeitherFirstNorLast() {
List<Integer> input = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> expectedOutput = Arrays.asList(2, 4);
Assert.assertEquals(expectedOutput, Strain.keep(input, x -> x % 2 == 0));
}
@Ignore
@Test
public void KeepStrings() {
List<String> words = Arrays
.asList("apple zebra banana zombies cherimoya zelot".split(" "));
List<String> expectedOutput = Arrays.asList("zebra", "zombies", "zelot");
Assert.assertEquals(expectedOutput,
Strain.keep(words, x -> x.startsWith("z")));
}
@Ignore
@Test
public void KeepArrays() {
List<List<Integer>> actual = Arrays.asList(
Arrays.asList(1, 2, 3),
Arrays.asList(5, 5, 5),
Arrays.asList(5, 1, 2),
Arrays.asList(2, 1, 2),
Arrays.asList(1, 5, 2),
Arrays.asList(2, 2, 1),
Arrays.asList(1, 2, 5));
List<List<Integer>> expectedOutput = Arrays.asList(
Arrays.asList(5, 5, 5),
Arrays.asList(5, 1, 2),
Arrays.asList(1, 5, 2),
Arrays.asList(1, 2, 5));
Assert.assertEquals(expectedOutput,
Strain.keep(actual, col -> col.contains(5)));
}
@Ignore
@Test
public void emptyDiscard() {
List<Integer> input = new LinkedList<>();
List<Integer> expectedOutput = new LinkedList<>();
Assert.assertEquals(expectedOutput, Strain.discard(input, x -> x < 10));
}
@Ignore
@Test
public void discardNothing() {
List<Integer> input = Arrays.asList(1, 2, 3);
List<Integer> expectedOutput = Arrays.asList(1, 2, 3);
Assert.assertEquals(expectedOutput, Strain.discard(input, x -> x > 10));
}
@Ignore
@Test
public void discardFirstAndLast() {
List<Integer> input = Arrays.asList(1, 2, 3);
List<Integer> expectedOutput = Arrays.asList(2);
Assert.assertEquals(expectedOutput, Strain.discard(input, x -> x % 2 != 0));
}
@Ignore
@Test
public void discardNeitherFirstNorLast() {
List<Integer> input = Arrays.asList(1, 2, 3, 4, 5);
List<Integer> expectedOutput = Arrays.asList(1, 3, 5);
Assert.assertEquals(expectedOutput, Strain.discard(input, x -> x % 2 == 0));
}
@Ignore
@Test
public void discardStrings() {
List<String> words = Arrays
.asList("apple zebra banana zombies cherimoya zelot".split(" "));
List<String> expectedOutput = Arrays.asList("apple", "banana", "cherimoya");
Assert.assertEquals(expectedOutput,
Strain.discard(words, x -> x.startsWith("z")));
}
@Ignore
@Test
public void discardArrays() {
List<List<Integer>> actual = Arrays.asList(
Arrays.asList(1, 2, 3),
Arrays.asList(5, 5, 5),
Arrays.asList(5, 1, 2),
Arrays.asList(2, 1, 2),
Arrays.asList(1, 5, 2),
Arrays.asList(2, 2, 1),
Arrays.asList(1, 2, 5));
List<List<Integer>> expectedOutput = Arrays.asList(
Arrays.asList(1, 2, 3),
Arrays.asList(2, 1, 2),
Arrays.asList(2, 2, 1));
Assert.assertEquals(expectedOutput,
Strain.discard(actual, col -> col.contains(5)));
}
}