assertThrown

fnvoid assertThrown(T : Throwable = Exception, E)(lazy E expression, string msg = null, string file = __FILE__, size_t line = __LINE__)

Asserts that the given expression throws the given type of Throwable. The Throwable is caught and does not escape assertThrown. However, any other Throwables will escape, and if no Throwable of the given type is thrown, then an AssertError is thrown.

Parameters

TThe Throwable to test for.
expressionThe expression to test.
msgOptional message to output on test failure.
fileThe file where the error occurred. Defaults to __FILE__.
lineThe line where the error occurred. Defaults to __LINE__.

Throws

AssertError if the given Throwable is not thrown.