summaryrefslogtreecommitdiffstats
path: root/googlemock/include
diff options
context:
space:
mode:
authorAlyssa Wilk <alyssar@chromium.org>2017-08-28 20:10:12 (GMT)
committerAlyssa Wilk <alyssar@chromium.org>2017-08-28 20:10:12 (GMT)
commitc00373320db8cfbd1524e73e7b2793a22ecb2672 (patch)
treefe20e7200424c65ab9acb8ff38ff1b2e86204ba6 /googlemock/include
parenta2803bc37dafdaad05b335e64a83aff03096a4ba (diff)
parentb43bfcf49166599955ba3713952bc6c0e96b421b (diff)
downloadgoogletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.zip
googletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.tar.gz
googletest-c00373320db8cfbd1524e73e7b2793a22ecb2672.tar.bz2
Merge branch 'refs/heads/master' into flag-default
Diffstat (limited to 'googlemock/include')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 3a97c43..c446bf7 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -2232,7 +2232,10 @@ class FieldMatcher {
// Implements the Property() matcher for matching a property
// (i.e. return value of a getter method) of an object.
-template <typename Class, typename PropertyType>
+//
+// Property is a const-qualified member function of Class returning
+// PropertyType.
+template <typename Class, typename PropertyType, typename Property>
class PropertyMatcher {
public:
// The property may have a reference type, so 'const PropertyType&'
@@ -2241,8 +2244,7 @@ class PropertyMatcher {
// PropertyType being a reference or not.
typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
- PropertyMatcher(PropertyType (Class::*property)() const,
- const Matcher<RefToConstProperty>& matcher)
+ PropertyMatcher(Property property, const Matcher<RefToConstProperty>& matcher)
: property_(property), matcher_(matcher) {}
void DescribeTo(::std::ostream* os) const {
@@ -2295,7 +2297,7 @@ class PropertyMatcher {
return MatchAndExplainImpl(false_type(), *p, listener);
}
- PropertyType (Class::*property_)() const;
+ Property property_;
const Matcher<RefToConstProperty> matcher_;
GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
@@ -3908,11 +3910,13 @@ inline PolymorphicMatcher<
// Property(&Foo::str, StartsWith("hi"))
// matches a Foo object x iff x.str() starts with "hi".
template <typename Class, typename PropertyType, typename PropertyMatcher>
-inline PolymorphicMatcher<
- internal::PropertyMatcher<Class, PropertyType> > Property(
- PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
+inline PolymorphicMatcher<internal::PropertyMatcher<
+ Class, PropertyType, PropertyType (Class::*)() const> >
+Property(PropertyType (Class::*property)() const,
+ const PropertyMatcher& matcher) {
return MakePolymorphicMatcher(
- internal::PropertyMatcher<Class, PropertyType>(
+ internal::PropertyMatcher<Class, PropertyType,
+ PropertyType (Class::*)() const>(
property,
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
// The call to MatcherCast() is required for supporting inner
@@ -3921,6 +3925,21 @@ inline PolymorphicMatcher<
// to compile where bar() returns an int32 and m is a matcher for int64.
}
+#if GTEST_LANG_CXX11
+// The same as above but for reference-qualified member functions.
+template <typename Class, typename PropertyType, typename PropertyMatcher>
+inline PolymorphicMatcher<internal::PropertyMatcher<
+ Class, PropertyType, PropertyType (Class::*)() const &> >
+Property(PropertyType (Class::*property)() const &,
+ const PropertyMatcher& matcher) {
+ return MakePolymorphicMatcher(
+ internal::PropertyMatcher<Class, PropertyType,
+ PropertyType (Class::*)() const &>(
+ property,
+ MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
+}
+#endif
+
// Creates a matcher that matches an object iff the result of applying
// a callable to x matches 'matcher'.
// For example,