1 /*
2  *  Created by Phil on 5/12/2012.
3  *  Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 #ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
9 #define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
10 
11 #include "catch_reporter_bases.hpp"
12 
13 #if defined(_MSC_VER)
14 #pragma warning(push)
15 #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
16                               // Note that 4062 (not all labels are handled
17                               // and default is missing) is enabled
18 #endif
19 
20 
21 namespace Catch {
22     // Fwd decls
23     struct SummaryColumn;
24     class TablePrinter;
25 
26     struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
27         std::unique_ptr<TablePrinter> m_tablePrinter;
28 
29         ConsoleReporter(ReporterConfig const& config);
30         ~ConsoleReporter() override;
31         static std::string getDescription();
32 
33         void noMatchingTestCases(std::string const& spec) override;
34 
35         void reportInvalidArguments(std::string const&arg) override;
36 
37         void assertionStarting(AssertionInfo const&) override;
38 
39         bool assertionEnded(AssertionStats const& _assertionStats) override;
40 
41         void sectionStarting(SectionInfo const& _sectionInfo) override;
42         void sectionEnded(SectionStats const& _sectionStats) override;
43 
44 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
45         void benchmarkPreparing(std::string const& name) override;
46         void benchmarkStarting(BenchmarkInfo const& info) override;
47         void benchmarkEnded(BenchmarkStats<> const& stats) override;
48         void benchmarkFailed(std::string const& error) override;
49 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
50 
51         void testCaseEnded(TestCaseStats const& _testCaseStats) override;
52         void testGroupEnded(TestGroupStats const& _testGroupStats) override;
53         void testRunEnded(TestRunStats const& _testRunStats) override;
54         void testRunStarting(TestRunInfo const& _testRunInfo) override;
55     private:
56 
57         void lazyPrint();
58 
59         void lazyPrintWithoutClosingBenchmarkTable();
60         void lazyPrintRunInfo();
61         void lazyPrintGroupInfo();
62         void printTestCaseAndSectionHeader();
63 
64         void printClosedHeader(std::string const& _name);
65         void printOpenHeader(std::string const& _name);
66 
67         // if string has a : in first line will set indent to follow it on
68         // subsequent lines
69         void printHeaderString(std::string const& _string, std::size_t indent = 0);
70 
71 
72         void printTotals(Totals const& totals);
73         void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row);
74 
75         void printTotalsDivider(Totals const& totals);
76         void printSummaryDivider();
77         void printTestFilters();
78 
79     private:
80         bool m_headerPrinted = false;
81     };
82 
83 } // end namespace Catch
84 
85 #if defined(_MSC_VER)
86 #pragma warning(pop)
87 #endif
88 
89 #endif // TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED