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

Fixed exception check regression

Commit
0dc4508d720234c2c2195b519a7716ff9a28c560
Author
Phil Nash ·
Parents
b82624395640

Files · Download .tar.gz

Changes

 Test/TestMain.cpp          |  2 +-
 catch.hpp                  |  4 ++--
 internal/catch_capture.hpp | 33 ++++++++++++++++++++++-----------
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/Test/TestMain.cpp b/Test/TestMain.cpp
index cb6d327f..ebabb8d9 100644
--- a/Test/TestMain.cpp
+++ b/Test/TestMain.cpp
@@ -53,7 +53,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
         {
             runner.runMatching( "./failing/*" );        
             CHECK( runner.getSuccessCount() == 0 );
-            CHECK( runner.getFailureCount() == 54 );
+            CHECK( runner.getFailureCount() == 55 );
         }
     }
 }
diff --git a/catch.hpp b/catch.hpp
index e02ed24d..f781d319 100644
--- a/catch.hpp
+++ b/catch.hpp
@@ -36,14 +36,14 @@
 
 #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, true, "REQUIRE_THROWS" )
 #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, true, "REQUIRE_THROWS_AS" )
-#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_THROWS_AS( expr, Catch::DummyExceptionType_DontUse, true, true, "REQUIRE_NOTHROW" )
+#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "REQUIRE_NOTHROW" )
 
 #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" )
 #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" )
 
 #define CHECK_THROWS( expr )  INTERNAL_CATCH_THROWS( expr, ..., false. false, "CHECK_THROWS" )
 #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, false, "CHECK_THROWS_AS" )
-#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_THROWS_AS( expr, Catch::DummyExceptionType_DontUse, true, false, "CHECK_NOTHROW" )
+#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CHECK_NOTHROW" )
 
 #define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "INFO" )
 #define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "WARN" )
diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp
index cf27c1aa..d970b20c 100644
--- a/internal/catch_capture.hpp
+++ b/internal/catch_capture.hpp
@@ -548,31 +548,42 @@ inline bool isTrue
 #define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
     Catch::Hub::getResultCapture().acceptExpression( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr );
 
+///////////////////////////////////////////////////////////////////////////////
+#define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \
+    try \
+    { \
+        using namespace Catch; \
+        expr; \
+        Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \
+    } \
+    catch( ... ) \
+    { \
+        using namespace Catch; \
+        Hub::getResultCapture().acceptExpression( ResultBuilder(  __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \
+    }
+
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_THROWS( expr, exceptionType, nothrow, stopOnFailure, macroName ) \
     try \
     { \
         using namespace Catch; \
         expr; \
-        ResultWas::OfType resultType = ( nothrow ) ? ResultWas::Ok : ResultWas::DidntThrowException; \
-        Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( resultType ) ); \
+        Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::DidntThrowException ) ); \
     } \
     catch( exceptionType ) \
     { \
         using namespace Catch; \
-        ResultWas::OfType resultType = ( nothrow ) ? ResultWas::ThrewException : ResultWas::Ok; \
-        Hub::getResultCapture().acceptExpression( ResultBuilder(  __FILE__, __LINE__, macroName, #expr ).setResultType( resultType ) ); \
+        Hub::getResultCapture().acceptExpression( ResultBuilder(  __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::Ok ) ); \
     }
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, nothrow, stopOnFailure, macroName ) \
-INTERNAL_CATCH_THROWS( expr, exceptionType, nothrow, stopOnFailure, macroName ) \
-catch( ... ) \
-{ \
-    using namespace Catch; \
-    ResultWas::OfType resultType = ( nothrow ) ? ResultWas::ThrewException : ResultWas::Ok; \
-    Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( resultType ) ); \
-}
+    INTERNAL_CATCH_THROWS( expr, exceptionType, nothrow, stopOnFailure, macroName ) \
+    catch( ... ) \
+    { \
+        using namespace Catch; \
+        Hub::getResultCapture().acceptExpression( ResultBuilder( __FILE__, __LINE__, macroName, #expr ).setResultType( ResultWas::ThrewException ) ); \
+    }
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_MSG( reason, resultType, stopOnFailure, macroName ) \