aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorvladlosev <vladlosev@8415998a-534a-0410-bf83-d39667b30386>2009-11-18 00:43:37 +0000
committervladlosev <vladlosev@8415998a-534a-0410-bf83-d39667b30386>2009-11-18 00:43:37 +0000
commit79b83505bcf73bf2903ebf2e2f82cb1e1f181816 (patch)
tree56889fedd603bae573b178494084d00d7f5da379 /test
parenta63be0bd91ebbcb33635b1730a8cd8cb70fb3733 (diff)
downloadgoogletest-79b83505bcf73bf2903ebf2e2f82cb1e1f181816.tar.gz
googletest-79b83505bcf73bf2903ebf2e2f82cb1e1f181816.tar.bz2
googletest-79b83505bcf73bf2903ebf2e2f82cb1e1f181816.zip
Updates IsNull and NotNull matchers to work with smart pointers.
Diffstat (limited to 'test')
-rw-r--r--test/gmock-matchers_test.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/gmock-matchers_test.cc b/test/gmock-matchers_test.cc
index 20b9387f..08cbcb64 100644
--- a/test/gmock-matchers_test.cc
+++ b/test/gmock-matchers_test.cc
@@ -121,6 +121,7 @@ using testing::internal::ValidateMatcherDescription;
using testing::internal::kInvalidInterpolation;
using testing::internal::kPercentInterpolation;
using testing::internal::kTupleInterpolation;
+using testing::internal::linked_ptr;
using testing::internal::string;
#ifdef GMOCK_HAS_REGEX
@@ -715,6 +716,24 @@ TEST(IsNullTest, MatchesNullPointer) {
#endif
}
+TEST(IsNullTest, LinkedPtr) {
+ const Matcher<linked_ptr<int> > m = IsNull();
+ const linked_ptr<int> null_p;
+ const linked_ptr<int> non_null_p(new int);
+
+ EXPECT_TRUE(m.Matches(null_p));
+ EXPECT_FALSE(m.Matches(non_null_p));
+}
+
+TEST(IsNullTest, ReferenceToConstLinkedPtr) {
+ const Matcher<const linked_ptr<double>&> m = IsNull();
+ const linked_ptr<double> null_p;
+ const linked_ptr<double> non_null_p(new double);
+
+ EXPECT_TRUE(m.Matches(null_p));
+ EXPECT_FALSE(m.Matches(non_null_p));
+}
+
// Tests that IsNull() describes itself properly.
TEST(IsNullTest, CanDescribeSelf) {
Matcher<int*> m = IsNull();
@@ -736,6 +755,24 @@ TEST(NotNullTest, MatchesNonNullPointer) {
EXPECT_TRUE(m2.Matches("hi"));
}
+TEST(NotNullTest, LinkedPtr) {
+ const Matcher<linked_ptr<int> > m = NotNull();
+ const linked_ptr<int> null_p;
+ const linked_ptr<int> non_null_p(new int);
+
+ EXPECT_FALSE(m.Matches(null_p));
+ EXPECT_TRUE(m.Matches(non_null_p));
+}
+
+TEST(NotNullTest, ReferenceToConstLinkedPtr) {
+ const Matcher<const linked_ptr<double>&> m = NotNull();
+ const linked_ptr<double> null_p;
+ const linked_ptr<double> non_null_p(new double);
+
+ EXPECT_FALSE(m.Matches(null_p));
+ EXPECT_TRUE(m.Matches(non_null_p));
+}
+
// Tests that NotNull() describes itself properly.
TEST(NotNullTest, CanDescribeSelf) {
Matcher<int*> m = NotNull();