diff options
author | Alyssa Wilk <alyssar@chromium.org> | 2017-08-28 16:10:12 -0400 |
---|---|---|
committer | Alyssa Wilk <alyssar@chromium.org> | 2017-08-28 16:10:12 -0400 |
commit | c00373320db8cfbd1524e73e7b2793a22ecb2672 (patch) | |
tree | fe20e7200424c65ab9acb8ff38ff1b2e86204ba6 /googlemock/test/gmock-matchers_test.cc | |
parent | a2803bc37dafdaad05b335e64a83aff03096a4ba (diff) | |
parent | b43bfcf49166599955ba3713952bc6c0e96b421b (diff) | |
download | googletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.tar.gz googletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.tar.bz2 googletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.zip |
Merge branch 'refs/heads/master' into flag-default
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f5ab7c81..fc867487 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -3588,10 +3588,15 @@ class AClass { // A getter that returns a reference to const. const std::string& s() const { return s_; } +#if GTEST_LANG_CXX11 + const std::string& s_ref() const & { return s_; } +#endif + void set_s(const std::string& new_s) { s_ = new_s; } // A getter that returns a reference to non-const. double& x() const { return x_; } + private: int n_; std::string s_; @@ -3635,6 +3640,21 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) { EXPECT_FALSE(m.Matches(a)); } +#if GTEST_LANG_CXX11 +// Tests that Property(&Foo::property, ...) works when property() is +// ref-qualified. +TEST(PropertyTest, WorksForRefQualifiedProperty) { + Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi")); + + AClass a; + a.set_s("hill"); + EXPECT_TRUE(m.Matches(a)); + + a.set_s("hole"); + EXPECT_FALSE(m.Matches(a)); +} +#endif + // Tests that Property(&Foo::property, ...) works when property() // returns a reference to non-const. TEST(PropertyTest, WorksForReferenceToNonConstProperty) { |