merge from upstream

This commit is contained in:
Malcolm Noyes 2013-12-27 13:55:25 +00:00
commit af18bcdab7
13 changed files with 156 additions and 122 deletions

View File

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

View File

@ -144,9 +144,8 @@ namespace Catch {
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
try {
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
if( unusedOptionBehaviour == OnUnusedOptions::Fail )
enforceNoUsedTokens();
if( m_configData.showHelp )
showHelp( m_configData.processName );
m_config.reset();
@ -154,7 +153,7 @@ namespace Catch {
catch( std::exception& ex ) {
{
Colour colourGuard( Colour::Red );
std::cerr << "\nError in input:\n"
std::cerr << "\nError(s) in input:\n"
<< Text( ex.what(), TextAttributes().setIndent(2) )
<< "\n\n";
}
@ -169,18 +168,6 @@ namespace Catch {
m_config.reset();
}
void enforceNoUsedTokens() const {
if( !m_unusedTokens.empty() ) {
std::vector<Clara::Parser::Token>::const_iterator
it = m_unusedTokens.begin(),
itEnd = m_unusedTokens.end();
std::string msg;
for(; it != itEnd; ++it )
msg += " unrecognised option: " + it->data + "\n";
throw std::runtime_error( msg.substr( 0, msg.size()-1 ) );
}
}
int run( int argc, char* const argv[] ) {
int returnCode = applyCommandLine( argc, argv );

View File

@ -70,7 +70,7 @@ namespace Detail {
std::string toString() const {
std::ostringstream oss;
oss << "Approx( " << m_value << " )";
oss << "Approx( " << Catch::toString( m_value ) << " )";
return oss.str();
}

View File

@ -14,7 +14,7 @@ namespace Catch {
// These numbers are maintained by a script
template <typename T>
const T LibraryVersionInfo<T>::value( 1, 0, 20, "master" );
const T LibraryVersionInfo<T>::value( 1, 0, 23, "master" );
}
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED

View File

@ -206,7 +206,8 @@ namespace Clara {
};
void parseIntoTokens( int argc, char const * const * argv, std::vector<Parser::Token>& tokens ) const {
for( int i = 1; i < argc; ++i )
const std::string doubleDash = "--";
for( int i = 1; i < argc && argv[i] != doubleDash; ++i )
parseIntoTokens( argv[i] , tokens);
}
void parseIntoTokens( std::string arg, std::vector<Parser::Token>& tokens ) const {
@ -371,18 +372,25 @@ namespace Clara {
CommandLine()
: m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
m_highestSpecifiedArgPosition( 0 )
m_highestSpecifiedArgPosition( 0 ),
m_throwOnUnrecognisedTokens( false )
{}
CommandLine( CommandLine const& other )
: m_boundProcessName( other.m_boundProcessName ),
m_options ( other.m_options ),
m_positionalArgs( other.m_positionalArgs ),
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition )
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
{
if( other.m_arg.get() )
m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
}
CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
m_throwOnUnrecognisedTokens = shouldThrow;
return *this;
}
template<typename F>
ArgBinder bind( F f ) {
ArgBinder binder( this, f );
@ -488,6 +496,7 @@ namespace Clara {
std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
std::vector<Parser::Token> unusedTokens;
std::vector<std::string> errors;
for( std::size_t i = 0; i < tokens.size(); ++i ) {
Parser::Token const& token = tokens[i];
typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
@ -499,8 +508,9 @@ namespace Clara {
( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
if( arg.takesArg() ) {
if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
throw std::domain_error( "Expected argument to option " + token.data );
arg.boundField.set( config, tokens[++i].data );
errors.push_back( "Expected argument to option: " + token.data );
else
arg.boundField.set( config, tokens[++i].data );
}
else {
arg.boundField.setFlag( config );
@ -509,11 +519,26 @@ namespace Clara {
}
}
catch( std::exception& ex ) {
throw std::runtime_error( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
}
}
if( it == itEnd )
unusedTokens.push_back( token );
if( it == itEnd ) {
if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
unusedTokens.push_back( token );
else if( m_throwOnUnrecognisedTokens )
errors.push_back( "unrecognised option: " + token.data );
}
}
if( !errors.empty() ) {
std::ostringstream oss;
for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
it != itEnd;
++it ) {
if( it != errors.begin() )
oss << "\n";
oss << *it;
}
throw std::runtime_error( oss.str() );
}
return unusedTokens;
}
@ -552,6 +577,7 @@ namespace Clara {
std::map<int, Arg> m_positionalArgs;
ArgAutoPtr m_arg;
int m_highestSpecifiedArgPosition;
bool m_throwOnUnrecognisedTokens;
};
} // end namespace Clara

View File

@ -49,22 +49,22 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 9.11f ) )
with expansion:
9.1 == Approx( 9.11 )
9.1 == Approx( 9.1099996567 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 9.0f ) )
with expansion:
9.1 == Approx( 9 )
9.1 == Approx( 9.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 1 ) )
with expansion:
9.1 == Approx( 1 )
9.1 == Approx( 1.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 0 ) )
with expansion:
9.1 == Approx( 0 )
9.1 == Approx( 0.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.double_pi == Approx( 3.1415 ) )
@ -110,12 +110,12 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one != Approx( 9.1f ) )
with expansion:
9.1 != Approx( 9.1 )
9.1 != Approx( 9.1000003815 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.double_pi != Approx( 3.1415926535 ) )
with expansion:
3.1415926535 != Approx( 3.14159 )
3.1415926535 != Approx( 3.1415926535 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.str_hello != "hello" )
@ -569,8 +569,8 @@ with expansion:
with message:
Testing if fib[7] (21) is even
Some information
An error
A string sent directly to stdout
A string sent directly to stderr
-------------------------------------------------------------------------------
checkedIf, failing
-------------------------------------------------------------------------------

View File

@ -73,13 +73,13 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1.23f == Approx( 1.23f ) )
with expansion:
1.23 == Approx( 1.23 )
1.23 == Approx( 1.2300000191 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0.0f == Approx( 0.0f ) )
with expansion:
0 == Approx( 0 )
0 == Approx( 0.0 )
-------------------------------------------------------------------------------
Approximate comparisons with ints
@ -90,10 +90,14 @@ ApproxTests.cpp:<line number>
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1 == Approx( 1 ) )
with expansion:
1 == Approx( 1.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( 0 ) )
with expansion:
0 == Approx( 0.0 )
-------------------------------------------------------------------------------
Approximate comparisons with mixed numeric types
@ -105,19 +109,19 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1.0f == Approx( 1 ) )
with expansion:
1 == Approx( 1 )
1 == Approx( 1.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( dZero) )
with expansion:
0 == Approx( 0 )
0 == Approx( 0.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) )
with expansion:
0 == Approx( 1e-05 )
0 == Approx( 0.00001 )
ApproxTests.cpp:<line number>:
PASSED:
@ -129,7 +133,7 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( dMedium == Approx( 1.234f ) )
with expansion:
1.234 == Approx( 1.234 )
1.234 == Approx( 1.2339999676 )
-------------------------------------------------------------------------------
Use a custom approx
@ -265,13 +269,13 @@ ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) )
with expansion:
9.1 == Approx( 9.1 )
9.1 == Approx( 9.1000003815 )
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.double_pi == Approx( 3.1415926535 ) )
with expansion:
3.1415926535 == Approx( 3.14159 )
3.1415926535 == Approx( 3.1415926535 )
ConditionTests.cpp:<line number>:
PASSED:
@ -321,22 +325,22 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 9.11f ) )
with expansion:
9.1 == Approx( 9.11 )
9.1 == Approx( 9.1099996567 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 9.0f ) )
with expansion:
9.1 == Approx( 9 )
9.1 == Approx( 9.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 1 ) )
with expansion:
9.1 == Approx( 1 )
9.1 == Approx( 1.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one == Approx( 0 ) )
with expansion:
9.1 == Approx( 0 )
9.1 == Approx( 0.0 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.double_pi == Approx( 3.1415 ) )
@ -390,25 +394,25 @@ ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) )
with expansion:
9.1 != Approx( 9.11 )
9.1 != Approx( 9.1099996567 )
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one != Approx( 9.0f ) )
with expansion:
9.1 != Approx( 9 )
9.1 != Approx( 9.0 )
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one != Approx( 1 ) )
with expansion:
9.1 != Approx( 1 )
9.1 != Approx( 1.0 )
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one != Approx( 0 ) )
with expansion:
9.1 != Approx( 0 )
9.1 != Approx( 0.0 )
ConditionTests.cpp:<line number>:
PASSED:
@ -454,12 +458,12 @@ with expansion:
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.float_nine_point_one != Approx( 9.1f ) )
with expansion:
9.1 != Approx( 9.1 )
9.1 != Approx( 9.1000003815 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.double_pi != Approx( 3.1415926535 ) )
with expansion:
3.1415926535 != Approx( 3.14159 )
3.1415926535 != Approx( 3.1415926535 )
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.str_hello != "hello" )
@ -3014,8 +3018,8 @@ with expansion:
with message:
Testing if fib[7] (21) is even
Some information
An error
A string sent directly to stdout
A string sent directly to stderr
-------------------------------------------------------------------------------
Sends stuff to stdout and stderr
-------------------------------------------------------------------------------

View File

@ -73,13 +73,13 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1.23f == Approx( 1.23f ) )
with expansion:
1.23 == Approx( 1.23 )
1.23 == Approx( 1.2300000191 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0.0f == Approx( 0.0f ) )
with expansion:
0 == Approx( 0 )
0 == Approx( 0.0 )
-------------------------------------------------------------------------------
Approximate comparisons with ints
@ -90,10 +90,14 @@ ApproxTests.cpp:<line number>
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1 == Approx( 1 ) )
with expansion:
1 == Approx( 1.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( 0 ) )
with expansion:
0 == Approx( 0.0 )
-------------------------------------------------------------------------------
Approximate comparisons with mixed numeric types
@ -105,19 +109,19 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 1.0f == Approx( 1 ) )
with expansion:
1 == Approx( 1 )
1 == Approx( 1.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( dZero) )
with expansion:
0 == Approx( 0 )
0 == Approx( 0.0 )
ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) )
with expansion:
0 == Approx( 1e-05 )
0 == Approx( 0.00001 )
ApproxTests.cpp:<line number>:
PASSED:
@ -129,7 +133,7 @@ ApproxTests.cpp:<line number>:
PASSED:
REQUIRE( dMedium == Approx( 1.234f ) )
with expansion:
1.234 == Approx( 1.234 )
1.234 == Approx( 1.2339999676 )
-------------------------------------------------------------------------------
Use a custom approx
@ -265,13 +269,13 @@ ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) )
with expansion:
9.1 == Approx( 9.1 )
9.1 == Approx( 9.1000003815 )
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.double_pi == Approx( 3.1415926535 ) )
with expansion:
3.1415926535 == Approx( 3.14159 )
3.1415926535 == Approx( 3.1415926535 )
ConditionTests.cpp:<line number>:
PASSED:

View File

@ -30,16 +30,16 @@ ConditionTests.cpp:<line number>
<failure message="7 == 0" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="9.1 == Approx( 9.11 )" type="CHECK">
<failure message="9.1 == Approx( 9.1099996567 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="9.1 == Approx( 9 )" type="CHECK">
<failure message="9.1 == Approx( 9.0 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="9.1 == Approx( 1 )" type="CHECK">
<failure message="9.1 == Approx( 1.0 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="9.1 == Approx( 0 )" type="CHECK">
<failure message="9.1 == Approx( 0.0 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="3.1415926535 == Approx( 3.1415 )" type="CHECK">
@ -66,10 +66,10 @@ ConditionTests.cpp:<line number>
<failure message="7 != 7" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="9.1 != Approx( 9.1 )" type="CHECK">
<failure message="9.1 != Approx( 9.1000003815 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="3.1415926535 != Approx( 3.14159 )" type="CHECK">
<failure message="3.1415926535 != Approx( 3.1415926535 )" type="CHECK">
ConditionTests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; != &quot;hello&quot;" type="CHECK">
@ -351,10 +351,10 @@ MiscTests.cpp:<line number>
</testcase>
<testcase classname="global" name="Sends stuff to stdout and stderr" time="{duration}">
<system-out>
Some information
A string sent directly to stdout
</system-out>
<system-err>
An error
A string sent directly to stderr
</system-err>
</testcase>
<testcase classname="global" name="null strings" time="{duration}"/>
@ -550,12 +550,12 @@ TrickyTests.cpp:<line number>
<system-out>
Message from section one
Message from section two
Some information
A string sent directly to stdout
hello
hello
</system-out>
<system-err>
An error
A string sent directly to stderr
</system-err>
</testsuite>
</testsuites>

View File

@ -76,7 +76,7 @@
1.23f == Approx( 1.23f )
</Original>
<Expanded>
1.23 == Approx( 1.23 )
1.23 == Approx( 1.2300000191 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ApproxTests.cpp" >
@ -84,7 +84,7 @@
0.0f == Approx( 0.0f )
</Original>
<Expanded>
0 == Approx( 0 )
0 == Approx( 0.0 )
</Expanded>
</Expression>
<OverallResult success="true"/>
@ -95,7 +95,7 @@
1 == Approx( 1 )
</Original>
<Expanded>
1 == Approx( 1 )
1 == Approx( 1.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ApproxTests.cpp" >
@ -103,7 +103,7 @@
0 == Approx( 0 )
</Original>
<Expanded>
0 == Approx( 0 )
0 == Approx( 0.0 )
</Expanded>
</Expression>
<OverallResult success="true"/>
@ -114,7 +114,7 @@
1.0f == Approx( 1 )
</Original>
<Expanded>
1 == Approx( 1 )
1 == Approx( 1.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ApproxTests.cpp" >
@ -122,7 +122,7 @@
0 == Approx( dZero)
</Original>
<Expanded>
0 == Approx( 0 )
0 == Approx( 0.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ApproxTests.cpp" >
@ -130,7 +130,7 @@
0 == Approx( dSmall ).epsilon( 0.001 )
</Original>
<Expanded>
0 == Approx( 1e-05 )
0 == Approx( 0.00001 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ApproxTests.cpp" >
@ -146,7 +146,7 @@
dMedium == Approx( 1.234f )
</Original>
<Expanded>
1.234 == Approx( 1.234 )
1.234 == Approx( 1.2339999676 )
</Expanded>
</Expression>
<OverallResult success="true"/>
@ -295,7 +295,7 @@
data.float_nine_point_one == Approx( 9.1f )
</Original>
<Expanded>
9.1 == Approx( 9.1 )
9.1 == Approx( 9.1000003815 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -303,7 +303,7 @@
data.double_pi == Approx( 3.1415926535 )
</Original>
<Expanded>
3.1415926535 == Approx( 3.14159 )
3.1415926535 == Approx( 3.1415926535 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -370,7 +370,7 @@
data.float_nine_point_one == Approx( 9.11f )
</Original>
<Expanded>
9.1 == Approx( 9.11 )
9.1 == Approx( 9.1099996567 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -378,7 +378,7 @@
data.float_nine_point_one == Approx( 9.0f )
</Original>
<Expanded>
9.1 == Approx( 9 )
9.1 == Approx( 9.0 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -386,7 +386,7 @@
data.float_nine_point_one == Approx( 1 )
</Original>
<Expanded>
9.1 == Approx( 1 )
9.1 == Approx( 1.0 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -394,7 +394,7 @@
data.float_nine_point_one == Approx( 0 )
</Original>
<Expanded>
9.1 == Approx( 0 )
9.1 == Approx( 0.0 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -469,7 +469,7 @@
data.float_nine_point_one != Approx( 9.11f )
</Original>
<Expanded>
9.1 != Approx( 9.11 )
9.1 != Approx( 9.1099996567 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -477,7 +477,7 @@
data.float_nine_point_one != Approx( 9.0f )
</Original>
<Expanded>
9.1 != Approx( 9 )
9.1 != Approx( 9.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -485,7 +485,7 @@
data.float_nine_point_one != Approx( 1 )
</Original>
<Expanded>
9.1 != Approx( 1 )
9.1 != Approx( 1.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -493,7 +493,7 @@
data.float_nine_point_one != Approx( 0 )
</Original>
<Expanded>
9.1 != Approx( 0 )
9.1 != Approx( 0.0 )
</Expanded>
</Expression>
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -552,7 +552,7 @@
data.float_nine_point_one != Approx( 9.1f )
</Original>
<Expanded>
9.1 != Approx( 9.1 )
9.1 != Approx( 9.1000003815 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >
@ -560,7 +560,7 @@
data.double_pi != Approx( 3.1415926535 )
</Original>
<Expanded>
3.1415926535 != Approx( 3.14159 )
3.1415926535 != Approx( 3.1415926535 )
</Expanded>
</Expression>
<Expression success="false" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/ConditionTests.cpp" >

View File

@ -116,7 +116,7 @@ TEST_CASE( "cmdline" ) {
.shortOpt( "d" )
.longOpt( "description" )
.hint( "some text" );
const char* argv[] = { "test", "-n 42", "-d some text" };
std::vector<Clara::Parser::Token> unusedTokens = parseInto( cli, argv, config1 );

View File

@ -116,9 +116,9 @@ namespace MiscTests
TEST_CASE( "Sends stuff to stdout and stderr", "" )
{
std::cout << "Some information" << std::endl;
std::cout << "A string sent directly to stdout" << std::endl;
std::cerr << "An error" << std::endl;
std::cerr << "A string sent directly to stderr" << std::endl;
}
inline const char* makeString( bool makeNull )

View File

@ -1,6 +1,6 @@
/*
* CATCH v1.0 build 20 (master branch)
* Generated: 2013-12-18 08:38:15.171445
* CATCH v1.0 build 23 (master branch)
* Generated: 2013-12-23 10:22:45.547645
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -2096,7 +2096,7 @@ namespace Detail {
std::string toString() const {
std::ostringstream oss;
oss << "Approx( " << m_value << " )";
oss << "Approx( " << Catch::toString( m_value ) << " )";
return oss.str();
}
@ -3224,7 +3224,8 @@ namespace Clara {
};
void parseIntoTokens( int argc, char const * const * argv, std::vector<Parser::Token>& tokens ) const {
for( int i = 1; i < argc; ++i )
const std::string doubleDash = "--";
for( int i = 1; i < argc && argv[i] != doubleDash; ++i )
parseIntoTokens( argv[i] , tokens);
}
void parseIntoTokens( std::string arg, std::vector<Parser::Token>& tokens ) const {
@ -3389,18 +3390,25 @@ namespace Clara {
CommandLine()
: m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
m_highestSpecifiedArgPosition( 0 )
m_highestSpecifiedArgPosition( 0 ),
m_throwOnUnrecognisedTokens( false )
{}
CommandLine( CommandLine const& other )
: m_boundProcessName( other.m_boundProcessName ),
m_options ( other.m_options ),
m_positionalArgs( other.m_positionalArgs ),
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition )
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
{
if( other.m_arg.get() )
m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
}
CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
m_throwOnUnrecognisedTokens = shouldThrow;
return *this;
}
template<typename F>
ArgBinder bind( F f ) {
ArgBinder binder( this, f );
@ -3506,6 +3514,7 @@ namespace Clara {
std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
std::vector<Parser::Token> unusedTokens;
std::vector<std::string> errors;
for( std::size_t i = 0; i < tokens.size(); ++i ) {
Parser::Token const& token = tokens[i];
typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
@ -3517,8 +3526,9 @@ namespace Clara {
( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
if( arg.takesArg() ) {
if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
throw std::domain_error( "Expected argument to option " + token.data );
arg.boundField.set( config, tokens[++i].data );
errors.push_back( "Expected argument to option: " + token.data );
else
arg.boundField.set( config, tokens[++i].data );
}
else {
arg.boundField.setFlag( config );
@ -3527,11 +3537,26 @@ namespace Clara {
}
}
catch( std::exception& ex ) {
throw std::runtime_error( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
}
}
if( it == itEnd )
unusedTokens.push_back( token );
if( it == itEnd ) {
if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
unusedTokens.push_back( token );
else if( m_throwOnUnrecognisedTokens )
errors.push_back( "unrecognised option: " + token.data );
}
}
if( !errors.empty() ) {
std::ostringstream oss;
for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
it != itEnd;
++it ) {
if( it != errors.begin() )
oss << "\n";
oss << *it;
}
throw std::runtime_error( oss.str() );
}
return unusedTokens;
}
@ -3570,6 +3595,7 @@ namespace Clara {
std::map<int, Arg> m_positionalArgs;
ArgAutoPtr m_arg;
int m_highestSpecifiedArgPosition;
bool m_throwOnUnrecognisedTokens;
};
} // end namespace Clara
@ -4812,9 +4838,8 @@ namespace Catch {
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
try {
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
if( unusedOptionBehaviour == OnUnusedOptions::Fail )
enforceNoUsedTokens();
if( m_configData.showHelp )
showHelp( m_configData.processName );
m_config.reset();
@ -4822,7 +4847,7 @@ namespace Catch {
catch( std::exception& ex ) {
{
Colour colourGuard( Colour::Red );
std::cerr << "\nError in input:\n"
std::cerr << "\nError(s) in input:\n"
<< Text( ex.what(), TextAttributes().setIndent(2) )
<< "\n\n";
}
@ -4837,18 +4862,6 @@ namespace Catch {
m_config.reset();
}
void enforceNoUsedTokens() const {
if( !m_unusedTokens.empty() ) {
std::vector<Clara::Parser::Token>::const_iterator
it = m_unusedTokens.begin(),
itEnd = m_unusedTokens.end();
std::string msg;
for(; it != itEnd; ++it )
msg += " unrecognised option: " + it->data + "\n";
throw std::runtime_error( msg.substr( 0, msg.size()-1 ) );
}
}
int run( int argc, char* const argv[] ) {
int returnCode = applyCommandLine( argc, argv );
@ -6166,7 +6179,7 @@ namespace Catch {
namespace Catch {
// These numbers are maintained by a script
Version libraryVersion( 1, 0, 20, "master" );
Version libraryVersion( 1, 0, 23, "master" );
}
// #included from: catch_text.hpp