mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Add float/int literal for Approx
This commit is contained in:
		 Henry Schreiner
					Henry Schreiner
				
			
				
					committed by
					
						 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
			
				
	
			
			
			 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
						parent
						
							d6c7392b24
						
					
				
				
					commit
					283e2e6d41
				
			| @@ -33,8 +33,21 @@ 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) ); | ||||
|     REQUIRE( d == 1_a .epsilon(.3) ); | ||||
| } | ||||
|  | ||||
| TEST_CASE( "Some simple comparisons between doubles", "[Approx]" ) { | ||||
|     double d = 1.23; | ||||
|  | ||||
| @@ -42,6 +55,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