This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 798665b45a7b7c67da6e939a8449b236ba3addb2
Author: James Peach <[email protected]>
AuthorDate: Fri May 17 13:39:47 2019 -0700

    Added `CHECK_CONTAINS` and `CHECK_NOT_CONTAINS` macros.
    
    Added a simple `CHECK_CONTAINS` and `CHECK_NOT_CONTAINS` to replace
    checks of the form `CHECK(foo.contains(bar))`. These macros format
    the value of the key in their failure message to assist debugging.
    
    Review: https://reviews.apache.org/r/70661/
---
 3rdparty/stout/include/stout/check.hpp | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/3rdparty/stout/include/stout/check.hpp 
b/3rdparty/stout/include/stout/check.hpp
index 7651150..6608897 100644
--- a/3rdparty/stout/include/stout/check.hpp
+++ b/3rdparty/stout/include/stout/check.hpp
@@ -289,4 +289,26 @@ struct _CheckFatal
   std::ostringstream out;
 };
 
+
+// Check on whether some container (that supports the contains()
+// member function) contains the given key. This prints a message
+// of the form:
+//
+// Check failed: $ContainerName does not contain $Value
+#define CHECK_CONTAINS(container, key)                                    \
+  if (!(container).contains(key))                                         \
+    google::LogMessageFatal(__FILE__, __LINE__).stream()                  \
+      << "Check failed: "  << #container << " does not contain " << (key) \
+
+
+// Check on whether some container (that supports the contains()
+// member function) does not contain the given key. This prints
+// a message of the form:
+//
+// Check failed: $ContainerName already contains $Value
+#define CHECK_NOT_CONTAINS(container, key)                                \
+  if ((container).contains(key))                                          \
+    google::LogMessageFatal(__FILE__, __LINE__).stream()                  \
+      << "Check failed: "  << #container << " already contains " << (key) \
+
 #endif // __STOUT_CHECK_HPP__

Reply via email to