aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2010-01-13 05:15:07 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2010-01-13 05:15:07 +0000
commit6953a725fc2151eff18078f8315d92811cd4d90e (patch)
treee78bb4d875e797e2f07afcce1208864bf5d40429 /test
parente122e457a6e890faac399c1f86d87cc8d3177ac2 (diff)
downloadgoogletest-6953a725fc2151eff18078f8315d92811cd4d90e.tar.gz
googletest-6953a725fc2151eff18078f8315d92811cd4d90e.tar.bz2
googletest-6953a725fc2151eff18078f8315d92811cd4d90e.zip
Allows Field() and Property() to work when the matcher argument is a pointer passed by reference.
Diffstat (limited to 'test')
-rw-r--r--test/gmock-matchers_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/gmock-matchers_test.cc b/test/gmock-matchers_test.cc
index e69844fa..e10b7275 100644
--- a/test/gmock-matchers_test.cc
+++ b/test/gmock-matchers_test.cc
@@ -2648,6 +2648,16 @@ TEST(FieldForPointerTest, WorksForPointerToNonConst) {
EXPECT_FALSE(m.Matches(&a));
}
+// Tests that Field() works when the argument is a reference to a const pointer.
+TEST(FieldForPointerTest, WorksForReferenceToConstPointer) {
+ Matcher<AStruct* const&> m = Field(&AStruct::x, Ge(0));
+
+ AStruct a;
+ EXPECT_TRUE(m.Matches(&a));
+ a.x = -1;
+ EXPECT_FALSE(m.Matches(&a));
+}
+
// Tests that Field() does not match the NULL pointer.
TEST(FieldForPointerTest, DoesNotMatchNull) {
Matcher<const AStruct*> m = Field(&AStruct::x, _);
@@ -2846,6 +2856,19 @@ TEST(PropertyForPointerTest, WorksForPointerToNonConst) {
EXPECT_FALSE(m.Matches(&a));
}
+// Tests that Property() works when the argument is a reference to a
+// const pointer.
+TEST(PropertyForPointerTest, WorksForReferenceToConstPointer) {
+ Matcher<AClass* const&> m = Property(&AClass::s, StartsWith("hi"));
+
+ AClass a;
+ a.set_s("hill");
+ EXPECT_TRUE(m.Matches(&a));
+
+ a.set_s("hole");
+ EXPECT_FALSE(m.Matches(&a));
+}
+
// Tests that Property() does not match the NULL pointer.
TEST(PropertyForPointerTest, WorksForReferenceToNonConstProperty) {
Matcher<const AClass*> m = Property(&AClass::x, _);