Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-05-10 16:44:27 +0200
committerMartin Hořeňovský2020-05-10 20:20:52 +0200
commited967fd7fcb0f1d995d11ebf1d7d4106d582d43c (patch)
tree158f20386c33958c08290e8e37a79875b03307a6 /src/catch2/internal
parent7030d7740d4d576149d5afb31b2f7668d02f8bdc (diff)
downloadcatch3-ed967fd7fcb0f1d995d11ebf1d7d4106d582d43c.tar.gz
Split MessageInfo into its own header
This is first step towards splitting apart reporter implementation and `catch_string.hpp`.
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_message_info.cpp26
-rw-r--r--src/catch2/internal/catch_message_info.hpp31
-rw-r--r--src/catch2/internal/catch_run_context.hpp1
3 files changed, 58 insertions, 0 deletions
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>