2626import java .io .IOException ;
2727import java .io .UncheckedIOException ;
2828import java .util .concurrent .atomic .AtomicInteger ;
29+ import java .util .concurrent .atomic .AtomicLong ;
2930import java .util .concurrent .atomic .AtomicReference ;
3031import 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