mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Merge branch 'dev-performance-round2'
This commit is contained in:
commit
615aa071a8
@ -56,7 +56,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string AssertionResult::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
if( isFalseTest( m_info.resultDisposition ) )
|
if( isFalseTest( m_info.resultDisposition ) )
|
||||||
return "!" + m_info.capturedExpression;
|
return '!' + m_info.capturedExpression;
|
||||||
else
|
else
|
||||||
return m_info.capturedExpression;
|
return m_info.capturedExpression;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace Catch {
|
|||||||
if( _warning == "NoAssertions" )
|
if( _warning == "NoAssertions" )
|
||||||
config.warnings = static_cast<WarnAbout::What>( config.warnings | WarnAbout::NoAssertions );
|
config.warnings = static_cast<WarnAbout::What>( config.warnings | WarnAbout::NoAssertions );
|
||||||
else
|
else
|
||||||
throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
|
throw std::runtime_error( "Unrecognised warning: '" + _warning + '\'' );
|
||||||
}
|
}
|
||||||
inline void setOrder( ConfigData& config, std::string const& order ) {
|
inline void setOrder( ConfigData& config, std::string const& order ) {
|
||||||
if( startsWith( "declared", order ) )
|
if( startsWith( "declared", order ) )
|
||||||
@ -40,7 +40,7 @@ namespace Catch {
|
|||||||
else if( startsWith( "random", order ) )
|
else if( startsWith( "random", order ) )
|
||||||
config.runOrder = RunTests::InRandomOrder;
|
config.runOrder = RunTests::InRandomOrder;
|
||||||
else
|
else
|
||||||
throw std::runtime_error( "Unrecognised ordering: '" + order + "'" );
|
throw std::runtime_error( "Unrecognised ordering: '" + order + '\'' );
|
||||||
}
|
}
|
||||||
inline void setRngSeed( ConfigData& config, std::string const& seed ) {
|
inline void setRngSeed( ConfigData& config, std::string const& seed ) {
|
||||||
if( seed == "time" ) {
|
if( seed == "time" ) {
|
||||||
@ -88,7 +88,7 @@ namespace Catch {
|
|||||||
line = trim(line);
|
line = trim(line);
|
||||||
if( !line.empty() && !startsWith( line, '#' ) ) {
|
if( !line.empty() && !startsWith( line, '#' ) ) {
|
||||||
if( !startsWith( line, '"' ) )
|
if( !startsWith( line, '"' ) )
|
||||||
line = "\"" + line + "\"";
|
line = '"' + line + '"';
|
||||||
addTestOrTags( config, line + ',' );
|
addTestOrTags( config, line + ',' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ namespace Catch {
|
|||||||
|
|
||||||
SourceLineInfo();
|
SourceLineInfo();
|
||||||
SourceLineInfo( char const* _file, std::size_t _line );
|
SourceLineInfo( char const* _file, std::size_t _line );
|
||||||
SourceLineInfo( SourceLineInfo const& other );
|
|
||||||
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
|
||||||
|
SourceLineInfo(SourceLineInfo const& other) = default;
|
||||||
SourceLineInfo( SourceLineInfo && ) = default;
|
SourceLineInfo( SourceLineInfo && ) = default;
|
||||||
SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
|
SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
|
||||||
SourceLineInfo& operator = ( SourceLineInfo && ) = default;
|
SourceLineInfo& operator = ( SourceLineInfo && ) = default;
|
||||||
@ -112,7 +112,7 @@ namespace Catch {
|
|||||||
bool operator == ( SourceLineInfo const& other ) const;
|
bool operator == ( SourceLineInfo const& other ) const;
|
||||||
bool operator < ( SourceLineInfo const& other ) const;
|
bool operator < ( SourceLineInfo const& other ) const;
|
||||||
|
|
||||||
std::string file;
|
char const* file;
|
||||||
std::size_t line;
|
std::size_t line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
bool startsWith( std::string const& s, std::string const& prefix ) {
|
bool startsWith( std::string const& s, std::string const& prefix ) {
|
||||||
@ -69,29 +71,25 @@ namespace Catch {
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
|
std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
|
||||||
os << pluraliser.m_count << " " << pluraliser.m_label;
|
os << pluraliser.m_count << ' ' << pluraliser.m_label;
|
||||||
if( pluraliser.m_count != 1 )
|
if( pluraliser.m_count != 1 )
|
||||||
os << "s";
|
os << 's';
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLineInfo::SourceLineInfo() : line( 0 ){}
|
SourceLineInfo::SourceLineInfo() : file(""), line( 0 ){}
|
||||||
SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line )
|
SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line )
|
||||||
: file( _file ),
|
: file( _file ),
|
||||||
line( _line )
|
line( _line )
|
||||||
{}
|
{}
|
||||||
SourceLineInfo::SourceLineInfo( SourceLineInfo const& other )
|
|
||||||
: file( other.file ),
|
|
||||||
line( other.line )
|
|
||||||
{}
|
|
||||||
bool SourceLineInfo::empty() const {
|
bool SourceLineInfo::empty() const {
|
||||||
return file.empty();
|
return file[0] == '\0';
|
||||||
}
|
}
|
||||||
bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const {
|
bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const {
|
||||||
return line == other.line && file == other.file;
|
return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);
|
||||||
}
|
}
|
||||||
bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const {
|
bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const {
|
||||||
return line < other.line || ( line == other.line && file < other.file );
|
return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void seedRng( IConfig const& config ) {
|
void seedRng( IConfig const& config ) {
|
||||||
@ -113,7 +111,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
|
void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << locationInfo << ": Internal Catch error: '" << message << "'";
|
oss << locationInfo << ": Internal Catch error: '" << message << '\'';
|
||||||
if( alwaysTrue() )
|
if( alwaysTrue() )
|
||||||
throw std::logic_error( oss.str() );
|
throw std::logic_error( oss.str() );
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ namespace Catch {
|
|||||||
matchedTests++;
|
matchedTests++;
|
||||||
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
||||||
if( startsWith( testCaseInfo.name, '#' ) )
|
if( startsWith( testCaseInfo.name, '#' ) )
|
||||||
Catch::cout() << "\"" << testCaseInfo.name << "\"" << std::endl;
|
Catch::cout() << '"' << testCaseInfo.name << '"' << std::endl;
|
||||||
else
|
else
|
||||||
Catch::cout() << testCaseInfo.name << std::endl;
|
Catch::cout() << testCaseInfo.name << std::endl;
|
||||||
}
|
}
|
||||||
@ -132,9 +132,9 @@ namespace Catch {
|
|||||||
.setInitialIndent( 0 )
|
.setInitialIndent( 0 )
|
||||||
.setIndent( oss.str().size() )
|
.setIndent( oss.str().size() )
|
||||||
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
|
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
|
||||||
Catch::cout() << oss.str() << wrapper << "\n";
|
Catch::cout() << oss.str() << wrapper << '\n';
|
||||||
}
|
}
|
||||||
Catch::cout() << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl;
|
Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl;
|
||||||
return tagCounts.size();
|
return tagCounts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,9 +153,9 @@ namespace Catch {
|
|||||||
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
|
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
|
||||||
Catch::cout() << " "
|
Catch::cout() << " "
|
||||||
<< it->first
|
<< it->first
|
||||||
<< ":"
|
<< ':'
|
||||||
<< std::string( maxNameLen - it->first.size() + 2, ' ' )
|
<< std::string( maxNameLen - it->first.size() + 2, ' ' )
|
||||||
<< wrapper << "\n";
|
<< wrapper << '\n';
|
||||||
}
|
}
|
||||||
Catch::cout() << std::endl;
|
Catch::cout() << std::endl;
|
||||||
return factories.size();
|
return factories.size();
|
||||||
|
@ -202,7 +202,7 @@ namespace Matchers {
|
|||||||
return m_data.m_str == m_data.adjustString( expr );;
|
return m_data.m_str == m_data.adjustString( expr );;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
return "equals: \"" + m_data.m_str + '"' + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
CasedString m_data;
|
CasedString m_data;
|
||||||
@ -219,7 +219,7 @@ namespace Matchers {
|
|||||||
return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
|
return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
return "contains: \"" + m_data.m_str + '"' + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
CasedString m_data;
|
CasedString m_data;
|
||||||
@ -237,7 +237,7 @@ namespace Matchers {
|
|||||||
return startsWith( m_data.adjustString( expr ), m_data.m_str );
|
return startsWith( m_data.adjustString( expr ), m_data.m_str );
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
return "starts with: \"" + m_data.m_str + '"' + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
CasedString m_data;
|
CasedString m_data;
|
||||||
@ -254,7 +254,7 @@ namespace Matchers {
|
|||||||
return endsWith( m_data.adjustString( expr ), m_data.m_str );
|
return endsWith( m_data.adjustString( expr ), m_data.m_str );
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
|
return "ends with: \"" + m_data.m_str + '"' + m_data.toStringSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
CasedString m_data;
|
CasedString m_data;
|
||||||
|
@ -61,7 +61,7 @@ namespace Catch {
|
|||||||
m_ofs.open( filename.c_str() );
|
m_ofs.open( filename.c_str() );
|
||||||
if( m_ofs.fail() ) {
|
if( m_ofs.fail() ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Unable to open file: '" << filename << "'";
|
oss << "Unable to open file: '" << filename << '\'';
|
||||||
throw std::domain_error( oss.str() );
|
throw std::domain_error( oss.str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
|
for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
|
||||||
oss << "[" << *it << "]";
|
oss << '[' << *it << ']';
|
||||||
std::string lcaseTag = toLower( *it );
|
std::string lcaseTag = toLower( *it );
|
||||||
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
|
testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
|
||||||
testCaseInfo.lcaseTags.insert( lcaseTag );
|
testCaseInfo.lcaseTags.insert( lcaseTag );
|
||||||
|
@ -69,7 +69,7 @@ std::string toString( std::string const& value ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "\"" + s + "\"";
|
return '"' + s + '"';
|
||||||
}
|
}
|
||||||
std::string toString( std::wstring const& value ) {
|
std::string toString( std::wstring const& value ) {
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ std::string toString( const double value ) {
|
|||||||
return fpToString( value, 10 );
|
return fpToString( value, 10 );
|
||||||
}
|
}
|
||||||
std::string toString( const float value ) {
|
std::string toString( const float value ) {
|
||||||
return fpToString( value, 5 ) + "f";
|
return fpToString( value, 5 ) + 'f';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString( bool value ) {
|
std::string toString( bool value ) {
|
||||||
|
@ -26,13 +26,13 @@ namespace Catch {
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& os, Version const& version ) {
|
std::ostream& operator << ( std::ostream& os, Version const& version ) {
|
||||||
os << version.majorVersion << "."
|
os << version.majorVersion << '.'
|
||||||
<< version.minorVersion << "."
|
<< version.minorVersion << '.'
|
||||||
<< version.patchNumber;
|
<< version.patchNumber;
|
||||||
|
|
||||||
if( !version.branchName.empty() ) {
|
if( !version.branchName.empty() ) {
|
||||||
os << "-" << version.branchName
|
os << '-' << version.branchName
|
||||||
<< "." << version.buildNumber;
|
<< '.' << version.buildNumber;
|
||||||
}
|
}
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ namespace Catch {
|
|||||||
XmlWriter& startElement( std::string const& name ) {
|
XmlWriter& startElement( std::string const& name ) {
|
||||||
ensureTagClosed();
|
ensureTagClosed();
|
||||||
newlineIfNecessary();
|
newlineIfNecessary();
|
||||||
stream() << m_indent << "<" << name;
|
stream() << m_indent << '<' << name;
|
||||||
m_tags.push_back( name );
|
m_tags.push_back( name );
|
||||||
m_indent += " ";
|
m_indent += " ";
|
||||||
m_tagIsOpen = true;
|
m_tagIsOpen = true;
|
||||||
@ -165,12 +165,12 @@ namespace Catch {
|
|||||||
|
|
||||||
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
|
||||||
if( !name.empty() && !attribute.empty() )
|
if( !name.empty() && !attribute.empty() )
|
||||||
stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
|
stream() << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
|
||||||
stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
|
stream() << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void newlineIfNecessary() {
|
void newlineIfNecessary() {
|
||||||
if( m_needsNewline ) {
|
if( m_needsNewline ) {
|
||||||
stream() << "\n";
|
stream() << '\n';
|
||||||
m_needsNewline = false;
|
m_needsNewline = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& spec ) {
|
virtual void noMatchingTestCases( std::string const& spec ) {
|
||||||
stream << "No test cases matched '" << spec << "'" << std::endl;
|
stream << "No test cases matched '" << spec << '\'' << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {
|
virtual void assertionStarting( AssertionInfo const& ) {
|
||||||
@ -61,7 +61,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
||||||
printTotals( _testRunStats.totals );
|
printTotals( _testRunStats.totals );
|
||||||
stream << "\n" << std::endl;
|
stream << '\n' << std::endl;
|
||||||
StreamingReporterBase::testRunEnded( _testRunStats );
|
StreamingReporterBase::testRunEnded( _testRunStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,26 +161,26 @@ namespace Catch {
|
|||||||
|
|
||||||
void printSourceInfo() const {
|
void printSourceInfo() const {
|
||||||
Colour colourGuard( Colour::FileName );
|
Colour colourGuard( Colour::FileName );
|
||||||
stream << result.getSourceInfo() << ":";
|
stream << result.getSourceInfo() << ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
void printResultType( Colour::Code colour, std::string passOrFail ) const {
|
void printResultType( Colour::Code colour, std::string passOrFail ) const {
|
||||||
if( !passOrFail.empty() ) {
|
if( !passOrFail.empty() ) {
|
||||||
{
|
{
|
||||||
Colour colourGuard( colour );
|
Colour colourGuard( colour );
|
||||||
stream << " " << passOrFail;
|
stream << ' ' << passOrFail;
|
||||||
}
|
}
|
||||||
stream << ":";
|
stream << ':';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printIssue( std::string issue ) const {
|
void printIssue( std::string issue ) const {
|
||||||
stream << " " << issue;
|
stream << ' ' << issue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printExpressionWas() {
|
void printExpressionWas() {
|
||||||
if( result.hasExpression() ) {
|
if( result.hasExpression() ) {
|
||||||
stream << ";";
|
stream << ';';
|
||||||
{
|
{
|
||||||
Colour colour( dimColour() );
|
Colour colour( dimColour() );
|
||||||
stream << " expression was:";
|
stream << " expression was:";
|
||||||
@ -191,7 +191,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void printOriginalExpression() const {
|
void printOriginalExpression() const {
|
||||||
if( result.hasExpression() ) {
|
if( result.hasExpression() ) {
|
||||||
stream << " " << result.getExpression();
|
stream << ' ' << result.getExpression();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void printMessage() {
|
void printMessage() {
|
||||||
if ( itMessage != messages.end() ) {
|
if ( itMessage != messages.end() ) {
|
||||||
stream << " '" << itMessage->message << "'";
|
stream << " '" << itMessage->message << '\'';
|
||||||
++itMessage;
|
++itMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,13 +222,13 @@ namespace Catch {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Colour colourGuard( colour );
|
Colour colourGuard( colour );
|
||||||
stream << " with " << pluralise( N, "message" ) << ":";
|
stream << " with " << pluralise( N, "message" ) << ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
for(; itMessage != itEnd; ) {
|
for(; itMessage != itEnd; ) {
|
||||||
// If this assertion is a warning ignore any INFO messages
|
// If this assertion is a warning ignore any INFO messages
|
||||||
if( printInfoMessages || itMessage->type != ResultWas::Info ) {
|
if( printInfoMessages || itMessage->type != ResultWas::Info ) {
|
||||||
stream << " '" << itMessage->message << "'";
|
stream << " '" << itMessage->message << '\'';
|
||||||
if ( ++itMessage != itEnd ) {
|
if ( ++itMessage != itEnd ) {
|
||||||
Colour colourGuard( dimColour() );
|
Colour colourGuard( dimColour() );
|
||||||
stream << " and";
|
stream << " and";
|
||||||
@ -254,7 +254,7 @@ namespace Catch {
|
|||||||
// - green: Passed [both/all] N tests cases with M assertions.
|
// - green: Passed [both/all] N tests cases with M assertions.
|
||||||
|
|
||||||
std::string bothOrAll( std::size_t count ) const {
|
std::string bothOrAll( std::size_t count ) const {
|
||||||
return count == 1 ? "" : count == 2 ? "both " : "all " ;
|
return count == 1 ? std::string() : count == 2 ? "both " : "all " ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printTotals( const Totals& totals ) const {
|
void printTotals( const Totals& totals ) const {
|
||||||
@ -265,12 +265,12 @@ namespace Catch {
|
|||||||
Colour colour( Colour::ResultError );
|
Colour colour( Colour::ResultError );
|
||||||
const std::string qualify_assertions_failed =
|
const std::string qualify_assertions_failed =
|
||||||
totals.assertions.failed == totals.assertions.total() ?
|
totals.assertions.failed == totals.assertions.total() ?
|
||||||
bothOrAll( totals.assertions.failed ) : "";
|
bothOrAll( totals.assertions.failed ) : std::string();
|
||||||
stream <<
|
stream <<
|
||||||
"Failed " << bothOrAll( totals.testCases.failed )
|
"Failed " << bothOrAll( totals.testCases.failed )
|
||||||
<< pluralise( totals.testCases.failed, "test case" ) << ", "
|
<< pluralise( totals.testCases.failed, "test case" ) << ", "
|
||||||
"failed " << qualify_assertions_failed <<
|
"failed " << qualify_assertions_failed <<
|
||||||
pluralise( totals.assertions.failed, "assertion" ) << ".";
|
pluralise( totals.assertions.failed, "assertion" ) << '.';
|
||||||
}
|
}
|
||||||
else if( totals.assertions.total() == 0 ) {
|
else if( totals.assertions.total() == 0 ) {
|
||||||
stream <<
|
stream <<
|
||||||
@ -282,14 +282,14 @@ namespace Catch {
|
|||||||
Colour colour( Colour::ResultError );
|
Colour colour( Colour::ResultError );
|
||||||
stream <<
|
stream <<
|
||||||
"Failed " << pluralise( totals.testCases.failed, "test case" ) << ", "
|
"Failed " << pluralise( totals.testCases.failed, "test case" ) << ", "
|
||||||
"failed " << pluralise( totals.assertions.failed, "assertion" ) << ".";
|
"failed " << pluralise( totals.assertions.failed, "assertion" ) << '.';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Colour colour( Colour::ResultSuccess );
|
Colour colour( Colour::ResultSuccess );
|
||||||
stream <<
|
stream <<
|
||||||
"Passed " << bothOrAll( totals.testCases.passed )
|
"Passed " << bothOrAll( totals.testCases.passed )
|
||||||
<< pluralise( totals.testCases.passed, "test case" ) <<
|
<< pluralise( totals.testCases.passed, "test case" ) <<
|
||||||
" with " << pluralise( totals.assertions.passed, "assertion" ) << ".";
|
" with " << pluralise( totals.assertions.passed, "assertion" ) << '.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
||||||
stream << "No test cases matched '" << spec << "'" << std::endl;
|
stream << "No test cases matched '" << spec << '\'' << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
@ -69,12 +69,12 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
if( m_headerPrinted ) {
|
if( m_headerPrinted ) {
|
||||||
if( m_config->showDurations() == ShowDurations::Always )
|
if( m_config->showDurations() == ShowDurations::Always )
|
||||||
stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
|
stream << "Completed in " << _sectionStats.durationInSeconds << 's' << std::endl;
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( m_config->showDurations() == ShowDurations::Always )
|
if( m_config->showDurations() == ShowDurations::Always )
|
||||||
stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
|
stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << 's' << std::endl;
|
||||||
}
|
}
|
||||||
StreamingReporterBase::sectionEnded( _sectionStats );
|
StreamingReporterBase::sectionEnded( _sectionStats );
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ namespace Catch {
|
|||||||
printSummaryDivider();
|
printSummaryDivider();
|
||||||
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
||||||
printTotals( _testGroupStats.totals );
|
printTotals( _testGroupStats.totals );
|
||||||
stream << "\n" << std::endl;
|
stream << '\n' << std::endl;
|
||||||
}
|
}
|
||||||
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
||||||
}
|
}
|
||||||
@ -180,13 +180,13 @@ namespace Catch {
|
|||||||
printSourceInfo();
|
printSourceInfo();
|
||||||
if( stats.totals.assertions.total() > 0 ) {
|
if( stats.totals.assertions.total() > 0 ) {
|
||||||
if( result.isOk() )
|
if( result.isOk() )
|
||||||
stream << "\n";
|
stream << '\n';
|
||||||
printResultType();
|
printResultType();
|
||||||
printOriginalExpression();
|
printOriginalExpression();
|
||||||
printReconstructedExpression();
|
printReconstructedExpression();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stream << "\n";
|
stream << '\n';
|
||||||
}
|
}
|
||||||
printMessage();
|
printMessage();
|
||||||
}
|
}
|
||||||
@ -203,25 +203,25 @@ namespace Catch {
|
|||||||
Colour colourGuard( Colour::OriginalExpression );
|
Colour colourGuard( Colour::OriginalExpression );
|
||||||
stream << " ";
|
stream << " ";
|
||||||
stream << result.getExpressionInMacro();
|
stream << result.getExpressionInMacro();
|
||||||
stream << "\n";
|
stream << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void printReconstructedExpression() const {
|
void printReconstructedExpression() const {
|
||||||
if( result.hasExpandedExpression() ) {
|
if( result.hasExpandedExpression() ) {
|
||||||
stream << "with expansion:\n";
|
stream << "with expansion:\n";
|
||||||
Colour colourGuard( Colour::ReconstructedExpression );
|
Colour colourGuard( Colour::ReconstructedExpression );
|
||||||
stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n";
|
stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void printMessage() const {
|
void printMessage() const {
|
||||||
if( !messageLabel.empty() )
|
if( !messageLabel.empty() )
|
||||||
stream << messageLabel << ":" << "\n";
|
stream << messageLabel << ':' << '\n';
|
||||||
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
|
for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
// If this assertion is a warning ignore any INFO messages
|
// If this assertion is a warning ignore any INFO messages
|
||||||
if( printInfoMessages || it->type != ResultWas::Info )
|
if( printInfoMessages || it->type != ResultWas::Info )
|
||||||
stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
|
stream << Text( it->message, TextAttributes().setIndent(2) ) << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void printSourceInfo() const {
|
void printSourceInfo() const {
|
||||||
@ -253,7 +253,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void lazyPrintRunInfo() {
|
void lazyPrintRunInfo() {
|
||||||
stream << "\n" << getLineOfChars<'~'>() << "\n";
|
stream << '\n' << getLineOfChars<'~'>() << '\n';
|
||||||
Colour colour( Colour::SecondaryText );
|
Colour colour( Colour::SecondaryText );
|
||||||
stream << currentTestRunInfo->name
|
stream << currentTestRunInfo->name
|
||||||
<< " is a Catch v" << libraryVersion << " host application.\n"
|
<< " is a Catch v" << libraryVersion << " host application.\n"
|
||||||
@ -287,19 +287,19 @@ namespace Catch {
|
|||||||
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
||||||
|
|
||||||
if( !lineInfo.empty() ){
|
if( !lineInfo.empty() ){
|
||||||
stream << getLineOfChars<'-'>() << "\n";
|
stream << getLineOfChars<'-'>() << '\n';
|
||||||
Colour colourGuard( Colour::FileName );
|
Colour colourGuard( Colour::FileName );
|
||||||
stream << lineInfo << "\n";
|
stream << lineInfo << '\n';
|
||||||
}
|
}
|
||||||
stream << getLineOfChars<'.'>() << "\n" << std::endl;
|
stream << getLineOfChars<'.'>() << '\n' << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printClosedHeader( std::string const& _name ) {
|
void printClosedHeader( std::string const& _name ) {
|
||||||
printOpenHeader( _name );
|
printOpenHeader( _name );
|
||||||
stream << getLineOfChars<'.'>() << "\n";
|
stream << getLineOfChars<'.'>() << '\n';
|
||||||
}
|
}
|
||||||
void printOpenHeader( std::string const& _name ) {
|
void printOpenHeader( std::string const& _name ) {
|
||||||
stream << getLineOfChars<'-'>() << "\n";
|
stream << getLineOfChars<'-'>() << '\n';
|
||||||
{
|
{
|
||||||
Colour colourGuard( Colour::Headers );
|
Colour colourGuard( Colour::Headers );
|
||||||
printHeaderString( _name );
|
printHeaderString( _name );
|
||||||
@ -316,7 +316,7 @@ namespace Catch {
|
|||||||
i = 0;
|
i = 0;
|
||||||
stream << Text( _string, TextAttributes()
|
stream << Text( _string, TextAttributes()
|
||||||
.setIndent( indent+i)
|
.setIndent( indent+i)
|
||||||
.setInitialIndent( indent ) ) << "\n";
|
.setInitialIndent( indent ) ) << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SummaryColumn {
|
struct SummaryColumn {
|
||||||
@ -331,9 +331,9 @@ namespace Catch {
|
|||||||
std::string row = oss.str();
|
std::string row = oss.str();
|
||||||
for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
|
for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
|
||||||
while( it->size() < row.size() )
|
while( it->size() < row.size() )
|
||||||
*it = " " + *it;
|
*it = ' ' + *it;
|
||||||
while( it->size() > row.size() )
|
while( it->size() > row.size() )
|
||||||
row = " " + row;
|
row = ' ' + row;
|
||||||
}
|
}
|
||||||
rows.push_back( row );
|
rows.push_back( row );
|
||||||
return *this;
|
return *this;
|
||||||
@ -353,8 +353,8 @@ namespace Catch {
|
|||||||
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
|
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
|
||||||
stream << " ("
|
stream << " ("
|
||||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||||
<< pluralise( totals.testCases.passed, "test case" ) << ")"
|
<< pluralise( totals.testCases.passed, "test case" ) << ')'
|
||||||
<< "\n";
|
<< '\n';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -389,10 +389,10 @@ namespace Catch {
|
|||||||
else if( value != "0" ) {
|
else if( value != "0" ) {
|
||||||
stream << Colour( Colour::LightGrey ) << " | ";
|
stream << Colour( Colour::LightGrey ) << " | ";
|
||||||
stream << Colour( it->colour )
|
stream << Colour( it->colour )
|
||||||
<< value << " " << it->label;
|
<< value << ' ' << it->label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream << "\n";
|
stream << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
|
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
|
||||||
@ -428,10 +428,10 @@ namespace Catch {
|
|||||||
else {
|
else {
|
||||||
stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
|
stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
|
||||||
}
|
}
|
||||||
stream << "\n";
|
stream << '\n';
|
||||||
}
|
}
|
||||||
void printSummaryDivider() {
|
void printSummaryDivider() {
|
||||||
stream << getLineOfChars<'-'>() << "\n";
|
stream << getLineOfChars<'-'>() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -146,7 +146,7 @@ namespace Catch {
|
|||||||
SectionNode const& sectionNode ) {
|
SectionNode const& sectionNode ) {
|
||||||
std::string name = trim( sectionNode.stats.sectionInfo.name );
|
std::string name = trim( sectionNode.stats.sectionInfo.name );
|
||||||
if( !rootName.empty() )
|
if( !rootName.empty() )
|
||||||
name = rootName + "/" + name;
|
name = rootName + '/' + name;
|
||||||
|
|
||||||
if( !sectionNode.assertions.empty() ||
|
if( !sectionNode.assertions.empty() ||
|
||||||
!sectionNode.stdOut.empty() ||
|
!sectionNode.stdOut.empty() ||
|
||||||
@ -224,14 +224,14 @@ namespace Catch {
|
|||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if( !result.getMessage().empty() )
|
if( !result.getMessage().empty() )
|
||||||
oss << result.getMessage() << "\n";
|
oss << result.getMessage() << '\n';
|
||||||
for( std::vector<MessageInfo>::const_iterator
|
for( std::vector<MessageInfo>::const_iterator
|
||||||
it = stats.infoMessages.begin(),
|
it = stats.infoMessages.begin(),
|
||||||
itEnd = stats.infoMessages.end();
|
itEnd = stats.infoMessages.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it )
|
++it )
|
||||||
if( it->type == ResultWas::Info )
|
if( it->type == ResultWas::Info )
|
||||||
oss << it->message << "\n";
|
oss << it->message << '\n';
|
||||||
|
|
||||||
oss << "at " << result.getSourceInfo();
|
oss << "at " << result.getSourceInfo();
|
||||||
xml.writeText( oss.str(), false );
|
xml.writeText( oss.str(), false );
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
Successful tests -- CHECK: median: 0.7689014999999999 (s), stddev: 0.02127512078801068 (s)
|
||||||
|
Successful tests -- REQUIRE: median: 0.772845 (s), stddev: 0.03011638381365052 (s)
|
||||||
|
Unsuccessful tests -- CHECK: median: 15.49 (s), stddev: 0.536088571143903 (s)
|
@ -0,0 +1,3 @@
|
|||||||
|
Successful tests -- CHECK: median: 0.775769 (s), stddev: 0.014802129132136525 (s)
|
||||||
|
Successful tests -- REQUIRE: median: 0.785235 (s), stddev: 0.03532672836834896 (s)
|
||||||
|
Unsuccessful tests -- CHECK: median: 15.156600000000001 (s), stddev: 0.2832375673450742 (s)
|
Loading…
Reference in New Issue
Block a user