blob: 2439ee2129fc02415c9424e2f82811a069605e98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);
}
}
}
|