Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Piwowarek committed Feb 20, 2016
1 parent 7f3edfa commit 03b13c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/jasongoodwin/monads/TryConsumer.java
Expand Up @@ -16,4 +16,4 @@ public interface TryConsumer<T, E extends Throwable> {
*/
void accept(T t) throws E;

}
}
15 changes: 15 additions & 0 deletions src/test/java/com/jasongoodwin/monads/TryTest.java
Expand Up @@ -116,6 +116,21 @@ public void itShouldOrElseTryOnFailure() throws Throwable {
assertEquals("jude", t.get());
}

@Test(expected = RuntimeException.class)
public void itShouldGetAndThrowUncheckedException() throws Throwable {
Try.<String>ofFailable(() -> {
throw new Exception();
}).getUnchecked();

}

@Test
public void itShouldGetValue() throws Throwable {
final String result = Try.<String>ofFailable(() -> "test").getUnchecked();

assertEquals("test", result);
}

@Test
public void itShouldReturnRecoverValueWhenRecoveringOnFailure() {
String t = Try.ofFailable(() -> "hey")
Expand Down

0 comments on commit 03b13c6

Please sign in to comment.