1 | #ifndef BANDIT_DOTS_REPORTER_H |
2 | #define BANDIT_DOTS_REPORTER_H |
3 | |
4 | #include <bandit/reporters/colored_reporter.h> |
5 | #include <bandit/reporters/test_run_summary.h> |
6 | |
7 | namespace bandit { |
8 | namespace detail { |
9 | struct dots_reporter : public colored_reporter { |
10 | dots_reporter(std::ostream& stm, const failure_formatter& failure_formatter, |
11 | const colorizer& colorizer) |
12 | : colored_reporter(stm, failure_formatter, colorizer) {} |
13 | |
14 | dots_reporter(const failure_formatter& failure_formatter, const colorizer& colorizer) |
15 | : dots_reporter(std::cout, failure_formatter, colorizer) {} |
16 | |
17 | dots_reporter& operator=(const dots_reporter&) { |
18 | return *this; |
19 | } |
20 | |
21 | void test_run_complete() override { |
22 | progress_reporter::test_run_complete(); |
23 | |
24 | stm_ << std::endl; |
25 | |
26 | test_run_summary summary(specs_run_, specs_failed_, specs_succeeded_, specs_skipped_, failures_, |
27 | test_run_errors_, colorizer_); |
28 | summary.write(stm_); |
29 | stm_.flush(); |
30 | } |
31 | |
32 | void test_run_error(const std::string& desc, const struct test_run_error& err) override { |
33 | progress_reporter::test_run_error(desc, err); |
34 | |
35 | std::stringstream ss; |
36 | ss << std::endl; |
37 | ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl; |
38 | |
39 | test_run_errors_.push_back(ss.str()); |
40 | } |
41 | |
42 | void it_succeeded(const std::string& desc) override { |
43 | progress_reporter::it_succeeded(desc); |
44 | stm_ << colorizer_.green() << "." << colorizer_.reset(); |
45 | stm_.flush(); |
46 | } |
47 | |
48 | void it_failed(const std::string& desc, const assertion_exception& ex) override { |
49 | progress_reporter::it_failed(desc, ex); |
50 | stm_ << colorizer_.red() << "F" << colorizer_.reset(); |
51 | stm_.flush(); |
52 | } |
53 | |
54 | void it_skip(const std::string& desc) override { |
55 | progress_reporter::it_skip(desc); |
56 | stm_ << colorizer_.yellow() << 'S' << colorizer_.reset(); |
57 | stm_.flush(); |
58 | } |
59 | |
60 | void it_unknown_error(const std::string& desc) override { |
61 | progress_reporter::it_unknown_error(desc); |
62 | stm_ << colorizer_.red() << "E" << colorizer_.reset(); |
63 | stm_.flush(); |
64 | } |
65 | }; |
66 | } |
67 | } |
68 | #endif |
69 | |