"Chris Fairles"
Thanks for the suggestion, tried a few things. I have #define CHECK_IS_CLOSE_WEAK(x, y, t) \ boost::test_tools::check_is_close((x),(y), boost::test_tools::percent_tolerance(t), boost::test_tools::FPC_WEAK)
which works fine with when either x or y is 0. I tried the predicate method, something like:
This is wrong. check_is_close can't return true if either x or y is zero regardless of weak/strong flag. Relative errors are 1 and Inf. Both are more than 1e-05
BOOST_CHECK_PREDICATE(boost::test_tools::check_is_close, (first)(second)(boost::test_tools::percent_tolerance( e ))(boost::test_tools::FPC_WEAK))
But this fails check boost::test_tools::check_is_close( m_cmp(i,j), m(i,j), boost::test_tools::percent_tolerance( tolerance ), boost::test_tools::FPC_WEAK ) failed for ( 0, -2.2204460492503131e-16, 1e-05, 1 )
As expected.
Am I not using the predicate correctly?
You should use differerent predicate, which uses check_is_close in regular cases and check_is_small in case if either of the arguments is zero. It's still not exactly correct, since in general you can't use the same tolerance for both comparizons: one is relative, another is absolute. Gennadiy