diff options
author | Abseil Team <absl-team@google.com> | 2020-12-08 12:37:32 -0500 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2020-12-08 19:15:35 -0500 |
commit | e5644f5f12ff3d5b2232dabc1c5ea272a52e8155 (patch) | |
tree | 170e3f0de02818b0c15709da473cfb6efdd7f0b6 /googlemock/test | |
parent | 8779937dd05016e3a96e477d2bb1f94947486605 (diff) | |
download | googletest-e5644f5f12ff3d5b2232dabc1c5ea272a52e8155.tar.gz googletest-e5644f5f12ff3d5b2232dabc1c5ea272a52e8155.zip |
Googletest export
Introduce a new `Address` matcher to gmock.
PiperOrigin-RevId: 346344591
Diffstat (limited to 'googlemock/test')
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 8084e29f..3ac16682 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -3787,6 +3787,46 @@ TEST(PointerTest, SmartPointerToConst) { EXPECT_FALSE(m.Matches(p)); } +TEST(AddressTest, NonConst) { + int n = 1; + const Matcher<int> m = Address(Eq(&n)); + + EXPECT_TRUE(m.Matches(n)); + + int other = 5; + + EXPECT_FALSE(m.Matches(other)); + + int& n_ref = n; + + EXPECT_TRUE(m.Matches(n_ref)); +} + +TEST(AddressTest, Const) { + const int n = 1; + const Matcher<int> m = Address(Eq(&n)); + + EXPECT_TRUE(m.Matches(n)); + + int other = 5; + + EXPECT_FALSE(m.Matches(other)); +} + +TEST(AddressTest, MatcherDoesntCopy) { + std::unique_ptr<int> n(new int(1)); + const Matcher<std::unique_ptr<int>> m = Address(Eq(&n)); + + EXPECT_TRUE(m.Matches(n)); +} + +TEST(AddressTest, Describe) { + Matcher<int> matcher = Address(_); + EXPECT_EQ("has address that is anything", Describe(matcher)); + EXPECT_EQ("does not have address that is anything", + DescribeNegation(matcher)); +} + MATCHER_P(FieldIIs, inner_matcher, "") { return ExplainMatchResult(inner_matcher, arg.i, result_listener); } |