Skip to content

Commit ef2bde1

Browse files
committed
More tests
1 parent 6622a46 commit ef2bde1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.lang.reflect.UndeclaredThrowableException;
2929
import java.util.ArrayList;
3030
import java.util.Arrays;
31+
import java.util.Enumeration;
3132
import java.util.Hashtable;
3233
import java.util.Iterator;
3334
import java.util.List;
@@ -38,6 +39,7 @@
3839
import org.apache.commons.lang3.function.Failable;
3940
import org.apache.commons.lang3.function.FailableConsumer;
4041
import org.apache.commons.lang3.function.FailablePredicate;
42+
import org.apache.commons.lang3.stream.Streams.FailableStream;
4143
import org.junit.jupiter.api.DynamicTest;
4244
import org.junit.jupiter.api.Test;
4345
import org.junit.jupiter.api.TestFactory;
@@ -136,6 +138,13 @@ void testArrayCollectorCombiner() {
136138
assertEquals(Arrays.asList("a", "b", "c"), Streams.toArray(String.class).combiner().apply(left, Arrays.asList("b", "c")));
137139
}
138140

141+
@Test
142+
void testAssertNotTerminated() {
143+
final FailableStream<String> stream = Streams.failableStream("A", "B");
144+
assertTrue(stream.allMatch(s -> s.length() == 1));
145+
assertThrows(IllegalStateException.class, () -> stream.allMatch(null));
146+
}
147+
139148
@SuppressWarnings("deprecation")
140149
@Test
141150
void testDeprefcatedCopnstructor() {
@@ -233,6 +242,9 @@ void testOfEnumeration() {
233242
assertTrue(collect.contains("One"));
234243
assertTrue(collect.contains("Two"));
235244
assertEquals(2, collect.size());
245+
assertFalse(Streams.of(table.keys()).filter(String::isEmpty).findFirst().isPresent());
246+
assertEquals(Arrays.asList("OneOne", "TwoTwo"), Streams.of(table.keys()).map(s -> s + s).collect(Collectors.toList()));
247+
assertFalse(Streams.of(new Hashtable<String, Object>().keys()).filter(String::isEmpty).findFirst().isPresent());
236248
}
237249

238250
@Test

0 commit comments

Comments
 (0)