Assertion.Throw

Asserts whether a callable object wrapped around the assertion throws an exception of type T.

struct Assertion(T)
@trusted
static if(isCallable!T)
void
Throw
(
T : Throwable = Exception
)
(
string file = __FILE__
,
size_t line = __LINE__
)

Examples

void throwing()
{
  throw new Exception("I throw with 0!");
}

should(&throwing).Throw!Exception;

void notThrowing()
{
  return;
}

should(&notThrowing).not.Throw;

Meta