mirror of https://github.com/google/benchmark.git
Handle the case when the argument name is an empty string.
This commit is contained in:
parent
17e1c405dd
commit
c1c01b2cd3
|
@ -153,12 +153,16 @@ bool BenchmarkFamilies::FindBenchmarks(
|
|||
// Add arguments to instance name
|
||||
size_t arg_i = 0;
|
||||
for (auto const& arg : args) {
|
||||
if (arg_i < family->arg_names_.size()) {
|
||||
instance.name +=
|
||||
StringPrintF("/%s:", family->arg_names_[arg_i].c_str());
|
||||
} else {
|
||||
instance.name += "/";
|
||||
|
||||
if (arg_i < family->arg_names_.size()) {
|
||||
const auto& arg_name = family->arg_names_[arg_i];
|
||||
if (!arg_name.empty()) {
|
||||
instance.name +=
|
||||
StringPrintF("%s:", family->arg_names_[arg_i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
AppendHumanReadable(arg, &instance.name);
|
||||
++arg_i;
|
||||
}
|
||||
|
|
|
@ -86,10 +86,11 @@ void BM_arg_names(benchmark::State& state) {
|
|||
while (state.KeepRunning()) {
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_arg_names)->Args({2, 4})->ArgNames({"first", "second"});
|
||||
ADD_CASES(TC_ConsoleOut, {{"^BM_arg_names/first:2/second:4 %console_report$"}});
|
||||
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_arg_names/first:2/second:4\",$"}});
|
||||
ADD_CASES(TC_CSVOut, {{"^\"BM_arg_names/first:2/second:4\",%csv_report$"}});
|
||||
BENCHMARK(BM_arg_names)->Args({2, 5, 4})->ArgNames({"first", "", "third"});
|
||||
ADD_CASES(TC_ConsoleOut,
|
||||
{{"^BM_arg_names/first:2/5/third:4 %console_report$"}});
|
||||
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_arg_names/first:2/5/third:4\",$"}});
|
||||
ADD_CASES(TC_CSVOut, {{"^\"BM_arg_names/first:2/5/third:4\",%csv_report$"}});
|
||||
|
||||
// ========================================================================= //
|
||||
// ----------------------- Testing Complexity Output ----------------------- //
|
||||
|
|
Loading…
Reference in New Issue