changed: measure relative error in a more standard way (knuth)

|(value-expected)/expected| < tol or |(value-expected)/value| < tol
instead of
|(value-expected)/(value+expected)|

this is how boost::test defines its check
This commit is contained in:
Arne Morten Kvarving 2020-10-27 09:55:43 +01:00
parent 778f486bcc
commit 3c1c3ba1f6

View File

@ -66,8 +66,8 @@
#define CHECK_CLOSE(value, expected, reltol) \
{ \
if (std::fabs((expected) - (value)) > 1e-14 && \
std::fabs(((expected) - (value))/((expected) + (value))) > reltol) \
if (std::fabs((expected) - (value)) > reltol*std::fabs(expected) && \
std::fabs((expected) - (value)) > reltol*std::fabs(value)) \
{ \
std::cerr << "Test failure: "; \
std::cerr << "expected value " << expected << " is not close to value " << value << std::endl; \