[Moved from Issue 183 on GitHub]
From Petter Strandmark:
See
https://github.com/philsquared/Catch/blob/master/include/internal/catch_approx.hpp#L22
Is there a reason why float is used instead of double? That gives about 5 digits, right? If it is correct, can it be made configurable?
Approx approx = Approx::custom().epsilon( 0.005 );
REQUIRE( d == approx( 1.24 ) );
REQUIRE( d != approx( 1.25 ) );
...If you know you need the precision it's trivial to set a specific epsilon value. e.g.:
Approx( 1.23456789 ). epsilon( std::numeric_limits<double>::epsilon() );
And then you can do, e.g.:REQUIRE( d == approx( 1.24 ) );
REQUIRE( d != approx( 1.25 ) );
I guess I misread this example.