6 #include "../src/check.h"
17 virtual void ReportRuns(
const std::vector<Run>& report) {
18 all_runs_.insert(all_runs_.end(),
begin(report),
end(report));
23 virtual ~TestReporter() {}
25 mutable std::vector<Run> all_runs_;
35 void CheckRun(
Run const& run)
const {
36 CHECK(
name == run.benchmark_name) <<
"expected " <<
name <<
" got "
37 << run.benchmark_name;
38 CHECK(error_occurred == run.error_occurred);
39 CHECK(error_message == run.error_message);
43 CHECK(run.iterations != 0);
48 std::vector<TestCase> ExpectedResults;
50 int AddCases(
const char* base_name, std::initializer_list<TestCase>
const&
v) {
52 TC.name = base_name + TC.name;
53 ExpectedResults.push_back(std::move(TC));
58 #define CONCAT(x, y) CONCAT2(x, y)
59 #define CONCAT2(x, y) x##y
60 #define ADD_CASES(...) int CONCAT(dummy, __LINE__) = AddCases(__VA_ARGS__)
71 ADD_CASES(
"BM_error_before_running", {{
"",
true,
"error message"}});
74 int first_iter =
true;
87 ADD_CASES(
"BM_error_during_running", {{
"/1/threads:1",
true,
"error message"},
88 {
"/1/threads:2",
true,
"error message"},
89 {
"/1/threads:4",
true,
"error message"},
90 {
"/1/threads:8",
true,
"error message"},
91 {
"/2/threads:1",
false,
""},
92 {
"/2/threads:2",
false,
""},
93 {
"/2/threads:4",
false,
""},
94 {
"/2/threads:8",
false,
""}});
104 ADD_CASES(
"BM_error_after_running", {{
"/threads:1",
true,
"error message"},
105 {
"/threads:2",
true,
"error message"},
106 {
"/threads:4",
true,
"error message"},
107 {
"/threads:8",
true,
"error message"}});
110 bool first_iter =
true;
124 ADD_CASES(
"BM_error_while_paused", {{
"/1/threads:1",
true,
"error message"},
125 {
"/1/threads:2",
true,
"error message"},
126 {
"/1/threads:4",
true,
"error message"},
127 {
"/1/threads:8",
true,
"error message"},
128 {
"/2/threads:1",
false,
""},
129 {
"/2/threads:2",
false,
""},
130 {
"/2/threads:4",
false,
""},
131 {
"/2/threads:8",
false,
""}});
133 int main(
int argc,
char* argv[]) {
136 TestReporter test_reporter;
140 auto EB = ExpectedResults.begin();
142 for (
Run const& run : test_reporter.all_runs_) {
143 assert(EB != ExpectedResults.end());
147 assert(EB == ExpectedResults.end());