Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_reporter_listening.cpp
Go to the documentation of this file.
1/*
2 * Created by Phil on 5/08/2015.
3 * Copyright 2015 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
10#include <cassert>
11
12namespace Catch {
13
15 // We will assume that listeners will always want all assertions
16 m_preferences.shouldReportAllAssertions = true;
17 }
18
20 m_listeners.push_back( std::move( listener ) );
21 }
22
24 assert(!m_reporter && "Listening reporter can wrap only 1 real reporter");
25 m_reporter = std::move( reporter );
26 m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;
27 }
28
30 return m_preferences;
31 }
32
34 return std::set<Verbosity>{ };
35 }
36
37
38 void ListeningReporter::noMatchingTestCases( std::string const& spec ) {
39 for ( auto const& listener : m_listeners ) {
40 listener->noMatchingTestCases( spec );
41 }
42 m_reporter->noMatchingTestCases( spec );
43 }
44
46 for ( auto const& listener : m_listeners ) {
47 listener->benchmarkStarting( benchmarkInfo );
48 }
49 m_reporter->benchmarkStarting( benchmarkInfo );
50 }
51 void ListeningReporter::benchmarkEnded( BenchmarkStats const& benchmarkStats ) {
52 for ( auto const& listener : m_listeners ) {
53 listener->benchmarkEnded( benchmarkStats );
54 }
55 m_reporter->benchmarkEnded( benchmarkStats );
56 }
57
59 for ( auto const& listener : m_listeners ) {
60 listener->testRunStarting( testRunInfo );
61 }
62 m_reporter->testRunStarting( testRunInfo );
63 }
64
66 for ( auto const& listener : m_listeners ) {
67 listener->testGroupStarting( groupInfo );
68 }
69 m_reporter->testGroupStarting( groupInfo );
70 }
71
72
74 for ( auto const& listener : m_listeners ) {
75 listener->testCaseStarting( testInfo );
76 }
77 m_reporter->testCaseStarting( testInfo );
78 }
79
81 for ( auto const& listener : m_listeners ) {
82 listener->sectionStarting( sectionInfo );
83 }
84 m_reporter->sectionStarting( sectionInfo );
85 }
86
88 for ( auto const& listener : m_listeners ) {
89 listener->assertionStarting( assertionInfo );
90 }
91 m_reporter->assertionStarting( assertionInfo );
92 }
93
94 // The return value indicates if the messages buffer should be cleared:
95 bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {
96 for( auto const& listener : m_listeners ) {
97 static_cast<void>( listener->assertionEnded( assertionStats ) );
98 }
99 return m_reporter->assertionEnded( assertionStats );
100 }
101
102 void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) {
103 for ( auto const& listener : m_listeners ) {
104 listener->sectionEnded( sectionStats );
105 }
106 m_reporter->sectionEnded( sectionStats );
107 }
108
109 void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
110 for ( auto const& listener : m_listeners ) {
111 listener->testCaseEnded( testCaseStats );
112 }
113 m_reporter->testCaseEnded( testCaseStats );
114 }
115
116 void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {
117 for ( auto const& listener : m_listeners ) {
118 listener->testGroupEnded( testGroupStats );
119 }
120 m_reporter->testGroupEnded( testGroupStats );
121 }
122
123 void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) {
124 for ( auto const& listener : m_listeners ) {
125 listener->testRunEnded( testRunStats );
126 }
127 m_reporter->testRunEnded( testRunStats );
128 }
129
130
132 for ( auto const& listener : m_listeners ) {
133 listener->skipTest( testInfo );
134 }
135 m_reporter->skipTest( testInfo );
136 }
137
139 return true;
140 }
141
142} // end namespace Catch
void addReporter(IStreamingReporterPtr &&reporter)
bool assertionEnded(AssertionStats const &assertionStats) override
void testGroupStarting(GroupInfo const &groupInfo) override
void testCaseStarting(TestCaseInfo const &testInfo) override
void testRunStarting(TestRunInfo const &testRunInfo) override
void benchmarkStarting(BenchmarkInfo const &benchmarkInfo) override
void skipTest(TestCaseInfo const &testInfo) override
void sectionEnded(SectionStats const &sectionStats) override
void testCaseEnded(TestCaseStats const &testCaseStats) override
void testGroupEnded(TestGroupStats const &testGroupStats) override
void noMatchingTestCases(std::string const &spec) override
ReporterPreferences getPreferences() const override
void assertionStarting(AssertionInfo const &assertionInfo) override
static std::set< Verbosity > getSupportedVerbosities()
void testRunEnded(TestRunStats const &testRunStats) override
void addListener(IStreamingReporterPtr &&listener)
void sectionStarting(SectionInfo const &sectionInfo) override
void benchmarkEnded(BenchmarkStats const &benchmarkStats) override
std::unique_ptr< IStreamingReporter > IStreamingReporterPtr