Skip to content

Commit 29132cb

Browse files
committed
Add missing test per JaCoCo test coverage
1 parent 0ab0010 commit 29132cb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/test/java/org/apache/commons/lang3/stream/StreamsTest.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.commons.lang3.stream;
1818

1919
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
2021
import static org.junit.jupiter.api.Assertions.assertNotNull;
2122
import static org.junit.jupiter.api.Assertions.assertNull;
2223
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -124,6 +125,41 @@ public Stream<DynamicTest> simpleStreamForEachFailing() {
124125
}));
125126
}
126127

128+
@SuppressWarnings("deprecation")
129+
@Test
130+
void testDeprefcatedCopnstructor() {
131+
assertNotNull(new Streams().toString());
132+
}
133+
134+
@Test
135+
void testFailableAllMatch() {
136+
assertTrue(Streams.failableStream("A", "B").allMatch(s -> s.length() == 1));
137+
assertFalse(Streams.failableStream("A", "B").allMatch(s -> s.length() == 2));
138+
}
139+
140+
@Test
141+
void testFailableAnyMatch() {
142+
assertTrue(Streams.failableStream("A", "B").anyMatch(s -> s.length() == 1));
143+
assertTrue(Streams.failableStream("A", "BC").anyMatch(s -> s.length() == 1));
144+
assertFalse(Streams.failableStream("A", "B").anyMatch(s -> s.length() == 2));
145+
}
146+
147+
@Test
148+
void testFailableCollect() {
149+
assertEquals(Arrays.asList("A", "B"), Streams.failableStream("A", "B").collect(ArrayList::new, ArrayList::add, ArrayList::addAll));
150+
}
151+
152+
@Test
153+
void testFailableReduce() {
154+
assertEquals(3, Streams.failableStream(1, 2).reduce(0, (a, b) -> a + b));
155+
}
156+
157+
@Test
158+
void testFailableStream() {
159+
assertEquals(1, Streams.failableStream(1).collect(Collectors.toList()).size());
160+
assertEquals(0, Streams.failableStream(Stream.empty()).collect(Collectors.toList()).size());
161+
}
162+
127163
@Test
128164
void testInstanceOfStream() {
129165
assertEquals(2, Streams.instancesOf(String.class, Arrays.asList("A", "B")).collect(Collectors.toList()).size());
@@ -137,6 +173,7 @@ void testInstanceOfStream() {
137173
@Test
138174
void testNonNull() {
139175
assertEquals(0, Streams.nonNull().collect(Collectors.toList()).size());
176+
assertEquals(0, Streams.nonNull((Stream<?>) null).collect(Collectors.toList()).size());
140177
assertEquals(1, Streams.nonNull("A").collect(Collectors.toList()).size());
141178
assertEquals(1, Streams.nonNull("A", null).collect(Collectors.toList()).size());
142179
assertEquals(1, Streams.nonNull(null, "A").collect(Collectors.toList()).size());
@@ -209,6 +246,12 @@ void testOfIteratorNull() {
209246
assertEquals(0, Streams.of(input).collect(Collectors.toList()).size());
210247
}
211248

249+
@Test
250+
void testOfVarArg() {
251+
assertEquals(1, Streams.of(1).collect(Collectors.toList()).size());
252+
assertEquals(2, Streams.of(1, 2).collect(Collectors.toList()).size());
253+
}
254+
212255
@Test
213256
void testSimpleStreamFilter() {
214257
final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6");
@@ -245,6 +288,13 @@ void testSimpleStreamMapFailing() {
245288
assertEquals("For input string: \"4 \"", thrown.getMessage());
246289
}
247290

291+
@SuppressWarnings("deprecation")
292+
@Test
293+
void testStream() {
294+
assertEquals(0, Streams.stream(Stream.empty()).collect(Collectors.toList()).size());
295+
assertEquals(1, Streams.stream(Stream.of("")).collect(Collectors.toList()).size());
296+
}
297+
248298
@Test
249299
void testStreamCollection() {
250300
final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6");

0 commit comments

Comments
 (0)