assertErrorsWith

Verify that calling expr throws and contains the exception message msg.

void
assertErrorsWith
(
E
)
(
lazy E expr
,
string msg
,
string file = __FILE__
,
size_t line = __LINE__
)

Examples

1 require(1 == 2).assertErrorsWith("requirement failed.");
2 require(1 == 2, "%s is not true").assertErrorsWith("%s is not true");
3 require(1 == 2, "%s is not true", "1 == 2").assertErrorsWith("1 == 2 is not true");
4 
5 require(1 == 1).assertErrorsWith("requirement failed.")
6                .assertErrorsWith("Error: No exception was thrown.");

Meta