mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 04:07:10 +01:00 
			
		
		
		
	Made Approx a little more forgiving (to 100& epsilon of float) and added some more tests for it
This commit is contained in:
		| @@ -41,5 +41,44 @@ TEST_CASE | ||||
|      | ||||
|     REQUIRE( d != Approx( 1.231 ) ); | ||||
|     REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ); | ||||
| //    REQUIRE( d != Approx( 1.232 ).epsilon( 0.1 ) ); | ||||
| } | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| TEST_CASE | ||||
| ( | ||||
|     "./succeeding/Approx/float",  | ||||
|     "Approximate comparisons with floats" | ||||
| ) | ||||
| { | ||||
|     REQUIRE( 1.23f == Approx( 1.23f ) ); | ||||
|     REQUIRE( 0.0f == Approx( 0.0f ) ); | ||||
| } | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| TEST_CASE | ||||
| ( | ||||
|     "./succeeding/Approx/int",  | ||||
|     "Approximate comparisons with ints" | ||||
| ) | ||||
| { | ||||
|     REQUIRE( 1 == Approx( 1 ) ); | ||||
|     REQUIRE( 0 == Approx( 0 ) ); | ||||
| } | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| TEST_CASE | ||||
| ( | ||||
|     "./succeeding/Approx/mixed",  | ||||
|     "Approximate comparisons with mixed numeric types" | ||||
| ) | ||||
| { | ||||
|     const double dZero = 0; | ||||
|     const double dSmall = 0.00001; | ||||
|     const double dMedium = 1.234; | ||||
|      | ||||
|     REQUIRE( 1.0f == Approx( 1 ) ); | ||||
|     REQUIRE( 0 == Approx( dZero) ); | ||||
|     REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) ); | ||||
|     REQUIRE( 1.234f == Approx( dMedium ) ); | ||||
|     REQUIRE( dMedium == Approx( 1.234f ) ); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash