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

Use StringRef on fatal error path

So far the fatal error path only uses string literals, so this removes
an allocation from that context
Commit
40209d1ae0fefc6ee4144be6bcb1366ef1444506
Author
Martin Hořeňovský ·
Parents
4e852672033a

Files · Download .tar.gz

Changes

 include/internal/catch_interfaces_capture.h | 4 +++-
 include/internal/catch_run_context.cpp      | 2 +-
 include/internal/catch_run_context.h        | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h
index d153a8bc..5b370114 100644
--- a/include/internal/catch_interfaces_capture.h
+++ b/include/internal/catch_interfaces_capture.h
@@ -10,6 +10,8 @@
 
 #include <string>
 
+#include "catch_stringref.h"
+
 namespace Catch {
 
     class AssertionResult;
@@ -43,7 +45,7 @@ namespace Catch {
 
         virtual void exceptionEarlyReported() = 0;
 
-        virtual void handleFatalErrorCondition( std::string const& message ) = 0;
+        virtual void handleFatalErrorCondition( StringRef message ) = 0;
 
         virtual bool lastAssertionPassed() = 0;
         virtual void assertionPassed() = 0;
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index b034ec62..11b85b24 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -208,7 +208,7 @@ namespace Catch {
         m_shouldReportUnexpected = false;
     }
 
-    void RunContext::handleFatalErrorCondition(std::string const & message) {
+    void RunContext::handleFatalErrorCondition( StringRef message ) {
         // First notify reporter that bad things happened
         m_reporter->fatalErrorEncountered(message);
 
diff --git a/include/internal/catch_run_context.h b/include/internal/catch_run_context.h
index 64314cb2..3f238171 100644
--- a/include/internal/catch_run_context.h
+++ b/include/internal/catch_run_context.h
@@ -100,7 +100,7 @@ namespace Catch {
 
         void exceptionEarlyReported() override;
 
-        void handleFatalErrorCondition(std::string const& message) override;
+        void handleFatalErrorCondition( StringRef message ) override;
 
         bool lastAssertionPassed() override;