summaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-matchers.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-11-06 21:11:06 (GMT)
committerMark Barolak <mbar@google.com>2020-11-09 20:43:24 (GMT)
commit0c400f67fcf305869c5fb113dd296eca266c9725 (patch)
treed154d3d5abaab96207eabe8c88556f93b777c834 /googlemock/include/gmock/gmock-matchers.h
parentd89b36302116233b8c6377e6e891083f41ee51c5 (diff)
downloadgoogletest-0c400f67fcf305869c5fb113dd296eca266c9725.zip
googletest-0c400f67fcf305869c5fb113dd296eca266c9725.tar.gz
googletest-0c400f67fcf305869c5fb113dd296eca266c9725.tar.bz2
Googletest export
GMock: Make Truly explain when it fails I just wrote a test that had a matcher of the form Optional(AllOf( SomeMatcher, SomeOtherMatcher, Truly(SomePredicate))) The predicate failed, the other two matchers succeeded, and I got a hard-to-interpret message saying that the value in the optional "didn't match". Didn't match what? This change improves situations like that slightly by having Truly explain to its result listener when it fails. When there are multiple Trulys in an AllOf, there will be some ambiguity, but it will at least provide more information than right now. PiperOrigin-RevId: 341105141
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 7db65a4..d12d7bf 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -1453,7 +1453,7 @@ class TrulyMatcher {
// interested in the address of the argument.
template <typename T>
bool MatchAndExplain(T& x, // NOLINT
- MatchResultListener* /* listener */) const {
+ MatchResultListener* listener) const {
// Without the if-statement, MSVC sometimes warns about converting
// a value to bool (warning 4800).
//
@@ -1462,6 +1462,7 @@ class TrulyMatcher {
// having no operator!().
if (predicate_(x))
return true;
+ *listener << "didn't satisfy the given predicate";
return false;
}