@@ -238,6 +238,25 @@ public void testGetAsInt() {
238238 assertEquals (1 , atomicInt .get ());
239239 }
240240
241+ @ Test
242+ public void testGetAsIntMessage () {
243+ // No exception
244+ assertThrows (UncheckedIOException .class , () -> Uncheck .getAsInt (() -> {
245+ throw new IOException ();
246+ }, () -> CUSTOM_MESSAGE ));
247+ assertThrows (UncheckedIOException .class , () -> Uncheck .getAsInt (TestConstants .THROWING_IO_INT_SUPPLIER , () -> CUSTOM_MESSAGE ));
248+ assertEquals (1 , Uncheck .getAsInt (() -> TestUtils .compareAndSetThrowsIO (atomicInt , 1 ), () -> CUSTOM_MESSAGE ));
249+ assertEquals (1 , atomicInt .get ());
250+ // exception
251+ final IOException expected = new IOException (CAUSE_MESSAGE );
252+ try {
253+ Uncheck .getAsInt (() -> new BrokenInputStream (expected ).read (), () -> CUSTOM_MESSAGE );
254+ fail ();
255+ } catch (final UncheckedIOException e ) {
256+ assertUncheckedIOException (expected , e );
257+ }
258+ }
259+
241260 @ Test
242261 public void testGetAsLong () {
243262 assertThrows (UncheckedIOException .class , () -> Uncheck .getAsLong (() -> {
@@ -249,18 +268,18 @@ public void testGetAsLong() {
249268 }
250269
251270 @ Test
252- public void testGetAsIntMessage () {
271+ public void testGetAsLongMessage () {
253272 // No exception
254- assertThrows (UncheckedIOException .class , () -> Uncheck .getAsInt (() -> {
273+ assertThrows (UncheckedIOException .class , () -> Uncheck .getAsLong (() -> {
255274 throw new IOException ();
256275 }, () -> CUSTOM_MESSAGE ));
257- assertThrows (UncheckedIOException .class , () -> Uncheck .getAsInt (TestConstants .THROWING_IO_INT_SUPPLIER , () -> CUSTOM_MESSAGE ));
258- assertEquals (1 , Uncheck .getAsInt (() -> TestUtils .compareAndSetThrowsIO (atomicInt , 1 ), () -> CUSTOM_MESSAGE ));
259- assertEquals (1 , atomicInt .get ());
276+ assertThrows (UncheckedIOException .class , () -> Uncheck .getAsLong (TestConstants .THROWING_IO_LONG_SUPPLIER , () -> CUSTOM_MESSAGE ));
277+ assertEquals (1L , Uncheck .getAsLong (() -> TestUtils .compareAndSetThrowsIO (atomicLong , 1L ), () -> CUSTOM_MESSAGE ));
278+ assertEquals (1L , atomicLong .get ());
260279 // exception
261280 final IOException expected = new IOException (CAUSE_MESSAGE );
262281 try {
263- Uncheck .getAsInt (() -> new BrokenInputStream (expected ).read (), () -> CUSTOM_MESSAGE );
282+ Uncheck .getAsLong (() -> new BrokenInputStream (expected ).read (), () -> CUSTOM_MESSAGE );
264283 fail ();
265284 } catch (final UncheckedIOException e ) {
266285 assertUncheckedIOException (expected , e );
0 commit comments