summaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-matchers-comparisons_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock/test/gmock-matchers-comparisons_test.cc')
-rw-r--r--googlemock/test/gmock-matchers-comparisons_test.cc52
1 files changed, 39 insertions, 13 deletions
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index 63af04e..eb8f3f6 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -45,7 +45,9 @@ namespace testing {
namespace gmock_matchers_test {
namespace {
-TEST(MonotonicMatcherTest, IsPrintable) {
+INSTANTIATE_GTEST_MATCHER_TEST_P(MonotonicMatcherTest);
+
+TEST_P(MonotonicMatcherTestP, IsPrintable) {
stringstream ss;
ss << GreaterThan(5);
EXPECT_EQ("is > 5", ss.str());
@@ -130,6 +132,8 @@ TEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) {
EXPECT_EQ("value % 2 == 1", Explain(m, 3));
}
+INSTANTIATE_GTEST_MATCHER_TEST_P(MatcherTest);
+
// Tests default-constructing a matcher.
TEST(MatcherTest, CanBeDefaultConstructed) { Matcher<double> m; }
@@ -192,7 +196,7 @@ TEST(MatcherTest, CanDescribeItself) {
}
// Tests Matcher<T>::MatchAndExplain().
-TEST(MatcherTest, MatchAndExplain) {
+TEST_P(MatcherTestP, MatchAndExplain) {
Matcher<int> m = GreaterThan(0);
StringMatchResultListener listener1;
EXPECT_TRUE(m.MatchAndExplain(42, &listener1));
@@ -376,11 +380,18 @@ TEST(MakePolymorphicMatcherTest, ConstructsMatcherUsingNewAPI) {
EXPECT_EQ("% 2 == 0", Explain(m2, '\x42'));
}
+INSTANTIATE_GTEST_MATCHER_TEST_P(MatcherCastTest);
+
// Tests that MatcherCast<T>(m) works when m is a polymorphic matcher.
-TEST(MatcherCastTest, FromPolymorphicMatcher) {
- Matcher<int> m = MatcherCast<int>(Eq(5));
- EXPECT_TRUE(m.Matches(5));
- EXPECT_FALSE(m.Matches(6));
+TEST_P(MatcherCastTestP, FromPolymorphicMatcher) {
+ Matcher<int16_t> m;
+ if (use_gtest_matcher_) {
+ m = MatcherCast<int16_t>(GtestGreaterThan(int64_t{5}));
+ } else {
+ m = MatcherCast<int16_t>(Gt(int64_t{5}));
+ }
+ EXPECT_TRUE(m.Matches(6));
+ EXPECT_FALSE(m.Matches(4));
}
// For testing casting matchers between compatible types.
@@ -591,10 +602,17 @@ class Derived : public Base {
class OtherDerived : public Base {};
+INSTANTIATE_GTEST_MATCHER_TEST_P(SafeMatcherCastTest);
+
// Tests that SafeMatcherCast<T>(m) works when m is a polymorphic matcher.
-TEST(SafeMatcherCastTest, FromPolymorphicMatcher) {
- Matcher<char> m2 = SafeMatcherCast<char>(Eq(32));
- EXPECT_TRUE(m2.Matches(' '));
+TEST_P(SafeMatcherCastTestP, FromPolymorphicMatcher) {
+ Matcher<char> m2;
+ if (use_gtest_matcher_) {
+ m2 = SafeMatcherCast<char>(GtestGreaterThan(32));
+ } else {
+ m2 = SafeMatcherCast<char>(Gt(32));
+ }
+ EXPECT_TRUE(m2.Matches('A'));
EXPECT_FALSE(m2.Matches('\n'));
}
@@ -1319,13 +1337,15 @@ TEST(HasSubstrTest, CanDescribeSelf) {
EXPECT_EQ("has substring \"foo\\n\\\"\"", Describe(m));
}
+INSTANTIATE_GTEST_MATCHER_TEST_P(KeyTest);
+
TEST(KeyTest, CanDescribeSelf) {
Matcher<const pair<std::string, int>&> m = Key("foo");
EXPECT_EQ("has a key that is equal to \"foo\"", Describe(m));
EXPECT_EQ("doesn't have a key that is equal to \"foo\"", DescribeNegation(m));
}
-TEST(KeyTest, ExplainsResult) {
+TEST_P(KeyTestP, ExplainsResult) {
Matcher<pair<int, bool>> m = Key(GreaterThan(10));
EXPECT_EQ("whose first field is a value which is 5 less than 10",
Explain(m, make_pair(5, true)));
@@ -1346,6 +1366,8 @@ TEST(KeyTest, WorksWithMoveOnly) {
EXPECT_THAT(p, Key(Eq(nullptr)));
}
+INSTANTIATE_GTEST_MATCHER_TEST_P(PairTest);
+
template <size_t I>
struct Tag {};
@@ -1434,7 +1456,7 @@ TEST(PairTest, CanDescribeSelf) {
DescribeNegation(m2));
}
-TEST(PairTest, CanExplainMatchResultTo) {
+TEST_P(PairTestP, CanExplainMatchResultTo) {
// If neither field matches, Pair() should explain about the first
// field.
const Matcher<pair<int, int>> m = Pair(GreaterThan(0), GreaterThan(0));
@@ -1522,6 +1544,8 @@ TEST(PairTest, InsideContainsUsingMap) {
EXPECT_THAT(container, Not(Contains(Pair(3, _))));
}
+INSTANTIATE_GTEST_MATCHER_TEST_P(FieldsAreTest);
+
TEST(FieldsAreTest, MatchesCorrectly) {
std::tuple<int, std::string, double> p(25, "foo", .5);
@@ -1547,7 +1571,7 @@ TEST(FieldsAreTest, CanDescribeSelf) {
DescribeNegation(m1));
}
-TEST(FieldsAreTest, CanExplainMatchResultTo) {
+TEST_P(FieldsAreTestP, CanExplainMatchResultTo) {
// The first one that fails is the one that gives the error.
Matcher<std::tuple<int, int, int>> m =
FieldsAre(GreaterThan(0), GreaterThan(0), GreaterThan(0));
@@ -2261,7 +2285,9 @@ TEST(ExplainMatchResultTest, AllOf_True_True_2) {
EXPECT_EQ("", Explain(m, 2));
}
-TEST(ExplainmatcherResultTest, MonomorphicMatcher) {
+INSTANTIATE_GTEST_MATCHER_TEST_P(ExplainmatcherResultTest);
+
+TEST_P(ExplainmatcherResultTestP, MonomorphicMatcher) {
const Matcher<int> m = GreaterThan(5);
EXPECT_EQ("which is 1 more than 5", Explain(m, 6));
}