Merge pull request #1676 from gennadiycivil/master

code merge
This commit is contained in:
Gennadiy Civil 2018-07-20 11:46:26 -04:00 committed by GitHub
commit 2a151c93c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &,
property, property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher))); 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 #endif
// Creates a matcher that matches an object iff the result of applying // Creates a matcher that matches an object iff the result of applying

View File

@ -2795,7 +2795,6 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
// Tests that AnyOf(m1, ..., mn) describes itself properly. // Tests that AnyOf(m1, ..., mn) describes itself properly.
TEST(AnyOfTest, CanDescribeSelf) { TEST(AnyOfTest, CanDescribeSelf) {
Matcher<int> m; Matcher<int> m;
@ -4239,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
// ref-qualified. // ref-qualified.
TEST(PropertyTest, WorksForRefQualifiedProperty) { TEST(PropertyTest, WorksForRefQualifiedProperty) {
Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi")); 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; AClass a;
a.set_s("hill"); a.set_s("hill");
EXPECT_TRUE(m.Matches(a)); EXPECT_TRUE(m.Matches(a));
EXPECT_TRUE(m_with_name.Matches(a));
a.set_s("hole"); a.set_s("hole");
EXPECT_FALSE(m.Matches(a)); EXPECT_FALSE(m.Matches(a));
EXPECT_FALSE(m_with_name.Matches(a));
} }
#endif #endif

View File

@ -522,11 +522,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif // !defined(GTEST_HAS_STD_STRING) #endif // !defined(GTEST_HAS_STD_STRING)
#ifndef GTEST_HAS_GLOBAL_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 # define GTEST_HAS_GLOBAL_STRING 0
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_STD_WSTRING #ifndef GTEST_HAS_STD_WSTRING