2015-08-05 20:02:17 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 5/08/2015.
|
|
|
|
* Copyright 2015 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include "../internal/catch_interfaces_reporter.h"
|
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
|
|
|
|
class MultipleReporters : public SharedImpl<IStreamingReporter> {
|
2016-04-05 18:21:49 +02:00
|
|
|
Ptr<IStreamingReporter> m_reporter;
|
|
|
|
Ptr<MultipleReporters> m_next;
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
public:
|
2016-04-05 18:21:49 +02:00
|
|
|
MultipleReporters( Ptr<IStreamingReporter> const& reporter )
|
|
|
|
: m_reporter( reporter )
|
|
|
|
, m_next( CATCH_NULL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MultipleReporters( Ptr<IStreamingReporter> const& first, Ptr<IStreamingReporter> const& second )
|
|
|
|
: m_reporter( first )
|
|
|
|
, m_next( new MultipleReporters( second ) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
void add( Ptr<IStreamingReporter> const& reporter ) {
|
2016-04-05 18:21:49 +02:00
|
|
|
if( m_next )
|
|
|
|
m_next->add( reporter );
|
|
|
|
else
|
|
|
|
m_next = new MultipleReporters( reporter );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
public: // IStreamingReporter
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
return m_reporter->getPreferences();
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->noMatchingTestCases( spec );
|
|
|
|
if( m_next )
|
|
|
|
m_next->noMatchingTestCases( spec );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testRunStarting( testRunInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testRunStarting( testRunInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testGroupStarting( groupInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testGroupStarting( groupInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testCaseStarting( testInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testCaseStarting( testInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->sectionStarting( sectionInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->sectionStarting( sectionInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->assertionStarting( assertionInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->assertionStarting( assertionInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
// The return value indicates if the messages buffer should be cleared:
|
|
|
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
bool clearBuffer = m_reporter->assertionEnded( assertionStats );
|
|
|
|
// Be careful with how the two calls' return values are anded.
|
|
|
|
// We don't want short-circuiting to eliminate one of the calls.
|
|
|
|
if( m_next && m_next->assertionEnded( assertionStats ) )
|
|
|
|
return true;
|
2015-08-05 20:02:17 +02:00
|
|
|
return clearBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->sectionEnded( sectionStats );
|
|
|
|
if( m_next )
|
|
|
|
m_next->sectionEnded( sectionStats );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testCaseEnded( testCaseStats );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testCaseEnded( testCaseStats );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testGroupEnded( testGroupStats );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testGroupEnded( testGroupStats );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->testRunEnded( testRunStats );
|
|
|
|
if( m_next )
|
|
|
|
m_next->testRunEnded( testRunStats );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
2016-04-05 18:21:49 +02:00
|
|
|
m_reporter->skipTest( testInfo );
|
|
|
|
if( m_next )
|
|
|
|
m_next->skipTest( testInfo );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
2016-04-05 18:21:49 +02:00
|
|
|
if( !existingReporter )
|
|
|
|
return additionalReporter;
|
|
|
|
return Ptr<IStreamingReporter>( new MultipleReporters(existingReporter, additionalReporter) );
|
2015-08-05 20:02:17 +02:00
|
|
|
}
|
2015-11-04 19:01:28 +01:00
|
|
|
|
|
|
|
|
2015-08-05 20:02:17 +02:00
|
|
|
} // end namespace Catch
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|