Commit 29169e6
committed
Use FAIL_CHECK macro to report non-fatal failures to Catch2
This avoids a two-step dance of first capturing a local variable
and then doing a roundabout CHECK(false);
The previous approach produces a somewhat cluttered error message,
that primarily describes the expression `failure.empty() == false`,
showing the real issue only as an extra "failure := "..." variable
(which is presented as a quoted value, and possible truncated).
FAILED:
CHECK( failure.empty() )
with expansion:
false
with message:
failure := "test.cpp:15
Unfulfilled expectation:
Expected mock.foo(42) to be called once, actually never called
param _1 == 42
"
Using FAIL_CHECK puts the real message up front, with no extra quoting.
Like CHECK(false) (but unlike FAIL) it allows execution to continue.
FAILED:
explicitly with message:
test.cpp:15
Unfulfilled expectation:
Expected mock.foo(42) to be called once, actually never called
param _1 == 42
FAIL_CHECK has been available since Catch2 1.8.21 parent 2a633b9 commit 29169e6
2 files changed
+3
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | | - | |
| 289 | + | |
291 | 290 | | |
292 | 291 | | |
293 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
52 | 51 | | |
53 | | - | |
54 | | - | |
| 52 | + | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
| |||
0 commit comments