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-io.git
The following commit(s) were added to refs/heads/master by this push:
new a41b4bc8 More coverage
a41b4bc8 is described below
commit a41b4bc8e70b206841f4d846be10cf8612dd81e1
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Sep 17 15:38:20 2022 -0400
More coverage
---
.../apache/commons/io/function/IOConsumerTest.java | 65 +++++++++++++++++-----
1 file changed, 52 insertions(+), 13 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
b/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
index 18bfa8ea..5bfeb401 100644
--- a/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
@@ -73,36 +73,75 @@ public class IOConsumerTest {
}
@Test
- public void testForAllArray() throws IOException {
+ public void testForAllArrayOf1() throws IOException {
IOConsumer.forAll(TestUtils.throwingIOConsumer(), (String[]) null);
+ IOConsumer.forAll(null, (String[]) null);
assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), new String[] {"1"}));
-
- final AtomicReference<String> ref = new AtomicReference<>();
- final IOConsumer<String> consumer1 = s -> ref.set(s + "2");
+ //
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
IOConsumer.forAll(consumer1, new String[] {"1"});
- assertEquals("12", ref.get());
+ assertEquals("01", ref.get());
+ }
+
+ @Test
+ public void testForAllArrayOf2() throws IOException {
+ IOConsumer.forAll(TestUtils.throwingIOConsumer(), (String[]) null);
+ IOConsumer.forAll(null, (String[]) null);
+ assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), new String[] {"1", "2"}));
+ //
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
+ IOConsumer.forAll(consumer1, new String[] {"1", "2"});
+ assertEquals("012", ref.get());
}
@Test
- public void testForAllIterable() throws IOException {
+ public void testForAllIterableOf1() throws IOException {
IOConsumer.forAll(TestUtils.throwingIOConsumer(), (Iterable<Object>)
null);
+ IOConsumer.forAll(null, (Iterable<Object>) null);
assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), Arrays.asList("1")));
- final AtomicReference<String> ref = new AtomicReference<>();
- final IOConsumer<String> consumer1 = s -> ref.set(s + "2");
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
IOConsumer.forAll(consumer1, Arrays.asList("1"));
- assertEquals("12", ref.get());
+ assertEquals("01", ref.get());
+ }
+
+ @Test
+ public void testForAllIterableOf2() throws IOException {
+ IOConsumer.forAll(TestUtils.throwingIOConsumer(), (Iterable<Object>)
null);
+ IOConsumer.forAll(null, (Iterable<Object>) null);
+ assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), Arrays.asList("1", "2")));
+
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
+ IOConsumer.forAll(consumer1, Arrays.asList("1", "2"));
+ assertEquals("012", ref.get());
}
@Test
- public void testForAllStream() throws IOException {
+ public void testForAllStreamOf1() throws IOException {
IOConsumer.forAll(TestUtils.throwingIOConsumer(), (Stream<Object>)
null);
+ IOConsumer.forAll(null, (Stream<Object>) null);
assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), Arrays.asList("1").stream()));
- final AtomicReference<String> ref = new AtomicReference<>();
- final IOConsumer<String> consumer1 = s -> ref.set(s + "2");
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
IOConsumer.forAll(consumer1, Arrays.asList("1").stream());
- assertEquals("12", ref.get());
+ assertEquals("01", ref.get());
+ }
+
+ @Test
+ public void testForAllStreamOf2() throws IOException {
+ IOConsumer.forAll(TestUtils.throwingIOConsumer(), (Stream<Object>)
null);
+ IOConsumer.forAll(null, (Stream<Object>) null);
+ assertThrows(IOExceptionList.class, () ->
IOConsumer.forAll(TestUtils.throwingIOConsumer(), Arrays.asList("1",
"2").stream()));
+
+ final AtomicReference<String> ref = new AtomicReference<>("0");
+ final IOConsumer<String> consumer1 = s -> ref.set(ref.get() + s);
+ IOConsumer.forAll(consumer1, Arrays.asList("1", "2").stream());
+ assertEquals("012", ref.get());
}
@Test