mirror of
https://github.com/google/benchmark.git
synced 2025-02-06 01:00:17 +08:00
Deal with names with embedded quotes
This commit is contained in:
parent
b6e4f67d75
commit
2924aaa747
@ -73,8 +73,12 @@ void CSVReporter::PrintRunData(Run const& run) {
|
||||
cpu_time = cpu_time / static_cast<double>(run.iterations);
|
||||
}
|
||||
|
||||
// Field with embedded commas must be delimited with double-quotes.
|
||||
std::cout << "\"" << run.benchmark_name << "\",";
|
||||
// Field with embedded double-quote characters must be doubled and the field
|
||||
// delimited with double-quotes.
|
||||
std::string name = run.benchmark_name;
|
||||
ReplaceAll(&name, "\"", "\"\"");
|
||||
std::cout << "\"" << name << "\",";
|
||||
|
||||
std::cout << run.iterations << ",";
|
||||
std::cout << real_time << ",";
|
||||
std::cout << cpu_time << ",";
|
||||
@ -92,7 +96,6 @@ void CSVReporter::PrintRunData(Run const& run) {
|
||||
// delimited with double-quotes.
|
||||
std::string label = run.report_label;
|
||||
ReplaceAll(&label, "\"", "\"\"");
|
||||
|
||||
std::cout << "\"" << label << "\"";
|
||||
}
|
||||
std::cout << '\n';
|
||||
|
Loading…
Reference in New Issue
Block a user