cmoon::test::assert_throws
Defined in module
<cmoon.test>
|
(1) |
|
(2) |
Throws an assert_exception
if an exception of type Exception
is not thrown.
Parameters
callable | - | Function to call with args... |
args | - | Arguments to be forwarded to the given function |
message | - | Extra information to be added to the error message |
location | - | Information about where in the file this assertion was ran |
Return value
(none)
Example
import <stdexcept>;
import cmoon.test;
void will_throw(int)
{
throw std::runtime_error{"Exception thrown!"};
}
class example_test : public cmoon::test::test_case
{
public:
example_test()
: cmoon::test::test_case{"example test"} {}
void operator()() override
{
cmoon::test::assert_throws<std::runtime_error>(will_throw, 5);
}
};