mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-01 09:27:54 +00:00
Improved error handling for --abort as per #108
This commit is contained in:
parent
6f220863cf
commit
b084562b3b
3 changed files with 16 additions and 3 deletions
|
@ -68,6 +68,7 @@ template<size_t size>
|
|||
std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||
try {
|
||||
Catch::parseIntoConfig( Catch::CommandParser( size, argv ), config );
|
||||
FAIL( "expected exception" );
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
return ex.what();
|
||||
|
@ -179,7 +180,15 @@ TEST_CASE( "selftest/parser/2", "ConfigData" ) {
|
|||
|
||||
REQUIRE( config.cutoff == 2 );
|
||||
}
|
||||
SECTION( "-a/error", "cutoff only takes one argument" ) {
|
||||
SECTION( "-a/error/0", "" ) {
|
||||
const char* argv[] = { "test", "-a", "0" };
|
||||
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" ) );
|
||||
}
|
||||
SECTION( "-a/error/non numeric", "" ) {
|
||||
const char* argv[] = { "test", "-a", "oops" };
|
||||
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" ) );
|
||||
}
|
||||
SECTION( "-a/error/two args", "cutoff only takes one argument" ) {
|
||||
const char* argv[] = { "test", "-a", "1", "2" };
|
||||
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "accepts" ) );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue