aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-01 01:47:35 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-01 01:47:35 +0000
commit83f6b08b5f730c2bfaa288a17d5f12ca98901a00 (patch)
tree4f3ff706ac088e235936686d9c9bdf3cd1088ef8 /include
parent320814aca02dfb6b5f116bc5de1785a478cc6d42 (diff)
downloadgoogletest-83f6b08b5f730c2bfaa288a17d5f12ca98901a00.tar.gz
googletest-83f6b08b5f730c2bfaa288a17d5f12ca98901a00.tar.bz2
googletest-83f6b08b5f730c2bfaa288a17d5f12ca98901a00.zip
Clarifies how to implement MatcherInterface.
Diffstat (limited to 'include')
-rw-r--r--include/gmock/gmock-matchers.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h
index 751574ca..19bd551a 100644
--- a/include/gmock/gmock-matchers.h
+++ b/include/gmock/gmock-matchers.h
@@ -112,10 +112,27 @@ class MatcherInterface {
virtual ~MatcherInterface() {}
// Returns true iff the matcher matches x; also explains the match
- // result to 'listener', in the form of a non-restrictive relative
- // clause ("which ...", "whose ...", etc) that describes x. For
- // example, the MatchAndExplain() method of the Pointee(...) matcher
- // should generate an explanation like "which points to ...".
+ // result to 'listener' if necessary (see the next paragraph), in
+ // the form of a non-restrictive relative clause ("which ...",
+ // "whose ...", etc) that describes x. For example, the
+ // MatchAndExplain() method of the Pointee(...) matcher should
+ // generate an explanation like "which points to ...".
+ //
+ // Implementations of MatchAndExplain() should add an explanation of
+ // the match result *if and only if* they can provide additional
+ // information that's not already present (or not obvious) in the
+ // print-out of x and the matcher's description. Whether the match
+ // succeeds is not a factor in deciding whether an explanation is
+ // needed, as sometimes the caller needs to print a failure message
+ // when the match succeeds (e.g. when the matcher is used inside
+ // Not()).
+ //
+ // For example, a "has at least 10 elements" matcher should explain
+ // what the actual element count is, regardless of the match result,
+ // as it is useful information to the reader; on the other hand, an
+ // "is empty" matcher probably only needs to explain what the actual
+ // size is when the match fails, as it's redundant to say that the
+ // size is 0 when the value is already known to be empty.
//
// You should override this method when defining a new matcher.
//