Unlike other testing frameworks, Catch does not provide a large set of assertion macros. It has two main macros: REQUIRE
, which produces a fatal error stopping the execution of the test case upon failure and CHECK
, which produces a non-fatal error upon failure, continuing the execution of the test case. Several additional macros are defined; in this recipe, we will see how to put them to work.
You should now be familiar with writing test cases and test functions using Catch, a topic covered in the previous recipe.
The following list contains the available options for asserting with the Catch framework:
- Use
CHECK(expr)
to check whetherexpr
evaluates totrue
, continuing the execution in case of failure, andREQUIRE(expr)
to make sure thatexpr
evaluates totrue
and stop the execution of the test in case of failure:
int a = 42; CHECK(a == 42); REQUIRE(a == 42);
- Use
CHECK_FALSE(expr)
andREQUIRE_FALSE(expr)
to make sure that...