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

Deprecate comparison operators on MessageInfo

Commit
98b4bbb35efc3937b24e1de5559c974bd2578a14
Author
Martin Hořeňovský ·
Parents
8c3ffe05e129

Files · Download .tar.gz

Changes

 src/catch2/internal/catch_message_info.hpp |  3 +++
 src/catch2/internal/catch_run_context.cpp  | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp
index 1ef43fda..ded098f5 100644
--- a/src/catch2/internal/catch_message_info.hpp
+++ b/src/catch2/internal/catch_message_info.hpp
@@ -8,6 +8,7 @@
 #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
 #define CATCH_MESSAGE_INFO_HPP_INCLUDED
 
+#include <catch2/internal/catch_deprecation_macro.hpp>
 #include <catch2/internal/catch_result_type.hpp>
 #include <catch2/internal/catch_source_line_info.hpp>
 #include <catch2/internal/catch_stringref.hpp>
@@ -27,9 +28,11 @@ namespace Catch {
         ResultWas::OfType type;
         unsigned int sequence;
 
+        DEPRECATED( "Explicitly use the 'sequence' member instead" )
         bool operator == (MessageInfo const& other) const {
             return sequence == other.sequence;
         }
+        DEPRECATED( "Explicitly use the 'sequence' member instead" )
         bool operator < (MessageInfo const& other) const {
             return sequence < other.sequence;
         }
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index ae170d1f..a6b99c02 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -439,8 +439,14 @@ namespace Catch {
         m_messages.push_back(message);
     }
 
-    void RunContext::popScopedMessage(MessageInfo const & message) {
-        m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end());
+    void RunContext::popScopedMessage( MessageInfo const& message ) {
+        m_messages.erase(
+            std::remove_if( m_messages.begin(),
+                            m_messages.end(),
+                            [id = message.sequence]( MessageInfo const& msg ) {
+                                return msg.sequence == id;
+                            } ),
+            m_messages.end() );
     }
 
     void RunContext::emplaceUnscopedMessage( MessageBuilder&& builder ) {