Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] upgrading from 1.58 to 1.59
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2015-09-07 01:49:19


Mathieu Champlon <m.champlon <at> free.fr> writes:

>
> On 05/09/2015 16:44, Mathieu Champlon wrote:
> > Hello,
> >
> > Prior to boost 1.59 I had code using the floating point comparisons of
> > Boost.Test as in
> >
> > if( boost::test_tools::check_is_close( v1, v2,
> > boost::test_tools::percent_tolerance( tolerance ) ) )
> > ...
> >
> > if( boost::test_tools::check_is_close( v1, v2,
> > boost::test_tools::fraction_tolerance( tolerance ) ) )
> > ...
> >
> > As these seem to have been replaced/generalized starting with boost
> > 1.59 I need to upgrade my code.
>
> It looks like I can still use boost::test_tools::check_is_close like
> this respectively :
>
> if( boost::test_tools::check_is_close( v1, v2, tolerance / 100 ) )
> ...
>
> if( boost::test_tools::check_is_close( v1, v2, tolerance ) )
> ...
>
> Am I right ?

check_is_close is deprecated.

Inside of the test modules I recommend using new BOOST_TEST tool:

BOOST_TEST( a==b, 3% tolerance() )

or

BOOST_TEST( a==b, tolerance(0.0003) )

For other use cases you can use close_at_tolerance directly:

fpc::close_at_tolerance<double> tester( 0.01, fpc::FPC_STRONG );

if( tester( a, b ) )
 ...

or

fpc::close_at_tolerance<double> tester( fpc::percent_tolerance(0.01),
fpc::FPC_STRONG );

if( tester( a, b ) )
 ...

Gennadiy


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