Actual test of assertException().
Actual test of assertException().
#include <exception>
#include <string>
class MyTestException
: public std::exception
{
public:
std::string info;
inline virtual ~MyTestException()
{
}
inline explicit MyTestException(const char* info = "(MyTestException)") noexcept
:info(info)
{
}
inline virtual const char* what() const noexcept
{
return info.c_str();
}
};
void doNothing()
{
}
{
throw MyTestException();
}
{
assertException(
throw MyTestException(), MyTestException,
"Failed to catch the exception!");
assertException(
throw MyTestException(), std::exception,
"Failed to catch the exception!");
}
{
assertException(
throw int(5), MyTestException,
"Failed to catch the int exception!")
}
{
}
#define assertException(expression, expected, message)
Fail this test if (expression) does not throw the expected exception or a derived class exception wit...
#define EXPECTED_FAILURE(expression, message)
Fail this test if evaluating (expression) does not result itself in a failed test.
#define TEST_SUITE_END()
Finish definition of a Test Suite started with TEST_SUITE().
#define TEST_CASE(testCaseName)
Defines a Test Case method named testCaseName within a Test Suite defined by TEST_SUITE().
#define TEST_SUITE(testSuiteName)
Defines a Test Suite named testSuiteName.