I have a couple of tests that test interpolations of continuous functions, and when my implementation fails for some reason I get lots of output like the following from my Google test suite:
/home/tlycken/exjobb/Code/alpha-orbit-follower/test/interpolation/interpolation-tests.cpp:71: Failure
The difference between this->test_function_y_deriv(x,y) and this->getInterpObjectPtr()->evaluateAt(x,y,0,1) is 1.5395837072062037, which exceeds tol, where
this->test_function_y_deriv(x,y) evaluates to -1.5395837072062037,
this->getInterpObjectPtr()->evaluateAt(x,y,0,1) evaluates to 0, and
tol evaluates to 0.01.
Since I basically loop over the interpolated interval and test with ASSERT_NEAR()
in a lot of places, I'm not surprised, but it would be nice to suppress the details of each error message, and just see the pass/fail status of the test case in the report. If a test fails, and I don't understand why, I can reenable the output and look closer.
However, I can't find any information on how to suppress that kind of output. Perhaps my Google-fu is inadequate...
Is there a command line flag, or some other means, to suppress the output from individual ASSERT*
calls, and just show the final test report?
Code sample:
As this seems to be difficult to reproduce, this is the code I'm running. In my test fixture, I have the following method:
void on_interpolated_grid(std::function<void(double)> f) {
double dxp = dx / 10;
double xmax = xmin + (N - 1) * dx;
for (double xp = xmin + 2 * dx; xp < xmax - 2 * dx; xp += dxp) {
f(xp);
}
}
and the test is defined like this:
TYPED_TEST(Interp1D_F, SecondOrderDerivative) {
Interp1D itp(this->N, this->x, this->f);
this->on_interpolated_grid([itp](double x) -> void {
ASSERT_NEAR(-sin(x), itp.evaluateAt(x, 2), 1e-3);
});
}
The members N
, x
and f
on the test fixture are just parameters for initialization of the interpolation object.
I also tried to wrap the call to on_interpolated_grid
in ASSERT_NO_FATAL_FAILURES
, but it didn't help.