Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Added tests for using margin with Approx.

Commit
8c078997155a86b45fc2dcf66c571461ebf51348
Author
Martin Hořeňovský ·
Parents
d5c623b3b69d

Files · Download .tar.gz

Changes

 projects/SelfTest/ApproxTests.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp
index 8e7e33c2..14a8234e 100644
--- a/projects/SelfTest/ApproxTests.cpp
+++ b/projects/SelfTest/ApproxTests.cpp
@@ -141,6 +141,16 @@ TEST_CASE( "Approximate PI", "[Approx][PI]" )
     REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) );
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
+TEST_CASE( "Absolute margin", "[Approx]" ) {
+    REQUIRE( 104.0 != Approx(100.0) );
+    REQUIRE( 104.0 == Approx(100.0).margin(5) );
+    REQUIRE( 104.0 != Approx(100.0).margin(3) );
+    REQUIRE( 100.3 != Approx(100.0) );
+    REQUIRE( 100.3 == Approx(100.0).margin(0.5) );
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 #if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)