You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/06/14 13:15:19 UTC
(commons-lang) 03/03: Add missing test per JaCoCo test coverage
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 29132cb86fd017f70964766bbb5be44dfdfaba46
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 14 09:15:10 2025 -0400
Add missing test per JaCoCo test coverage
---
.../apache/commons/lang3/stream/StreamsTest.java | 50 ++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java b/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
index 539f64a3b..f3b3dda61 100644
--- a/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
+++ b/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
@@ -17,6 +17,7 @@
package org.apache.commons.lang3.stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -124,6 +125,41 @@ public Stream<DynamicTest> simpleStreamForEachFailing() {
}));
}
+ @SuppressWarnings("deprecation")
+ @Test
+ void testDeprefcatedCopnstructor() {
+ assertNotNull(new Streams().toString());
+ }
+
+ @Test
+ void testFailableAllMatch() {
+ assertTrue(Streams.failableStream("A", "B").allMatch(s -> s.length() == 1));
+ assertFalse(Streams.failableStream("A", "B").allMatch(s -> s.length() == 2));
+ }
+
+ @Test
+ void testFailableAnyMatch() {
+ assertTrue(Streams.failableStream("A", "B").anyMatch(s -> s.length() == 1));
+ assertTrue(Streams.failableStream("A", "BC").anyMatch(s -> s.length() == 1));
+ assertFalse(Streams.failableStream("A", "B").anyMatch(s -> s.length() == 2));
+ }
+
+ @Test
+ void testFailableCollect() {
+ assertEquals(Arrays.asList("A", "B"), Streams.failableStream("A", "B").collect(ArrayList::new, ArrayList::add, ArrayList::addAll));
+ }
+
+ @Test
+ void testFailableReduce() {
+ assertEquals(3, Streams.failableStream(1, 2).reduce(0, (a, b) -> a + b));
+ }
+
+ @Test
+ void testFailableStream() {
+ assertEquals(1, Streams.failableStream(1).collect(Collectors.toList()).size());
+ assertEquals(0, Streams.failableStream(Stream.empty()).collect(Collectors.toList()).size());
+ }
+
@Test
void testInstanceOfStream() {
assertEquals(2, Streams.instancesOf(String.class, Arrays.asList("A", "B")).collect(Collectors.toList()).size());
@@ -137,6 +173,7 @@ void testInstanceOfStream() {
@Test
void testNonNull() {
assertEquals(0, Streams.nonNull().collect(Collectors.toList()).size());
+ assertEquals(0, Streams.nonNull((Stream<?>) null).collect(Collectors.toList()).size());
assertEquals(1, Streams.nonNull("A").collect(Collectors.toList()).size());
assertEquals(1, Streams.nonNull("A", null).collect(Collectors.toList()).size());
assertEquals(1, Streams.nonNull(null, "A").collect(Collectors.toList()).size());
@@ -209,6 +246,12 @@ void testOfIteratorNull() {
assertEquals(0, Streams.of(input).collect(Collectors.toList()).size());
}
+ @Test
+ void testOfVarArg() {
+ assertEquals(1, Streams.of(1).collect(Collectors.toList()).size());
+ assertEquals(2, Streams.of(1, 2).collect(Collectors.toList()).size());
+ }
+
@Test
void testSimpleStreamFilter() {
final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6");
@@ -245,6 +288,13 @@ void testSimpleStreamMapFailing() {
assertEquals("For input string: \"4 \"", thrown.getMessage());
}
+ @SuppressWarnings("deprecation")
+ @Test
+ void testStream() {
+ assertEquals(0, Streams.stream(Stream.empty()).collect(Collectors.toList()).size());
+ assertEquals(1, Streams.stream(Stream.of("")).collect(Collectors.toList()).size());
+ }
+
@Test
void testStreamCollection() {
final List<String> input = Arrays.asList("1", "2", "3", "4", "5", "6");