Skip to content

Commit 6fea8f4

Browse files
committed
Add missing test
1 parent c6d891e commit 6fea8f4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/test/java/org/apache/commons/io/function/UncheckTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.IOException;
2727
import java.io.UncheckedIOException;
2828
import java.util.concurrent.atomic.AtomicInteger;
29+
import java.util.concurrent.atomic.AtomicLong;
2930
import java.util.concurrent.atomic.AtomicReference;
3031
import java.util.function.Supplier;
3132

@@ -43,6 +44,7 @@ public class UncheckTest {
4344
private static final String CUSTOM_MESSAGE = "Custom message";
4445

4546
private AtomicInteger atomicInt;
47+
private AtomicLong atomicLong;
4648
private AtomicReference<String> ref1;
4749
private AtomicReference<String> ref2;
4850
private AtomicReference<String> ref3;
@@ -62,6 +64,7 @@ public void initEach() {
6264
ref3 = new AtomicReference<>();
6365
ref4 = new AtomicReference<>();
6466
atomicInt = new AtomicInteger();
67+
atomicLong = new AtomicLong();
6568
}
6669

6770
private ByteArrayInputStream newInputStream() {
@@ -235,6 +238,16 @@ public void testGetAsInt() {
235238
assertEquals(1, atomicInt.get());
236239
}
237240

241+
@Test
242+
public void testGetAsLong() {
243+
assertThrows(UncheckedIOException.class, () -> Uncheck.getAsLong(() -> {
244+
throw new IOException();
245+
}));
246+
assertThrows(UncheckedIOException.class, () -> Uncheck.getAsLong(TestConstants.THROWING_IO_LONG_SUPPLIER));
247+
assertEquals(1L, Uncheck.getAsLong(() -> TestUtils.compareAndSetThrowsIO(atomicLong, 1L)));
248+
assertEquals(1L, atomicLong.get());
249+
}
250+
238251
@Test
239252
public void testGetAsIntMessage() {
240253
// No exception

0 commit comments

Comments
 (0)