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 2023/06/24 17:57:21 UTC

[commons-io] 01/02: Add missing test

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

commit 6fea8f40e4af6358d11e4cdfaad57af23f1c7a0a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 24 13:25:13 2023 -0400

    Add missing test
---
 .../java/org/apache/commons/io/function/UncheckTest.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/test/java/org/apache/commons/io/function/UncheckTest.java b/src/test/java/org/apache/commons/io/function/UncheckTest.java
index 6597166d..d0785477 100644
--- a/src/test/java/org/apache/commons/io/function/UncheckTest.java
+++ b/src/test/java/org/apache/commons/io/function/UncheckTest.java
@@ -26,6 +26,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Supplier;
 
@@ -43,6 +44,7 @@ public class UncheckTest {
     private static final String CUSTOM_MESSAGE = "Custom message";
 
     private AtomicInteger atomicInt;
+    private AtomicLong atomicLong;
     private AtomicReference<String> ref1;
     private AtomicReference<String> ref2;
     private AtomicReference<String> ref3;
@@ -62,6 +64,7 @@ public class UncheckTest {
         ref3 = new AtomicReference<>();
         ref4 = new AtomicReference<>();
         atomicInt = new AtomicInteger();
+        atomicLong = new AtomicLong();
     }
 
     private ByteArrayInputStream newInputStream() {
@@ -235,6 +238,16 @@ public class UncheckTest {
         assertEquals(1, atomicInt.get());
     }
 
+    @Test
+    public void testGetAsLong() {
+        assertThrows(UncheckedIOException.class, () -> Uncheck.getAsLong(() -> {
+            throw new IOException();
+        }));
+        assertThrows(UncheckedIOException.class, () -> Uncheck.getAsLong(TestConstants.THROWING_IO_LONG_SUPPLIER));
+        assertEquals(1L, Uncheck.getAsLong(() -> TestUtils.compareAndSetThrowsIO(atomicLong, 1L)));
+        assertEquals(1L, atomicLong.get());
+    }
+
     @Test
     public void testGetAsIntMessage() {
         // No exception