1 /*
2  *  Created by Martin on 19/07/2017.
3  *
4  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
5  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  */
7 
8 #include "catch_interfaces_reporter.h"
9 #include "../reporters/catch_reporter_listening.h"
10 
11 namespace Catch {
12 
ReporterConfig(IConfigPtr const & _fullConfig)13     ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig )
14     :   m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
15 
ReporterConfig(IConfigPtr const & _fullConfig,std::ostream & _stream)16     ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream )
17     :   m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
18 
stream() const19     std::ostream& ReporterConfig::stream() const { return *m_stream; }
fullConfig() const20     IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; }
21 
22 
TestRunInfo(std::string const & _name)23     TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {}
24 
GroupInfo(std::string const & _name,std::size_t _groupIndex,std::size_t _groupsCount)25     GroupInfo::GroupInfo(  std::string const& _name,
26                            std::size_t _groupIndex,
27                            std::size_t _groupsCount )
28     :   name( _name ),
29         groupIndex( _groupIndex ),
30         groupsCounts( _groupsCount )
31     {}
32 
AssertionStats(AssertionResult const & _assertionResult,std::vector<MessageInfo> const & _infoMessages,Totals const & _totals)33      AssertionStats::AssertionStats( AssertionResult const& _assertionResult,
34                                      std::vector<MessageInfo> const& _infoMessages,
35                                      Totals const& _totals )
36     :   assertionResult( _assertionResult ),
37         infoMessages( _infoMessages ),
38         totals( _totals )
39     {
40         assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression;
41 
42         if( assertionResult.hasMessage() ) {
43             // Copy message into messages list.
44             // !TBD This should have been done earlier, somewhere
45             MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
46             builder << assertionResult.getMessage();
47             builder.m_info.message = builder.m_stream.str();
48 
49             infoMessages.push_back( builder.m_info );
50         }
51     }
52 
53      AssertionStats::~AssertionStats() = default;
54 
SectionStats(SectionInfo const & _sectionInfo,Counts const & _assertions,double _durationInSeconds,bool _missingAssertions)55     SectionStats::SectionStats(  SectionInfo const& _sectionInfo,
56                                  Counts const& _assertions,
57                                  double _durationInSeconds,
58                                  bool _missingAssertions )
59     :   sectionInfo( _sectionInfo ),
60         assertions( _assertions ),
61         durationInSeconds( _durationInSeconds ),
62         missingAssertions( _missingAssertions )
63     {}
64 
65     SectionStats::~SectionStats() = default;
66 
67 
TestCaseStats(TestCaseInfo const & _testInfo,Totals const & _totals,std::string const & _stdOut,std::string const & _stdErr,bool _aborting)68     TestCaseStats::TestCaseStats(  TestCaseInfo const& _testInfo,
69                                    Totals const& _totals,
70                                    std::string const& _stdOut,
71                                    std::string const& _stdErr,
72                                    bool _aborting )
73     : testInfo( _testInfo ),
74         totals( _totals ),
75         stdOut( _stdOut ),
76         stdErr( _stdErr ),
77         aborting( _aborting )
78     {}
79 
80     TestCaseStats::~TestCaseStats() = default;
81 
82 
TestGroupStats(GroupInfo const & _groupInfo,Totals const & _totals,bool _aborting)83     TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo,
84                                     Totals const& _totals,
85                                     bool _aborting )
86     :   groupInfo( _groupInfo ),
87         totals( _totals ),
88         aborting( _aborting )
89     {}
90 
TestGroupStats(GroupInfo const & _groupInfo)91     TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo )
92     :   groupInfo( _groupInfo ),
93         aborting( false )
94     {}
95 
96     TestGroupStats::~TestGroupStats() = default;
97 
TestRunStats(TestRunInfo const & _runInfo,Totals const & _totals,bool _aborting)98     TestRunStats::TestRunStats(   TestRunInfo const& _runInfo,
99                     Totals const& _totals,
100                     bool _aborting )
101     :   runInfo( _runInfo ),
102         totals( _totals ),
103         aborting( _aborting )
104     {}
105 
106     TestRunStats::~TestRunStats() = default;
107 
fatalErrorEncountered(StringRef)108     void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
isMulti() const109     bool IStreamingReporter::isMulti() const { return false; }
110 
111     IReporterFactory::~IReporterFactory() = default;
112     IReporterRegistry::~IReporterRegistry() = default;
113 
114 } // end namespace Catch
115