summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-09-15 04:56:58 (GMT)
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-09-15 04:56:58 (GMT)
commit345d9ebf30ccc2747c4e4c224b95fd8406093e29 (patch)
tree661b65a6a11d7f955b9888d8125f68e91a782cba
parentdac3e879c56a50696a36f53e1e5e353e48fa665f (diff)
downloadgoogletest-345d9ebf30ccc2747c4e4c224b95fd8406093e29.zip
googletest-345d9ebf30ccc2747c4e4c224b95fd8406093e29.tar.gz
googletest-345d9ebf30ccc2747c4e4c224b95fd8406093e29.tar.bz2
Implements GTEST_ASSERT_XY as alias of ASSERT_XY.
-rw-r--r--include/gtest/gtest.h39
-rw-r--r--test/gtest_unittest.cc35
2 files changed, 68 insertions, 6 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 334a52d..71eccac 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -1799,21 +1799,48 @@ const T* TestWithParam<T>::parameter_ = NULL;
#define EXPECT_GT(val1, val2) \
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
-#define ASSERT_EQ(expected, actual) \
+#define GTEST_ASSERT_EQ(expected, actual) \
ASSERT_PRED_FORMAT2(::testing::internal:: \
EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
expected, actual)
-#define ASSERT_NE(val1, val2) \
+#define GTEST_ASSERT_NE(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
-#define ASSERT_LE(val1, val2) \
+#define GTEST_ASSERT_LE(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
-#define ASSERT_LT(val1, val2) \
+#define GTEST_ASSERT_LT(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
-#define ASSERT_GE(val1, val2) \
+#define GTEST_ASSERT_GE(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
-#define ASSERT_GT(val1, val2) \
+#define GTEST_ASSERT_GT(val1, val2) \
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
+// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
+// ASSERT_XY(), which clashes with some users' own code.
+
+#if !GTEST_DONT_DEFINE_ASSERT_EQ
+#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_NE
+#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_LE
+#define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_LT
+#define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_GE
+#define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
+#endif
+
+#if !GTEST_DONT_DEFINE_ASSERT_GT
+#define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
+#endif
+
// C String Comparisons. All tests treat NULL and any non-NULL string
// as different. Two NULLs are equal.
//
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 5eaa2af..8e3e7e6 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -6866,6 +6866,41 @@ GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST.
// GTEST_FAIL is the same as FAIL.
EXPECT_FATAL_FAILURE(GTEST_FAIL() << "An expected failure",
"An expected failure");
+
+ // GTEST_ASSERT_XY is the same as ASSERT_XY.
+
+ GTEST_ASSERT_EQ(0, 0);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(0, 1) << "An expected failure",
+ "An expected failure");
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(1, 0) << "An expected failure",
+ "An expected failure");
+
+ GTEST_ASSERT_NE(0, 1);
+ GTEST_ASSERT_NE(1, 0);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_NE(0, 0) << "An expected failure",
+ "An expected failure");
+
+ GTEST_ASSERT_LE(0, 0);
+ GTEST_ASSERT_LE(0, 1);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_LE(1, 0) << "An expected failure",
+ "An expected failure");
+
+ GTEST_ASSERT_LT(0, 1);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(0, 0) << "An expected failure",
+ "An expected failure");
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(1, 0) << "An expected failure",
+ "An expected failure");
+
+ GTEST_ASSERT_GE(0, 0);
+ GTEST_ASSERT_GE(1, 0);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_GE(0, 1) << "An expected failure",
+ "An expected failure");
+
+ GTEST_ASSERT_GT(1, 0);
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(0, 1) << "An expected failure",
+ "An expected failure");
+ EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(1, 1) << "An expected failure",
+ "An expected failure");
}
// Tests for internal utilities necessary for implementation of the universal