|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Test] Understanding the correct use of BOOST_CHECK_CLOSE and BOOST_CHECK_CLOSE_FRACTION
From: Torri, Stephen CIV NSWCDD, W15 (stephen.torri_at_[hidden])
Date: 2010-09-10 09:17:06
>From: boost-users-bounces_at_[hidden] on behalf of Gennadiy Rozental
>Sent: Thu 9/9/2010 8:33 PM
>To: boost-users_at_[hidden]
>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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net