Allow calling Args and ArgNames in any order.

This commit is contained in:
Marek Kurdej 2016-10-26 09:36:39 +02:00
parent cfee1a54e4
commit 3f23832a09
2 changed files with 6 additions and 2 deletions

View File

@ -422,7 +422,11 @@ Benchmark* Benchmark::ThreadPerCpu() {
void Benchmark::SetName(const char* name) { name_ = name; }
int Benchmark::ArgsCnt() const {
return args_.empty() ? -1 : static_cast<int>(args_.front().size());
if (args_.empty()) {
if (arg_names_.empty()) return -1;
return static_cast<int>(arg_names_.size());
}
return static_cast<int>(args_.front().size());
}
//=============================================================================//

View File

@ -73,7 +73,7 @@ void BM_arg_name(benchmark::State& state) {
while (state.KeepRunning()) {
}
}
BENCHMARK(BM_arg_name)->Arg(3)->ArgName("first");
BENCHMARK(BM_arg_name)->ArgName("first")->Arg(3);
ADD_CASES(TC_ConsoleOut, {{"^BM_arg_name/first:3 %console_report$"}});
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_arg_name/first:3\",$"}});
ADD_CASES(TC_CSVOut, {{"^\"BM_arg_name/first:3\",%csv_report$"}});