Removed all trailing whitespace

- addresses #105
This commit is contained in:
Phil Nash
2013-07-03 19:14:59 +01:00
parent 503d5d0c8e
commit f3d1f08c3b
62 changed files with 527 additions and 527 deletions

View File

@@ -16,23 +16,23 @@
namespace Catch {
class BasicReporter : public SharedImpl<IReporter> {
struct SpanInfo {
SpanInfo()
SpanInfo()
: emitted( false )
{}
SpanInfo( const std::string& spanName )
SpanInfo( const std::string& spanName )
: name( spanName ),
emitted( false )
{}
SpanInfo( const SpanInfo& other )
SpanInfo( const SpanInfo& other )
: name( other.name ),
emitted( other.emitted )
{}
std::string name;
bool emitted;
};
@@ -45,7 +45,7 @@ namespace Catch {
{}
virtual ~BasicReporter();
static std::string getDescription() {
return "Reports test results as lines of text";
}
@@ -81,10 +81,10 @@ namespace Catch {
}
private: // IReporter
virtual bool shouldRedirectStdout() const {
return false;
}
}
virtual void StartTesting() {
m_testingSpan = SpanInfo();
@@ -119,11 +119,11 @@ namespace Catch {
m_groupSpan = SpanInfo();
}
}
virtual void StartTestCase( const TestCaseInfo& testInfo ) {
m_testSpan = testInfo.name;
}
virtual void StartSection( const std::string& sectionName, const std::string& ) {
m_sectionSpans.push_back( SpanInfo( sectionName ) );
}
@@ -144,7 +144,7 @@ namespace Catch {
SpanInfo& sectionSpan = m_sectionSpans.back();
if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
m_config.stream() << "[End of section: '" << sectionName << "' ";
if( assertions.failed ) {
Colour colour( Colour::ResultError );
ReportCounts( "assertion", assertions);
@@ -158,18 +158,18 @@ namespace Catch {
}
m_sectionSpans.pop_back();
}
virtual void Result( const AssertionResult& assertionResult ) {
if( !m_config.fullConfig()->includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok )
return;
startSpansLazily();
if( !assertionResult.getSourceInfo().empty() ) {
Colour colour( Colour::FileName );
m_config.stream() << assertionResult.getSourceInfo() << ": ";
}
if( assertionResult.hasExpression() ) {
Colour colour( Colour::OriginalExpression );
m_config.stream() << assertionResult.getExpression();
@@ -250,7 +250,7 @@ namespace Catch {
}
break;
}
if( assertionResult.hasExpandedExpression() ) {
m_config.stream() << " for: ";
if( assertionResult.getExpandedExpression().size() > 40 ) {
@@ -263,30 +263,30 @@ namespace Catch {
}
m_config.stream() << std::endl;
}
virtual void EndTestCase( const TestCaseInfo& testInfo,
virtual void EndTestCase( const TestCaseInfo& testInfo,
const Totals& totals,
const std::string& stdOut,
const std::string& stdOut,
const std::string& stdErr ) {
if( !stdOut.empty() ) {
startSpansLazily();
streamVariableLengthText( "stdout", stdOut );
}
if( !stdErr.empty() ) {
startSpansLazily();
streamVariableLengthText( "stderr", stdErr );
}
if( m_testSpan.emitted ) {
m_config.stream() << "[Finished: '" << testInfo.name << "' ";
ReportCounts( totals );
m_config.stream() << "]" << std::endl;
}
}
}
private: // helpers
void startSpansLazily() {
if( !m_testingSpan.emitted ) {
if( m_config.fullConfig()->name().empty() )
@@ -295,17 +295,17 @@ namespace Catch {
m_config.stream() << "[Started testing: " << m_config.fullConfig()->name() << "]" << std::endl;
m_testingSpan.emitted = true;
}
if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
m_config.stream() << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
m_groupSpan.emitted = true;
}
if( !m_testSpan.emitted ) {
m_config.stream() << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
m_testSpan.emitted = true;
}
if( !m_sectionSpans.empty() ) {
SpanInfo& sectionSpan = m_sectionSpans.back();
if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
@@ -320,34 +320,34 @@ namespace Catch {
if( !prevSpan.emitted && !prevSpan.name.empty() ) {
m_config.stream() << "[Started section: '" << prevSpan.name << "']" << std::endl;
prevSpan.emitted = true;
}
}
}
}
}
}
void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
std::string trimmed = trim( text );
if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
m_config.stream() << "[" << prefix << ": " << trimmed << "]";
}
else {
m_config.stream() << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
m_config.stream() << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
<< "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
}
}
private:
ReporterConfig m_config;
bool m_firstSectionInTestCase;
SpanInfo m_testingSpan;
SpanInfo m_groupSpan;
SpanInfo m_testSpan;
std::vector<SpanInfo> m_sectionSpans;
bool m_aborted;
};
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED

View File

@@ -35,17 +35,17 @@ namespace Catch {
virtual void noMatchingTestCases( std::string const& spec ) {
stream << "No test cases matched '" << spec << "'" << std::endl;
}
virtual void assertionStarting( AssertionInfo const& ) {
}
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
AssertionResult const& result = _assertionStats.assertionResult;
// Drop out if result was successful and we're not printing those
if( !m_config->includeSuccessfulResults() && result.isOk() )
return false;
lazyPrint();
AssertionPrinter printer( stream, _assertionStats );
@@ -96,7 +96,7 @@ namespace Catch {
}
private:
class AssertionPrinter {
void operator= ( AssertionPrinter const& );
public:
@@ -165,7 +165,7 @@ namespace Catch {
break;
}
}
void print() const {
printSourceInfo();
if( stats.totals.assertions.total() > 0 ) {
@@ -180,7 +180,7 @@ namespace Catch {
}
printMessage();
}
private:
void printResultType() const {
if( !passOrFail.empty() ) {
@@ -208,7 +208,7 @@ namespace Catch {
stream << messageLabel << ":" << "\n";
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
it != itEnd;
++it ) {
++it ) {
stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
}
}
@@ -216,7 +216,7 @@ namespace Catch {
Colour colourGuard( Colour::FileName );
stream << result.getSourceInfo() << ": ";
}
std::ostream& stream;
AssertionStats const& stats;
AssertionResult const& result;
@@ -226,14 +226,14 @@ namespace Catch {
std::string message;
std::vector<MessageInfo> messages;
};
void lazyPrint() {
if( testRunInfo )
lazyPrintRunInfo();
if( unusedGroupInfo )
lazyPrintGroupInfo();
if( !m_headerPrinted ) {
printTestCaseAndSectionHeader();
m_headerPrinted = true;
@@ -251,7 +251,7 @@ namespace Catch {
stream << " (" << libraryVersion.branchName << ")";
stream << " host application.\n"
<< "Run with -? for options\n\n";
testRunInfo.reset();
}
void lazyPrintGroupInfo() {
@@ -269,9 +269,9 @@ namespace Catch {
section;
section = section->parent )
sections.push_back( section );
// Sections
if( !sections.empty() ) {
if( !sections.empty() ) {
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it )
printHeaderString( (*it)->name, 2 );
@@ -281,7 +281,7 @@ namespace Catch {
SourceLineInfo lineInfo = currentSectionInfo
? currentSectionInfo->lineInfo
: unusedTestCaseInfo->lineInfo;
if( !lineInfo.empty() ){
stream << getDashes() << "\n";
Colour colourGuard( Colour::FileName );
@@ -314,7 +314,7 @@ namespace Catch {
.setIndent( indent+i)
.setInitialIndent( indent ) ) << "\n";
}
void printTotals( const Totals& totals ) {
if( totals.assertions.total() == 0 ) {
stream << "No tests ran";
@@ -361,7 +361,7 @@ namespace Catch {
}
}
}
void printTotalsDivider() {
stream << getDoubleDashes() << "\n";
}
@@ -384,7 +384,7 @@ namespace Catch {
static const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '~' );
return dots;
}
private:
bool m_headerPrinted;
bool m_atLeastOneTestCasePrinted;

View File

@@ -18,21 +18,21 @@
namespace Catch {
class JunitReporter : public SharedImpl<IReporter> {
struct TestStats {
std::string m_element;
std::string m_resultType;
std::string m_message;
std::string m_content;
};
struct TestCaseStats {
TestCaseStats( const std::string& className, const std::string& name )
: m_className( className ),
m_name( name )
{}
double m_timeInSeconds;
std::string m_status;
std::string m_className;
@@ -42,9 +42,9 @@ namespace Catch {
std::vector<TestStats> m_testStats;
std::vector<TestCaseStats> m_sections;
};
struct Stats {
Stats( const std::string& name = std::string() )
: m_testsCount( 0 ),
m_failuresCount( 0 ),
@@ -53,17 +53,17 @@ namespace Catch {
m_timeInSeconds( 0 ),
m_name( name )
{}
std::size_t m_testsCount;
std::size_t m_failuresCount;
std::size_t m_disabledCount;
std::size_t m_errorsCount;
double m_timeInSeconds;
std::string m_name;
std::vector<TestCaseStats> m_testCaseStats;
};
public:
JunitReporter( ReporterConfig const& config )
: m_config( config ),
@@ -71,19 +71,19 @@ namespace Catch {
m_currentStats( &m_testSuiteStats )
{}
virtual ~JunitReporter();
static std::string getDescription() {
return "Reports test results in an XML format that looks like Ant's junitreport target";
}
private: // IReporter
virtual bool shouldRedirectStdout() const {
return true;
}
}
virtual void StartTesting(){}
virtual void StartGroup( const std::string& groupName ) {
if( groupName.empty() )
m_statsForSuites.push_back( Stats( m_config.fullConfig()->name() ) );
@@ -96,19 +96,19 @@ namespace Catch {
m_currentStats->m_testsCount = totals.assertions.total();
m_currentStats = &m_testSuiteStats;
}
virtual void StartSection( const std::string&, const std::string& ){}
virtual void NoAssertionsInSection( const std::string& ) {}
virtual void NoAssertionsInTestCase( const std::string& ) {}
virtual void EndSection( const std::string&, const Counts& ) {}
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.className, testInfo.name ) );
m_currentTestCaseStats.push_back( &m_currentStats->m_testCaseStats.back() );
}
virtual void Result( const Catch::AssertionResult& assertionResult ) {
if( assertionResult.getResultType() != ResultWas::Ok || m_config.fullConfig()->includeSuccessfulResults() ) {
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
@@ -153,10 +153,10 @@ namespace Catch {
stats.m_element = "* internal error *";
break;
}
testCaseStats.m_testStats.push_back( stats );
testCaseStats.m_testStats.push_back( stats );
}
}
virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) {
m_currentTestCaseStats.pop_back();
assert( m_currentTestCaseStats.empty() );
@@ -167,7 +167,7 @@ namespace Catch {
m_stdOut << stdOut << "\n";
if( !stdErr.empty() )
m_stdErr << stdErr << "\n";
}
}
virtual void Aborted() {
// !TBD
@@ -175,13 +175,13 @@ namespace Catch {
virtual void EndTesting( const Totals& ) {
XmlWriter xml( m_config.stream() );
if( m_statsForSuites.size() > 0 )
xml.startElement( "testsuites" );
std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
for(; it != itEnd; ++it ) {
XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
xml.writeAttribute( "name", it->m_name );
@@ -191,19 +191,19 @@ namespace Catch {
xml.writeAttribute( "hostname", "tbd" );
xml.writeAttribute( "time", "tbd" );
xml.writeAttribute( "timestamp", "tbd" );
OutputTestCases( xml, *it );
}
xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ), false );
xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ), false );
}
void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin();
std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end();
for(; it != itEnd; ++it ) {
XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
xml.writeAttribute( "classname", it->m_className );
xml.writeAttribute( "name", it->m_name );
@@ -220,14 +220,14 @@ namespace Catch {
}
}
void OutputTestResult( XmlWriter& xml, const TestCaseStats& stats ) {
std::vector<TestStats>::const_iterator it = stats.m_testStats.begin();
std::vector<TestStats>::const_iterator itEnd = stats.m_testStats.end();
for(; it != itEnd; ++it ) {
if( it->m_element != "success" ) {
XmlWriter::ScopedElement e = xml.scopedElement( it->m_element );
xml.writeAttribute( "message", it->m_message );
xml.writeAttribute( "type", it->m_resultType );
if( !it->m_content.empty() )
@@ -235,10 +235,10 @@ namespace Catch {
}
}
}
private:
ReporterConfig m_config;
Stats m_testSuiteStats;
Stats* m_currentStats;
std::vector<Stats> m_statsForSuites;
@@ -246,7 +246,7 @@ namespace Catch {
std::ostringstream m_stdOut;
std::ostringstream m_stdErr;
};
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED

View File

@@ -22,12 +22,12 @@ namespace Catch {
return "Reports test results as an XML document";
}
virtual ~XmlReporter();
private: // IReporter
virtual bool shouldRedirectStdout() const {
return true;
}
}
virtual void StartTesting() {
m_xml = XmlWriter( m_config.stream() );
@@ -35,14 +35,14 @@ namespace Catch {
if( !m_config.fullConfig()->name().empty() )
m_xml.writeAttribute( "name", m_config.fullConfig()->name() );
}
virtual void EndTesting( const Totals& totals ) {
m_xml.scopedElement( "OverallResults" )
.writeAttribute( "successes", totals.assertions.passed )
.writeAttribute( "failures", totals.assertions.failed );
m_xml.endElement();
}
virtual void StartGroup( const std::string& groupName ) {
m_xml.startElement( "Group" )
.writeAttribute( "name", groupName );
@@ -54,7 +54,7 @@ namespace Catch {
.writeAttribute( "failures", totals.assertions.failed );
m_xml.endElement();
}
virtual void StartSection( const std::string& sectionName, const std::string& description ) {
m_xml.startElement( "Section" )
.writeAttribute( "name", sectionName )
@@ -69,12 +69,12 @@ namespace Catch {
.writeAttribute( "failures", assertions.failed );
m_xml.endElement();
}
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name );
m_currentTestSuccess = true;
}
virtual void Result( const Catch::AssertionResult& assertionResult ) {
if( !m_config.fullConfig()->includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok )
return;
@@ -84,14 +84,14 @@ namespace Catch {
.writeAttribute( "success", assertionResult.succeeded() )
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
.writeAttribute( "line", assertionResult.getSourceInfo().line );
m_xml.scopedElement( "Original" )
.writeText( assertionResult.getExpression() );
m_xml.scopedElement( "Expanded" )
.writeText( assertionResult.getExpandedExpression() );
m_currentTestSuccess &= assertionResult.succeeded();
}
switch( assertionResult.getResultType() ) {
case ResultWas::ThrewException:
m_xml.scopedElement( "Exception" )
@@ -120,7 +120,7 @@ namespace Catch {
case ResultWas::Exception:
case ResultWas::DidntThrowException:
break;
}
}
if( assertionResult.hasExpression() )
m_xml.endElement();
}
@@ -128,12 +128,12 @@ namespace Catch {
virtual void Aborted() {
// !TBD
}
virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) {
m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
m_xml.endElement();
}
}
private:
ReporterConfig m_config;
bool m_currentTestSuccess;