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

Split MessageInfo into its own header

This is first step towards splitting apart reporter implementation
and `catch_string.hpp`.
Commit
ed967fd7fcb0f1d995d11ebf1d7d4106d582d43c
Author
Martin Hořeňovský ·
Parents
7030d7740d4d

Files · Download .tar.gz

Changes

 src/CMakeLists.txt                                 |  2 ++
 src/catch2/catch_all.hpp                           |  1 +
 src/catch2/catch_message.cpp                       | 21 ---------------
 src/catch2/catch_message.hpp                       | 18 +------------
 .../interfaces/catch_interfaces_reporter.cpp       |  1 +
 .../interfaces/catch_interfaces_reporter.hpp       |  2 +-
 src/catch2/internal/catch_message_info.cpp         | 26 ++++++++++++++++++
 src/catch2/internal/catch_message_info.hpp         | 31 ++++++++++++++++++++++
 src/catch2/internal/catch_run_context.hpp          |  1 +
 9 files changed, 64 insertions(+), 39 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b6578f8b..ecabdb3f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -84,6 +84,7 @@ set(INTERNAL_HEADERS
     ${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
     ${SOURCES_DIR}/matchers/catch_matchers_vector.hpp
     ${SOURCES_DIR}/catch_message.hpp
+    ${SOURCES_DIR}/internal/catch_message_info.hpp
     ${SOURCES_DIR}/internal/catch_meta.hpp
     ${SOURCES_DIR}/internal/catch_option.hpp
     ${SOURCES_DIR}/internal/catch_output_redirect.hpp
@@ -151,6 +152,7 @@ set(IMPL_SOURCES
     ${SOURCES_DIR}/matchers/catch_matchers_string.cpp
     ${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
     ${SOURCES_DIR}/catch_message.cpp
+    ${SOURCES_DIR}/internal/catch_message_info.cpp
     ${SOURCES_DIR}/internal/catch_output_redirect.cpp
     ${SOURCES_DIR}/catch_registry_hub.cpp
     ${SOURCES_DIR}/internal/catch_combined_tu.cpp
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index c3f35500..e39204aa 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -56,6 +56,7 @@
 #include <catch2/internal/catch_fatal_condition_handler.hpp>
 #include <catch2/internal/catch_leak_detector.hpp>
 #include <catch2/internal/catch_list.hpp>
+#include <catch2/internal/catch_message_info.hpp>
 #include <catch2/internal/catch_meta.hpp>
 #include <catch2/internal/catch_option.hpp>
 #include <catch2/internal/catch_output_redirect.hpp>
diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp
index 08207ee7..3d66a5f4 100644
--- a/src/catch2/catch_message.cpp
+++ b/src/catch2/catch_message.cpp
@@ -16,27 +16,6 @@
 
 namespace Catch {
 
-    MessageInfo::MessageInfo(   StringRef const& _macroName,
-                                SourceLineInfo const& _lineInfo,
-                                ResultWas::OfType _type )
-    :   macroName( _macroName ),
-        lineInfo( _lineInfo ),
-        type( _type ),
-        sequence( ++globalCount )
-    {}
-
-    bool MessageInfo::operator==( MessageInfo const& other ) const {
-        return sequence == other.sequence;
-    }
-
-    bool MessageInfo::operator<( MessageInfo const& other ) const {
-        return sequence < other.sequence;
-    }
-
-    // This may need protecting if threading support is added
-    unsigned int MessageInfo::globalCount = 0;
-
-
     ////////////////////////////////////////////////////////////////////////////
 
     Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp
index 07c99bb0..26b314dd 100644
--- a/src/catch2/catch_message.hpp
+++ b/src/catch2/catch_message.hpp
@@ -11,6 +11,7 @@
 #include <catch2/internal/catch_result_type.hpp>
 #include <catch2/internal/catch_common.hpp>
 #include <catch2/internal/catch_stream.hpp>
+#include <catch2/internal/catch_message_info.hpp>
 #include <catch2/interfaces/catch_interfaces_capture.hpp>
 #include <catch2/catch_tostring.hpp>
 
@@ -19,23 +20,6 @@
 
 namespace Catch {
 
-    struct MessageInfo {
-        MessageInfo(    StringRef const& _macroName,
-                        SourceLineInfo const& _lineInfo,
-                        ResultWas::OfType _type );
-
-        StringRef macroName;
-        std::string message;
-        SourceLineInfo lineInfo;
-        ResultWas::OfType type;
-        unsigned int sequence;
-
-        bool operator == ( MessageInfo const& other ) const;
-        bool operator < ( MessageInfo const& other ) const;
-    private:
-        static unsigned int globalCount;
-    };
-
     struct MessageStream {
 
         template<typename T>
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index 7e538d38..f0e612e7 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -7,6 +7,7 @@
 
 #include <catch2/interfaces/catch_interfaces_reporter.hpp>
 #include <catch2/internal/catch_console_colour.hpp>
+#include <catch2/catch_message.hpp>
 #include <catch2/internal/catch_list.hpp>
 #include <catch2/internal/catch_text.hpp>
 #include <catch2/internal/catch_string_manip.hpp>
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index df47ef5c..01469999 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -14,7 +14,7 @@
 #include <catch2/catch_totals.hpp>
 #include <catch2/catch_test_case_info.hpp>
 #include <catch2/catch_assertion_result.hpp>
-#include <catch2/catch_message.hpp>
+#include <catch2/internal/catch_message_info.hpp>
 #include <catch2/internal/catch_option.hpp>
 #include <catch2/internal/catch_stringref.hpp>
 
diff --git a/src/catch2/internal/catch_message_info.cpp b/src/catch2/internal/catch_message_info.cpp
new file mode 100644
index 00000000..65d990ad
--- /dev/null
+++ b/src/catch2/internal/catch_message_info.cpp
@@ -0,0 +1,26 @@
+
+#include <catch2/internal/catch_message_info.hpp>
+
+namespace Catch {
+
+    MessageInfo::MessageInfo(   StringRef const& _macroName,
+                                SourceLineInfo const& _lineInfo,
+                                ResultWas::OfType _type )
+    :   macroName( _macroName ),
+        lineInfo( _lineInfo ),
+        type( _type ),
+        sequence( ++globalCount )
+    {}
+
+    bool MessageInfo::operator==( MessageInfo const& other ) const {
+        return sequence == other.sequence;
+    }
+
+    bool MessageInfo::operator<( MessageInfo const& other ) const {
+        return sequence < other.sequence;
+    }
+
+    // This may need protecting if threading support is added
+    unsigned int MessageInfo::globalCount = 0;
+
+} // end namespace Catch
diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp
new file mode 100644
index 00000000..b1af4565
--- /dev/null
+++ b/src/catch2/internal/catch_message_info.hpp
@@ -0,0 +1,31 @@
+#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
+#define CATCH_MESSAGE_INFO_HPP_INCLUDED
+
+#include <catch2/internal/catch_result_type.hpp>
+#include <catch2/internal/catch_common.hpp>
+#include <catch2/interfaces/catch_interfaces_capture.hpp>
+
+#include <string>
+
+namespace Catch {
+
+    struct MessageInfo {
+        MessageInfo(    StringRef const& _macroName,
+                        SourceLineInfo const& _lineInfo,
+                        ResultWas::OfType _type );
+
+        StringRef macroName;
+        std::string message;
+        SourceLineInfo lineInfo;
+        ResultWas::OfType type;
+        unsigned int sequence;
+
+        bool operator == ( MessageInfo const& other ) const;
+        bool operator < ( MessageInfo const& other ) const;
+    private:
+        static unsigned int globalCount;
+    };
+
+} // end namespace Catch
+
+#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index ea72dde0..bfbd8bcf 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -16,6 +16,7 @@
 #include <catch2/internal/catch_test_registry.hpp>
 #include <catch2/catch_test_case_info.hpp>
 #include <catch2/internal/catch_test_macro_impl.hpp>
+#include <catch2/catch_message.hpp>
 #include <catch2/catch_totals.hpp>
 #include <catch2/catch_test_spec.hpp>
 #include <catch2/internal/catch_test_case_tracker.hpp>