report_aggregates_only_test.cc 1.5 KB

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