diff options
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java b/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java new file mode 100644 index 0000000..2439ee2 --- /dev/null +++ b/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java @@ -0,0 +1,15 @@ +package org.zwobble.mammoth.tests.util; + +import org.zwobble.mammoth.internal.util.Casts; + +public class MammothAsserts { + public static <T extends Throwable> T assertThrows(Class<T> exceptionType, Action action) throws T { + try { + action.run(); + throw new AssertionError("Expected exception"); + } catch (RuntimeException exception) { + return Casts.tryCast(exceptionType, exception) + .orElseThrow(() -> exception); + } + } +} |
