You could mutate CHECK_CLOSE
into a macro (I know... macros are evil but as wrappers for debug functions, to automatically pass things like __FILE__
, __LINE__
...)
#if defined(DEBUG)
#define CHECK_CLOSE(actual, expected, tolerance) { \
if (std::fabs(expected.x) < EPSILON) BOOST_CHECK_SMALL(actual.x, tolerance); \
else BOOST_CHECK_CLOSE(actual.x, expected.x, tolerance); \
if (std::fabs(expected.y) < EPSILON) BOOST_CHECK_SMALL(actual.y, tolerance); \
else BOOST_CHECK_CLOSE(actual.y, expected.y, tolerance); \
if (std::fabs(expected.z) < EPSILON) BOOST_CHECK_SMALL(actual.z, tolerance); \
else BOOST_CHECK_CLOSE(actual.z, expected.z, tolerance); \
}
#else
#define CHECK_CLOSE(actual, expected, tolerance)
#endif