Add float/int literal for Approx

This commit is contained in:
Henry Schreiner
2018-05-21 15:42:40 +02:00
committed by Henry Fredrick Schreiner
parent df0b0e64e1
commit 77230e69ad
7 changed files with 156 additions and 8 deletions

View File

@@ -33,8 +33,20 @@ namespace { namespace ApproxTests {
#endif
using namespace Catch::literals;
///////////////////////////////////////////////////////////////////////////////
TEST_CASE( "A comparison that uses literals instead of the normal constructor", "[Approx]" ) {
double d = 1.23;
REQUIRE( d == 1.23_a );
REQUIRE( d != 1.22_a );
REQUIRE( -d == -1.23_a );
REQUIRE( d == 1.2_a .epsilon(.1));
REQUIRE( d != 1.2_a .epsilon(.001));
}
TEST_CASE( "Some simple comparisons between doubles", "[Approx]" ) {
double d = 1.23;
@@ -42,6 +54,9 @@ TEST_CASE( "Some simple comparisons between doubles", "[Approx]" ) {
REQUIRE( d != Approx( 1.22 ) );
REQUIRE( d != Approx( 1.24 ) );
REQUIRE( d == 1.23_a );
REQUIRE( d != 1.22_a );
REQUIRE( Approx( d ) == 1.23 );
REQUIRE( Approx( d ) != 1.22 );
REQUIRE( Approx( d ) != 1.24 );