[test] upgrading from 1.58 to 1.59
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:: Snippet fraction_tolerance( tolerance ) ) ) ... As these seem to have been replaced/generalized starting with boost 1.59 I need to upgrade my code. Surely this involves using boost::test_tools::tolerance() but I'm getting a bit lost in the internals of Boost.Test. Could someone shed some light ? Thanks ! MAT.
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 ? Thanks ! MAT.
Mathieu Champlon
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
On 07/09/2015 07:49, Gennadiy Rozental wrote:
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 ) ) ...
Thank you Gennadiy, this is what I was looking for. Cheers, MAT.
participants (2)
-
Gennadiy Rozental
-
Mathieu Champlon