template <typename T>
class MatcherInterface
Defined at line 140 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
The implementation of a matcher.
Public Methods
bool MatchAndExplain (T x, MatchResultListener * listener)
Returns true if and only if the matcher matches x; also explains the
match 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.
It's the responsibility of the caller (Google Test) to guarantee
that 'listener' is not NULL. This helps to simplify a matcher's
implementation when it doesn't care about the performance, as it
can talk to 'listener' without checking its validity first.
However, in order to implement dummy listeners efficiently,
listener->stream() may be NULL.