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

made CHECK/ REQUIRE into block statements

Placed the contents of the macros into do{…}while(0) so they can be used as statements (e.g. after an if() with no braces).
Also means they now require the closing ;
Commit
f52bd35e2f9bf6e2f38a1f2a842319f4362d61bc
Author
Phil Nash ·
Parents
918046aaf1ed

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index d19f4c24..2c44ae57 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -684,20 +684,15 @@ inline bool isTrue
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
-    try \
-    { \
+    do{ try{ \
         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr, isNot )->*expr ), stopOnFailure ); \
         if( Catch::isTrue( false ) ){ bool internal_catch_dummyResult = ( expr ); Catch::isTrue( internal_catch_dummyResult ); } \
-    } \
-    catch( Catch::TestFailureException& ) \
-    { \
+    }catch( Catch::TestFailureException& ){ \
         throw; \
-    } \
-    catch( ... ) \
-    { \
+    } catch( ... ){ \
         INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( __FILE__, __LINE__, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \
         throw; \
-    }
+    }}while(0)
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_IF( expr, isNot, stopOnFailure, macroName ) \