This commit is contained in:
Phil Nash 2014-07-09 19:22:49 +01:00
parent 3ff3acf46c
commit 28c2e07879
3 changed files with 83 additions and 35 deletions

View File

@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png)
*v1.0 build 51 (master branch)*
*v1.0 build 52 (master branch)*
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)

View File

@ -13,7 +13,7 @@
namespace Catch {
// These numbers are maintained by a script
Version libraryVersion( 1, 0, 51, "master" );
Version libraryVersion( 1, 0, 52, "master" );
}
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED

View File

@ -1,6 +1,6 @@
/*
* CATCH v1.0 build 51 (master branch)
* Generated: 2014-07-09 07:40:07.923348
* CATCH v1.0 build 52 (master branch)
* Generated: 2014-07-09 19:21:54.977279
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -1166,6 +1166,7 @@ std::string toString( int value );
std::string toString( unsigned long value );
std::string toString( unsigned int value );
std::string toString( const double value );
std::string toString( const float value );
std::string toString( bool value );
std::string toString( char value );
std::string toString( signed char value );
@ -1625,6 +1626,9 @@ namespace Catch {
std::size_t total() const {
return passed + failed + failedButOk;
}
bool allPassed() const {
return failed == 0 && failedButOk == 0;
}
std::size_t passed;
std::size_t failed;
@ -6406,7 +6410,7 @@ namespace Catch {
namespace Catch {
// These numbers are maintained by a script
Version libraryVersion( 1, 0, 51, "master" );
Version libraryVersion( 1, 0, 52, "master" );
}
// #included from: catch_message.hpp
@ -6911,9 +6915,10 @@ std::string toString( unsigned int value ) {
return toString( static_cast<unsigned long>( value ) );
}
std::string toString( const double value ) {
template<typename T>
std::string fpToString( T value, int precision ) {
std::ostringstream oss;
oss << std::setprecision( 10 )
oss << std::setprecision( precision )
<< std::fixed
<< value;
std::string d = oss.str();
@ -6926,6 +6931,13 @@ std::string toString( const double value ) {
return d;
}
std::string toString( const double value ) {
return fpToString( value, 10 );
}
std::string toString( const float value ) {
return fpToString( value, 5 ) + "f";
}
std::string toString( bool value ) {
return value ? "true" : "false";
}
@ -8309,46 +8321,79 @@ namespace Catch {
.setInitialIndent( indent ) ) << "\n";
}
struct SummaryColumn {
SummaryColumn( std::string const& _label, Colour::Code _colour )
: label( _label ),
colour( _colour )
{}
SummaryColumn addRow( std::size_t count ) {
std::ostringstream oss;
oss << count;
std::string row = oss.str();
for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
while( it->size() < row.size() )
while( it->size() > row.size() )
row = " " + row;
}
rows.push_back( row );
return *this;
}
std::string label;
Colour::Code colour;
std::vector<std::string> rows;
};
void printTotals( Totals const& totals ) {
int cols = 1+static_cast<int>( log10( static_cast<float>( (std::max)( totals.testCases.total(), totals.assertions.total() ) ) ) );
if( totals.testCases.total() == 0 ) {
stream << Colour( Colour::Warning ) << "No tests ran\n";
}
else if( totals.assertions.total() == 0 ) {
stream << "test cases: ";
printCounts( totals.testCases, cols );
stream << "assertions: ";
stream << Colour( Colour::Warning ) << "- none -\n";
}
else if( totals.assertions.failed + totals.assertions.failedButOk ) {
stream << "test cases: ";
printCounts( totals.testCases, cols );
stream << "assertions: ";
printCounts( totals.assertions, cols );
}
else {
else if( totals.assertions.total() > 0 && totals.assertions.allPassed() ) {
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
stream << " ("
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
<< pluralise( totals.testCases.passed, "test case" ) << ")"
<< "\n";
}
}
void printCounts( Counts const& counts, int cols ) {
stream << Colour( counts.passed > 0 ? Colour::Success : Colour::LightGrey )
<< std::setw( cols ) << counts.passed << " passed";
else {
stream << Colour( Colour::LightGrey ) << " | ";
std::vector<SummaryColumn> columns;
columns.push_back( SummaryColumn( "", Colour::None )
.addRow( totals.testCases.total() )
.addRow( totals.assertions.total() ) );
columns.push_back( SummaryColumn( "passed", Colour::Success )
.addRow( totals.testCases.passed )
.addRow( totals.assertions.passed ) );
columns.push_back( SummaryColumn( "failed", Colour::ResultError )
.addRow( totals.testCases.failed )
.addRow( totals.assertions.failed ) );
columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure )
.addRow( totals.testCases.failedButOk )
.addRow( totals.assertions.failedButOk ) );
stream << Colour( counts.failed > 0 ? Colour::ResultError : Colour::LightGrey )
<< std::setw( cols ) << counts.failed << " failed";
if( counts.failedButOk > 0 ) {
stream << Colour( Colour::LightGrey ) << " | ";
stream << Colour( counts.failedButOk > 0 ? Colour::ResultExpectedFailure : Colour::LightGrey )
<< std::setw( cols ) << counts.failedButOk << " failed as expected";
printSummaryRow( "test cases", columns, 0 );
printSummaryRow( "assertions", columns, 1 );
}
stream << Colour( Colour::LightGrey ) << " | "
<< "total: " << counts.total() << "\n";
}
void printSummaryRow( std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row ) {
for( std::vector<SummaryColumn>::const_iterator it = cols.begin(); it != cols.end(); ++it ) {
std::string value = it->rows[row];
if( it->label.empty() ) {
stream << label << ": ";
if( value != "0" )
stream << value;
else
stream << Colour( Colour::Warning ) << "- none -";
}
else if( value != "0" ) {
stream << Colour( Colour::LightGrey ) << " | ";
stream << Colour( it->colour )
<< value << " " << it->label;
}
}
stream << "\n";
}
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
@ -8374,9 +8419,12 @@ namespace Catch {
while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 )
findMax( failedRatio, failedButOkRatio, passedRatio )--;
stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' );
stream << Colour( Colour::Error ) << std::string( failedRatio, '=' );
stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' );
if( totals.testCases.allPassed() )
stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' );
else
stream << Colour( Colour::Success ) << std::string( passedRatio, '=' );
}
else {
stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );