aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-09-24 21:41:36 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-09-24 21:41:36 +0000
commit2d970ee3bad530703ff24bc3a011390b45cdd293 (patch)
tree76d3726db6abb5f652671bfa2b31348c1506f9b5 /include
parentf7af24c7de14ccb10a24909a6f3440a763cb1164 (diff)
downloadgoogletest-2d970ee3bad530703ff24bc3a011390b45cdd293.tar.gz
googletest-2d970ee3bad530703ff24bc3a011390b45cdd293.tar.bz2
googletest-2d970ee3bad530703ff24bc3a011390b45cdd293.zip
Adds the IsNull() matcher.
Diffstat (limited to 'include')
-rw-r--r--include/gmock/gmock-matchers.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h
index 688ce64f..e2beff4e 100644
--- a/include/gmock/gmock-matchers.h
+++ b/include/gmock/gmock-matchers.h
@@ -621,6 +621,19 @@ GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "not equal to");
#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
+// Implements the polymorphic IsNull() matcher, which matches any
+// pointer that is NULL.
+class IsNullMatcher {
+ public:
+ template <typename T>
+ bool Matches(T* p) const { return p == NULL; }
+
+ void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "is not NULL";
+ }
+};
+
// Implements the polymorphic NotNull() matcher, which matches any
// pointer that is not NULL.
class NotNullMatcher {
@@ -2319,6 +2332,11 @@ inline internal::NeMatcher<Rhs> Ne(Rhs x) {
return internal::NeMatcher<Rhs>(x);
}
+// Creates a polymorphic matcher that matches any NULL pointer.
+inline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {
+ return MakePolymorphicMatcher(internal::IsNullMatcher());
+}
+
// Creates a polymorphic matcher that matches any non-NULL pointer.
// This is convenient as Not(NULL) doesn't compile (the compiler
// thinks that that expression is comparing a pointer with an integer).