diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-07-20 11:46:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 11:46:26 -0400 |
commit | 2a151c93c180ac765c27c5f2e37af9366abd4d55 (patch) | |
tree | 0fae2f56aba6c1275fdca61d4ef6f2131f2e7f12 | |
parent | c62c79432bd23762a99a6658380fd202f858d7a9 (diff) | |
parent | a02af2f689426aa9622b06643f53ed27fa6dc8a5 (diff) | |
download | googletest-2a151c93c180ac765c27c5f2e37af9366abd4d55.tar.gz googletest-2a151c93c180ac765c27c5f2e37af9366abd4d55.tar.bz2 googletest-2a151c93c180ac765c27c5f2e37af9366abd4d55.zip |
Merge pull request #1676 from gennadiycivil/master
code merge
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 14 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 5 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 4 |
3 files changed, 18 insertions, 5 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 7fd57870..eb096135 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &, property, MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher))); } + +// Three-argument form for reference-qualified member functions. +template <typename Class, typename PropertyType, typename PropertyMatcher> +inline PolymorphicMatcher<internal::PropertyMatcher< + Class, PropertyType, PropertyType (Class::*)() const &> > +Property(const std::string& property_name, + PropertyType (Class::*property)() const &, + const PropertyMatcher& matcher) { + return MakePolymorphicMatcher( + internal::PropertyMatcher<Class, PropertyType, + PropertyType (Class::*)() const &>( + property_name, property, + MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher))); +} #endif // Creates a matcher that matches an object iff the result of applying diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f9dfd3c1..9f1a5471 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -2795,7 +2795,6 @@ TEST(ElementsAreTest, HugeMatcherUnordered) { #endif // GTEST_LANG_CXX11 - // Tests that AnyOf(m1, ..., mn) describes itself properly. TEST(AnyOfTest, CanDescribeSelf) { Matcher<int> m; @@ -4239,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) { // ref-qualified. TEST(PropertyTest, WorksForRefQualifiedProperty) { Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi")); + Matcher<const AClass&> m_with_name = + Property("s", &AClass::s_ref, StartsWith("hi")); AClass a; a.set_s("hill"); EXPECT_TRUE(m.Matches(a)); + EXPECT_TRUE(m_with_name.Matches(a)); a.set_s("hole"); EXPECT_FALSE(m.Matches(a)); + EXPECT_FALSE(m_with_name.Matches(a)); } #endif diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index bc35c34c..dbe703b5 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -522,11 +522,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // !defined(GTEST_HAS_STD_STRING) #ifndef GTEST_HAS_GLOBAL_STRING -// The user didn't tell us whether ::string is available, so we need -// to figure it out. - # define GTEST_HAS_GLOBAL_STRING 0 - #endif // GTEST_HAS_GLOBAL_STRING #ifndef GTEST_HAS_STD_WSTRING |