Asserting with Catch2
Unlike other testing frameworks, Catch2 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 Catch2, a topic we covered in the previous recipe, Writing and invoking tests with Catch2.
How to do it...
The following list contains the available options for asserting with the Catch2 framework:
CHECK(expr)to check whether
true, continuing the execution in case of failure, and
REQUIRE(expr)to make sure that
true, stopping the execution of the test in case of failure:
int a = 42; CHECK(a == 42);...