From: boost-users-bounces@lists.boost.org on behalf of Gennadiy Rozental Sent: Thu 9/9/2010 8:33 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users][Boost.Test] Understanding the correct use of BOOST_CHECK_CLOSE and >BOOST_CHECK_CLOSE_FRACTION
Use BOOST_CHECK_SMALL( a-b, tolerance ).
That said I really recommend you to use assertions based on relative errors, since they give more reliable results.
Thanks for the input. On the advice of a co-worker I am using a normalized variance ( value - reference ) / reference. Of course you can't use the check if the reference is zero. In that case I simply use BOOST_CHECK_EQUAL. Here is how I did the macro: #define BOOST_CHECK_VARIANCE( L, R ) BOOST_CHECK_LT ( fabs ( ( L - R ) / R ), 1e-9 ) I can change that to be #define BOOST_CHECK_VARIANCE( L, R ) BOOST_CHECK_SMALL ( ( L - R ) / R, 1e-9 ) What would have to do finish the implementation of a proper print algorithm so that 9.999999e-13 is displayed as 1e-12? Stephen