2013-04-08 12:44:03 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 6th April 2013.
|
|
|
|
* Copyright 2013 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_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include "catch_legacy_reporter_adapter.h"
|
|
|
|
|
|
|
|
namespace Catch
|
|
|
|
{
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
|
2013-05-28 19:39:32 +02:00
|
|
|
: m_legacyReporter( legacyReporter )
|
2013-04-08 12:44:03 +02:00
|
|
|
{}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE LegacyReporterAdapter::~LegacyReporterAdapter() {}
|
2013-04-08 12:44:03 +02:00
|
|
|
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE ReporterPreferences LegacyReporterAdapter::getPreferences() const {
|
2013-04-08 12:44:03 +02:00
|
|
|
ReporterPreferences prefs;
|
|
|
|
prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout();
|
|
|
|
return prefs;
|
|
|
|
}
|
|
|
|
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
|
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->StartTesting();
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->StartGroup( groupInfo.name );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->StartTestCase( testInfo );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
// Not on legacy interface
|
|
|
|
}
|
|
|
|
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
|
|
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
|
|
|
it != itEnd;
|
|
|
|
++it ) {
|
|
|
|
if( it->type == ResultWas::Info ) {
|
|
|
|
ExpressionResultBuilder expressionBuilder( it->type );
|
|
|
|
expressionBuilder << it->message;
|
|
|
|
AssertionInfo info( it->macroName, it->lineInfo, "", ResultDisposition::Normal );
|
|
|
|
AssertionResult result = expressionBuilder.buildResult( info );
|
|
|
|
m_legacyReporter->Result( result );
|
|
|
|
}
|
|
|
|
}
|
2013-07-03 20:14:59 +02:00
|
|
|
}
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->Result( assertionStats.assertionResult );
|
2013-06-28 17:25:49 +02:00
|
|
|
return true;
|
2013-04-08 12:44:03 +02:00
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
if( sectionStats.missingAssertions )
|
|
|
|
m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name );
|
|
|
|
m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->EndTestCase
|
|
|
|
( testCaseStats.testInfo,
|
|
|
|
testCaseStats.totals,
|
|
|
|
testCaseStats.stdOut,
|
|
|
|
testCaseStats.stdErr );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
if( testGroupStats.aborting )
|
|
|
|
m_legacyReporter->Aborted();
|
|
|
|
m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals );
|
|
|
|
}
|
2014-02-21 14:04:11 +01:00
|
|
|
INTERNAL_CATCH_INLINE void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
|
2013-04-08 12:44:03 +02:00
|
|
|
m_legacyReporter->EndTesting( testRunStats.totals );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
|