What is the point of the REQUIRE_NOTHROW
assertion? If I just put a statement and don't wrap it in any assertion macro it will fail if it throws anyway?
Point of REQUIRE_NOTHROW in the catch c++ testing framework
2.1k views Asked by Baruch At
1
It's the difference between the TEST_CASE failing and an individual assertion failing. The REQUIRE macros ensure that the next lines aren't executed if they fail. Conversely, the CHECK macros can mark the test case as a failure but continue.
Consider this example:
So we're explicitly requesting that passing valid input does not cause an exception, but bad input does. If we didn't use the
REQUIRE_NOTHROW()
macro, then the test would fail but then we'd need to decipher where it failed - an exception could have come from other lines of test code.