Googletest export

rollback of 224929783

PiperOrigin-RevId: 225008559
This commit is contained in:
misterg
2018-12-11 11:35:25 -05:00
committed by Gennadiy Civil
parent 06bb8d4d6d
commit 6cbd3753dc
2 changed files with 7 additions and 96 deletions

View File

@@ -1296,24 +1296,14 @@ class PredicateFormatterFromMatcher {
// We don't write MatcherCast<const T&> either, as that allows
// potentially unsafe downcasting of the matcher argument.
const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);
// The expected path here is that the matcher should match (i.e. that most
// tests pass) so optimize for this case.
if (matcher.Matches(x)) {
StringMatchResultListener listener;
if (MatchPrintAndExplain(x, matcher, &listener))
return AssertionSuccess();
}
::std::stringstream ss;
ss << "Value of: " << value_text << "\n"
<< "Expected: ";
matcher.DescribeTo(&ss);
// Rerun the matcher to "PrintAndExain" the failure.
StringMatchResultListener listener;
if (MatchPrintAndExplain(x, matcher, &listener)) {
ss << "\n The matcher failed on the initial attempt; but passed when "
"rerun to generate the explanation.";
}
ss << "\n Actual: " << listener.str();
return AssertionFailure() << ss.str();
}