Clara: added test for positional arg

This commit is contained in:
Phil Nash 2013-05-20 18:45:33 +01:00
parent 3dde25be7d
commit 30cb460d42
1 changed files with 14 additions and 7 deletions

View File

@ -584,11 +584,6 @@ struct Config {
std::string reporter; std::string reporter;
std::vector<std::string> warnings; std::vector<std::string> warnings;
std::vector<std::string> testsOrTags; std::vector<std::string> testsOrTags;
// void abortAfterFirst() { abortAfter = 1; }
// void abortAfterX( int x ) { abortAfter = x; }
// void addWarning( std::string const& _warning ) { warnings.push_back( _warning ); }
// void addTestOrTags( std::string const& _testSpec ) { testsOrTags.push_back( _testSpec ); }
}; };
inline void abortAfterFirst( Config& config ) { config.abortAfter = 1; } inline void abortAfterFirst( Config& config ) { config.abortAfter = 1; }
@ -699,6 +694,7 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
const char* argv[] = { "test", "-a" }; const char* argv[] = { "test", "-a" };
parseInto( cli, argv, config ); parseInto( cli, argv, config );
THEN( "The flag is set" )
REQUIRE( config.abortAfter == 1 ); REQUIRE( config.abortAfter == 1 );
} }
WHEN( "A flag is set via a unary method" ) { WHEN( "A flag is set via a unary method" ) {
@ -707,8 +703,19 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
const char* argv[] = { "test", "-x", "2" }; const char* argv[] = { "test", "-x", "2" };
parseInto( cli, argv, config ); parseInto( cli, argv, config );
THEN( "The flag is set" )
REQUIRE( config.abortAfter == 2 ); REQUIRE( config.abortAfter == 2 );
} }
WHEN( "A positional argument is supplied" ) {
const char* argv[] = { "test", "[hello]" };
parseInto( cli, argv, config );
THEN( "The argument is in the testOrTags collection" ) {
REQUIRE( config.testsOrTags.size() == 1 );
REQUIRE( config.testsOrTags[0] == "[hello]" );
}
}
} }
} }