Merge pull request #4041 from zloylos:allow-naming-expectations

PiperOrigin-RevId: 483683590
Change-Id: Id22de3a22018324e5c1e21e262ac5e027a83bf3e
This commit is contained in:
Copybara-Service
2022-10-25 08:39:19 -07:00
3 changed files with 48 additions and 11 deletions

View File

@@ -409,8 +409,15 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
} else if (!untyped_expectation->IsSatisfied()) {
expectations_met = false;
::std::stringstream ss;
ss << "Actual function call count doesn't match "
<< untyped_expectation->source_text() << "...\n";
const ::std::string& expectation_name =
untyped_expectation->GetDescription();
ss << "Actual function ";
if (!expectation_name.empty()) {
ss << "\"" << expectation_name << "\" ";
}
ss << "call count doesn't match " << untyped_expectation->source_text()
<< "...\n";
// No need to show the source file location of the expectation
// in the description, as the Expect() call that follows already
// takes care of it.