mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-26 14:35:38 +02:00
Add float/int literal for Approx
This commit is contained in:

committed by
Henry Fredrick Schreiner

parent
df0b0e64e1
commit
77230e69ad
@@ -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 );
|
||||
|
Reference in New Issue
Block a user