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

Stop recounting constant string's length on each passed assertion

Commit
d09fe4459d0ed1174383a173a9bb50b028fe0d9e
Author
Martin Hořeňovský ·
Parents
e484236825ef

Files · Download .tar.gz

Changes

 include/internal/catch_run_context.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 005b1af2..6748d3e0 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -8,6 +8,8 @@
 #include <algorithm>
 #include <sstream>
 
+static auto const& defaultExpression = "{Unknown expression after the reported line}";
+
 namespace Catch {
 
     StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString)
@@ -253,8 +255,8 @@ namespace Catch {
 
     void RunContext::assertionPassed() {
         ++m_totals.assertions.passed;
-        m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}";
-        m_lastAssertionInfo.macroName = "";
+        m_lastAssertionInfo.capturedExpression = StringRef(defaultExpression, sizeof(defaultExpression) - 1);
+        m_lastAssertionInfo.macroName = StringRef("", 0);
     }
 
     void RunContext::assertionRun() {