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

Refactored duplicated code between acceptExpression() and acceptResult()

Commit
3eb41eed6dbfe0e4193ddeed9ef974a08632be45
Author
Phil Nash ·
Parents
4890a1d80a69

Files · Download .tar.gz

Changes

 internal/catch_runner_impl.hpp | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp
index 0593259f..4c528bc3 100644
--- a/internal/catch_runner_impl.hpp
+++ b/internal/catch_runner_impl.hpp
@@ -406,17 +406,7 @@ namespace Catch
         )
         {
             m_currentResult.setResultType( result );            
-            testEnded( m_currentResult );
-
-            bool ok = m_currentResult.ok();
-            m_currentResult = MutableResultInfo();
-            if( ok )
-                return ResultAction::None;
-            else if( shouldDebugBreak() )
-                return ResultAction::DebugFailed;
-            else
-                return ResultAction::Failed;
-            
+            return actOnCurrentResult();
         }
 
         ///////////////////////////////////////////////////////////////////////////
@@ -426,16 +416,7 @@ namespace Catch
         )
         {
             m_currentResult = resultInfo;
-            testEnded( m_currentResult );
-            
-            bool ok = m_currentResult.ok();
-            m_currentResult = MutableResultInfo();
-            if( ok )
-                return ResultAction::None;
-            else if( shouldDebugBreak() )
-                return ResultAction::DebugFailed;
-            else
-                return ResultAction::Failed;
+            return actOnCurrentResult();
         }
 
         ///////////////////////////////////////////////////////////////////////////
@@ -544,6 +525,22 @@ namespace Catch
         
     private:
         
+        ///////////////////////////////////////////////////////////////////////////
+        ResultAction::Value actOnCurrentResult
+        ()
+        {
+            testEnded( m_currentResult );
+            
+            bool ok = m_currentResult.ok();
+            m_currentResult = MutableResultInfo();
+            if( ok )
+                return ResultAction::None;
+            else if( shouldDebugBreak() )
+                return ResultAction::DebugFailed;
+            else
+                return ResultAction::Failed;
+        }
+
         ///////////////////////////////////////////////////////////////////////////
         void runCurrentTest
         (