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

Renamed DebugBreak to avoid collision and implemented in terms of __debugbreak() on Windows

Commit
dea778138ee2313a8dbb9fd0b3459e9166149aac
Author
Phil Nash ·
Parents
7d65a8c61224

Files · Download .tar.gz

Changes

 internal/catch_capture.hpp  |  2 +-
 internal/catch_debugger.hpp | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp
index b647c8e1..047a1ac8 100644
--- a/internal/catch_capture.hpp
+++ b/internal/catch_capture.hpp
@@ -443,7 +443,7 @@ inline bool isTrue
 #define INTERNAL_CATCH_ACCEPT_RESULT( result, stopOnFailure ) \
     if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptResult( result )  ) \
     { \
-        if( action == Catch::ResultAction::DebugFailed ) DebugBreak(); \
+        if( action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \
         if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \
     }
 
diff --git a/internal/catch_debugger.hpp b/internal/catch_debugger.hpp
index b79ad530..5d867aa1 100644
--- a/internal/catch_debugger.hpp
+++ b/internal/catch_debugger.hpp
@@ -8,8 +8,7 @@
  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  *
- * Provides a DebugBreak() macro for platforms other than Windows
- * (currently only Macs are supported)
+ * Provides a BreakIntoDebugger() macro for Windows and Mac (so far)
  */
 
 #ifndef TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
@@ -68,21 +67,22 @@
     // http://cocoawithlove.com/2008/03/break-into-debugger.html
     #ifdef DEBUG
         #if defined(__ppc64__) || defined(__ppc__)
-            #define DebugBreak() \
+            #define BreakIntoDebugger() \
             if( Catch::AmIBeingDebugged() ) \
             { \
             __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
             : : : "memory","r0","r3","r4" ); \
             }
         #else
-            #define DebugBreak() if( Catch::AmIBeingDebugged() ) {__asm__("int $3\n" : : );}
+            #define BreakIntoDebugger() if( Catch::AmIBeingDebugged() ) {__asm__("int $3\n" : : );}
         #endif
     #endif
 
-#endif
-
-#ifndef DebugBreak
-    inline void DebugBreak(){}
+#elif defined(__WIN32__) && defined(_MSC_VER)

+   extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();

+   #define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); }

+#else
+	   inline void BreakIntoDebugger(){}
 #endif
 
 inline void writeToDebugConsole( const std::string& text )
@@ -97,4 +97,4 @@ inline void writeToDebugConsole( const std::string& text )
 //#endif
 }
 
-#endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
\ No newline at end of file
+#endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED