• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 assertionStarting(AssertionInfo const&) override;
36 
37         bool assertionEnded(AssertionStats const& _assertionStats) override;
38 
39         void sectionStarting(SectionInfo const& _sectionInfo) override;
40         void sectionEnded(SectionStats const& _sectionStats) override;
41 
42 
43         void benchmarkStarting(BenchmarkInfo const& info) override;
44         void benchmarkEnded(BenchmarkStats const& stats) override;
45 
46         void testCaseEnded(TestCaseStats const& _testCaseStats) override;
47         void testGroupEnded(TestGroupStats const& _testGroupStats) override;
48         void testRunEnded(TestRunStats const& _testRunStats) override;
49 
50     private:
51 
52         void lazyPrint();
53 
54         void lazyPrintWithoutClosingBenchmarkTable();
55         void lazyPrintRunInfo();
56         void lazyPrintGroupInfo();
57         void printTestCaseAndSectionHeader();
58 
59         void printClosedHeader(std::string const& _name);
60         void printOpenHeader(std::string const& _name);
61 
62         // if string has a : in first line will set indent to follow it on
63         // subsequent lines
64         void printHeaderString(std::string const& _string, std::size_t indent = 0);
65 
66 
67         void printTotals(Totals const& totals);
68         void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row);
69 
70         void printTotalsDivider(Totals const& totals);
71         void printSummaryDivider();
72 
73     private:
74         bool m_headerPrinted = false;
75     };
76 
77 } // end namespace Catch
78 
79 #if defined(_MSC_VER)
80 #pragma warning(pop)
81 #endif
82 
83 #endif // TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
84