shouldNotThrow

Used for asserting that a expression will not throw an exception.

void
shouldNotThrow
(
T : Throwable = Exception
E
)
(
lazy E condition
,
in string file = __FILE__
,
in size_t line = __LINE__
)

Parameters

condition
Type: E

The expression that is expected to not throw the exception.

file
Type: string

The file name that the assert failed in. Should be left as default.

line
Type: size_t

The file line that the assert failed in. Should be left as default.

Throws

If expression does throw, will throw an UnitTestException.

Examples

1 // Makes sure it throws with the message "test"
2 void noThrow(){};
3 void withThrow(){throw new Exception("test");};
4 
5 // Will throw an exception like "checkit.exception.UnitTestException@test/example.d(7): Expression threw"
6 noThrow.shouldNotThrow();

Meta