• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #undef NDEBUG
3 #include <cstdio>
4 #include <string>
5 
6 #include "benchmark/benchmark.h"
7 #include "output_test.h"
8 
9 // Ok this test is super ugly. We want to check what happens with the file
10 // reporter in the presence of ReportAggregatesOnly().
11 // We do not care about console output, the normal tests check that already.
12 
BM_SummaryRepeat(benchmark::State & state)13 void BM_SummaryRepeat(benchmark::State& state) {
14   for (auto _ : state) {
15   }
16 }
17 BENCHMARK(BM_SummaryRepeat)->Repetitions(3)->ReportAggregatesOnly();
18 
main(int argc,char * argv[])19 int main(int argc, char* argv[]) {
20   const std::string output = GetFileReporterOutput(argc, argv);
21 
22   if (SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3") != 3 ||
23       SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_mean\"") != 1 ||
24       SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_median\"") !=
25           1 ||
26       SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"") !=
27           1) {
28     std::cout << "Precondition mismatch. Expected to only find three "
29                  "occurrences of \"BM_SummaryRepeat/repeats:3\" substring:\n"
30                  "\"name\": \"BM_SummaryRepeat/repeats:3_mean\", "
31                  "\"name\": \"BM_SummaryRepeat/repeats:3_median\", "
32                  "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"\nThe entire "
33                  "output:\n";
34     std::cout << output;
35     return 1;
36   }
37 
38   return 0;
39 }
40