Boost logo

Boost Users :

Subject: [Boost-users] Boost.Test: floating point comparison using absolute diference
From: Georgios Sermaidis (g.sermaidis_at_[hidden])
Date: 2017-12-29 16:33:45


Hi all,

I am trying to find a way to make the boost unit test framework use an absolute difference for floating point comparison instead of the relative difference.
I searched the documentation to try to find a suitable decorator but couldn’t find anything. Any help is much appreciated!

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

// boost::unit_test::tolerance uses relative difference and hence this test will pass;
// is there anything I can use here to indicate absolute difference?
BOOST_AUTO_TEST_CASE(my_test, * boost::unit_test::tolerance(0.1) )
{

  BOOST_TEST(10.1 == 10.3);
}



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