Repository: mesos
Updated Branches:
  refs/heads/master d5e905361 -> 0d4548cb6


Added EXPECT_SOME_NE to stout gtest.

Review: https://reviews.apache.org/r/20291


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0d4548cb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0d4548cb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0d4548cb

Branch: refs/heads/master
Commit: 0d4548cb6e39d988c1c33f38b4f6b8e072785f51
Parents: d5e9053
Author: Jie Yu <[email protected]>
Authored: Fri Apr 11 10:24:51 2014 -0700
Committer: Jie Yu <[email protected]>
Committed: Mon Apr 14 13:36:34 2014 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/gtest.hpp      | 33 ++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0d4548cb/3rdparty/libprocess/3rdparty/stout/include/stout/gtest.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/gtest.hpp 
b/3rdparty/libprocess/3rdparty/stout/include/stout/gtest.hpp
index ea284d7..7c27513 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/gtest.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/gtest.hpp
@@ -93,6 +93,31 @@ template <typename T1, typename T2>
 }
 
 
+template <typename T1, typename T2>
+::testing::AssertionResult AssertSomeNe(
+    const char* notExpectedExpr,
+    const char* actualExpr,
+    const T1& notExpected,
+    const T2& actual) // Duck typing!
+{
+  const ::testing::AssertionResult result = AssertSome(actualExpr, actual);
+
+  if (result) {
+    if (notExpected == actual.get()) {
+      return ::testing::AssertionFailure()
+        << "    Value of: (" << actualExpr << ").get()\n"
+        << "      Actual: " << ::testing::PrintToString(actual.get()) << "\n"
+        << "Not expected: " << notExpectedExpr << "\n"
+        << "    Which is: " << ::testing::PrintToString(notExpected);
+    } else {
+      return ::testing::AssertionSuccess();
+    }
+  }
+
+  return result;
+}
+
+
 #define ASSERT_SOME(actual)                     \
   ASSERT_PRED_FORMAT1(AssertSome, actual)
 
@@ -109,6 +134,14 @@ template <typename T1, typename T2>
   EXPECT_PRED_FORMAT2(AssertSomeEq, expected, actual)
 
 
+#define ASSERT_SOME_NE(notExpected, actual)             \
+  ASSERT_PRED_FORMAT2(AssertSomeNe, notExpected, actual)
+
+
+#define EXPECT_SOME_NE(notExpected, actual)             \
+  EXPECT_PRED_FORMAT2(AssertSomeNe, notExpected, actual)
+
+
 #define ASSERT_SOME_TRUE(actual)                        \
   ASSERT_PRED_FORMAT2(AssertSomeEq, true, actual)
 

Reply via email to