Use ResultOf()'s result_description when explaining match result.

PiperOrigin-RevId: 439389646
Change-Id: Ie34adcdd2b24378e85962efac53b7bb89ed93803
This commit is contained in:
Abseil Team
2022-04-04 12:55:29 -07:00
committed by Copybara-Service
parent 25dcdc7e8b
commit 3ffa237f0e
2 changed files with 16 additions and 1 deletions

View File

@@ -2258,7 +2258,11 @@ class ResultOfMatcher {
}
bool MatchAndExplain(T obj, MatchResultListener* listener) const override {
*listener << "which is mapped by the given callable to ";
if (result_description_.empty()) {
*listener << "which is mapped by the given callable to ";
} else {
*listener << "whose " << result_description_ << " is ";
}
// Cannot pass the return value directly to MatchPrintAndExplain, which
// takes a non-const reference as argument.
// Also, specifying template argument explicitly is needed because T could