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

Remove "second argument" from result builder and assertion result

This is not quite complete removal (it doesn't pass approval tests),
but it should be representative of full perf improvements from doing so
Commit
0eb101e165df425a4f15bf5e8e8c371e3b790d01
Author
Martin Hořeňovský ·
Parents
dcab8a59716d

Files · Download .tar.gz

Changes

 include/internal/catch_assertionresult.h   |  4 +---
 include/internal/catch_assertionresult.hpp | 17 ++++++++---------
 include/internal/catch_capture.hpp         |  2 +-
 include/internal/catch_result_builder.h    |  3 +--
 include/internal/catch_result_builder.hpp  |  9 ++++-----
 5 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h
index 5d6c86d1..87e85990 100644
--- a/include/internal/catch_assertionresult.h
+++ b/include/internal/catch_assertionresult.h
@@ -43,14 +43,12 @@ namespace Catch {
         AssertionInfo(  char const * _macroName,
                         SourceLineInfo const& _lineInfo,
                         char const * _capturedExpression,
-                        ResultDisposition::Flags _resultDisposition,
-                        char const * _secondArg = "");
+                        ResultDisposition::Flags _resultDisposition);
 
         char const * macroName;
         SourceLineInfo lineInfo;
         char const * capturedExpression;
         ResultDisposition::Flags resultDisposition;
-        char const * secondArg;
     };
 
     struct AssertionResultData
diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp
index 2fa3373d..b4038ade 100644
--- a/include/internal/catch_assertionresult.hpp
+++ b/include/internal/catch_assertionresult.hpp
@@ -16,13 +16,11 @@ namespace Catch {
     AssertionInfo::AssertionInfo(   char const * _macroName,
                                     SourceLineInfo const& _lineInfo,
                                     char const * _capturedExpression,
-                                    ResultDisposition::Flags _resultDisposition,
-                                    char const * _secondArg)
+                                    ResultDisposition::Flags _resultDisposition)
     :   macroName( _macroName ),
         lineInfo( _lineInfo ),
         capturedExpression( _capturedExpression ),
-        resultDisposition( _resultDisposition ),
-        secondArg( _secondArg )
+        resultDisposition( _resultDisposition )
     {}
 
     AssertionResult::AssertionResult() {}
@@ -63,16 +61,17 @@ namespace Catch {
     }
 
     std::string AssertionResult::getExpression() const {
-        if( isFalseTest( m_info.resultDisposition ) )
-            return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+        if (isFalseTest(m_info.resultDisposition))
+            return '!' + std::string(m_info.capturedExpression);
         else
-            return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+            return std::string(m_info.capturedExpression);
     }
+
     std::string AssertionResult::getExpressionInMacro() const {
         if( m_info.macroName[0] == 0 )
-            return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
+            return std::string(m_info.capturedExpression);
         else
-            return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )";
+            return std::string(m_info.macroName) + "( " + m_info.capturedExpression + " )";
     }
 
     bool AssertionResult::hasExpandedExpression() const {
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index a6d25dad..968bf79e 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -107,7 +107,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
     do { \
-        Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
+        Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #matcher, resultDisposition); \
         if( __catchResult.allowThrows() ) \
             try { \
                 static_cast<void>(expr); \
diff --git a/include/internal/catch_result_builder.h b/include/internal/catch_result_builder.h
index 82494566..1e8bff52 100644
--- a/include/internal/catch_result_builder.h
+++ b/include/internal/catch_result_builder.h
@@ -37,8 +37,7 @@ namespace Catch {
         ResultBuilder(  char const* macroName,
                         SourceLineInfo const& lineInfo,
                         char const* capturedExpression,
-                        ResultDisposition::Flags resultDisposition,
-                        char const* secondArg = "" );
+                        ResultDisposition::Flags resultDisposition);
         ~ResultBuilder();
 
         template<typename T>
diff --git a/include/internal/catch_result_builder.hpp b/include/internal/catch_result_builder.hpp
index 510fbc3b..f3688de5 100644
--- a/include/internal/catch_result_builder.hpp
+++ b/include/internal/catch_result_builder.hpp
@@ -21,9 +21,8 @@ namespace Catch {
     ResultBuilder::ResultBuilder(   char const* macroName,
                                     SourceLineInfo const& lineInfo,
                                     char const* capturedExpression,
-                                    ResultDisposition::Flags resultDisposition,
-                                    char const* secondArg )
-    :   m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
+                                    ResultDisposition::Flags resultDisposition)
+    :   m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition),
         m_shouldDebugBreak( false ),
         m_shouldThrow( false ),
         m_guardException( false )
@@ -77,7 +76,7 @@ namespace Catch {
         assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
         AssertionResultData data = m_data;
         data.resultType = ResultWas::Ok;
-        data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
+        data.reconstructedExpression = m_assertionInfo.capturedExpression;
 
         std::string actualMessage = Catch::translateActiveException();
         if( !matcher.match( actualMessage ) ) {
@@ -149,7 +148,7 @@ namespace Catch {
     }
 
     void ResultBuilder::reconstructExpression( std::string& dest ) const {
-        dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
+        dest = m_assertionInfo.capturedExpression;
     }
 
     void ResultBuilder::setExceptionGuard() {