I am working on some code with unit tests using catch2 (and it will stay that way, for reasons).
Now, in the set of unit tests, there are a lot of (pairs of) lines which look like this:
T t1;
t1 = foo(some, params, here);
CHECK(my_compare(t1, T{some_literal}));
so, my_out_param
is being set using a single function call, and then it's compared to a T literal.
Now, when this runs and fails, I get:
/path/to/test.cpp:493: Failure:
CHECK(my_compare(t1, T{some_literal}));
with expansion:
false
but obviously I don't get the "some, params, here". Well, I need it. Otherwise, I don't really know which test failed without reading the source code.
Since there's a reliance on macros here, I can't just wrap CHECK()
in a function and do something fancy inside.
What would you suggest I do to make "some, params, here" get printed alongside "some_literal" when the check fails, while:
- Keeping my test source code terse.
- Not repeating myself
- Still getting a valid file and line number
?
Note: The currently-used version of catch2 is 2.7.0, merged into a single header. If a version change would help, that may be doable.