xtd 0.2.0
Loading...
Searching...
No Matches

◆ throws() [3/4]

template<typename exception_t >
static void xtd::tunit::valid::throws ( const std::function< void()> &  statement,
const xtd::string message 
)
inlinestatic

Validates that the statement throws a particular exception when called.

Template Parameters
exception_tThe exception type that must be throw.
Parameters
statementThe statement that verify.
messageA user message to display if the assertion fails. This message can be seen in the unit test results.
Examples
std::vector<int> v1 = {1, 2, 3, 4};
xtd::tunit::valid::throws<std::out_of_range>([&] {v1.at(5);}, "User message..."); // test ok.
xtd::tunit::valid::throws<std::out_of_range>([&] {v1.at(2);}, "User message..."); // test fails.