Include the param names in the generated description of the MATCHER_P matchers.

PiperOrigin-RevId: 418497526
Change-Id: Ie53c3c0810c10a32cbcb941e3ca1ee8fb1ddd9f9
This commit is contained in:
Abseil Team
2021-12-27 08:04:50 -08:00
committed by Copybara-Service
parent d81ae2f0bf
commit 6b74da4757
7 changed files with 83 additions and 65 deletions

View File

@@ -44,6 +44,7 @@
#include <cstring>
#include <ostream> // NOLINT
#include <string>
#include <vector>
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
@@ -54,21 +55,22 @@ namespace internal {
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
GTEST_API_ std::string JoinAsTuple(const Strings& fields) {
switch (fields.size()) {
case 0:
return "";
case 1:
return fields[0];
default:
std::string result = "(" + fields[0];
for (size_t i = 1; i < fields.size(); i++) {
result += ", ";
result += fields[i];
}
result += ")";
return result;
GTEST_API_ std::string JoinAsKeyValueTuple(
const std::vector<const char*>& names, const Strings& values) {
GTEST_CHECK_(names.size() == values.size());
if (values.empty()) {
return "";
}
const auto build_one = [&](const size_t i) {
return std::string(names[i]) + ": " + values[i];
};
std::string result = "(" + build_one(0);
for (size_t i = 1; i < values.size(); i++) {
result += ", ";
result += build_one(i);
}
result += ")";
return result;
}
// Converts an identifier name to a space-separated list of lower-case