Added NotImplementedException

This commit is contained in:
Phil Nash 2012-07-05 18:37:58 +01:00
parent 4c73aa5a0e
commit abf271672f
7 changed files with 252 additions and 195 deletions

View File

@ -77,7 +77,8 @@ namespace Catch {
} }
inline void showUsage( std::ostream& os ) { inline void showUsage( std::ostream& os ) {
os << "\t-l, --list <tests | reporters> [xml]\n" os << "\t-?, -h, --help\n"
<< "\t-l, --list <tests | reporters> [xml]\n"
<< "\t-t, --test <testspec> [<testspec>...]\n" << "\t-t, --test <testspec> [<testspec>...]\n"
<< "\t-r, --reporter <reporter name>\n" << "\t-r, --reporter <reporter name>\n"
<< "\t-o, --out <file name>|<%stream name>\n" << "\t-o, --out <file name>|<%stream name>\n"

View File

@ -19,6 +19,30 @@ namespace Catch {
struct TestFailureException{}; struct TestFailureException{};
class NotImplementedException : public std::exception
{
public:
NotImplementedException( const SourceLineInfo& lineInfo )
: m_lineInfo( lineInfo ) {
std::ostringstream oss;
oss << lineInfo << "function ";
if( !lineInfo.function.empty() )
oss << lineInfo.function << " ";
oss << "not implemented";
m_what = oss.str();
}
virtual ~NotImplementedException() throw() {}
virtual const char* what() const throw() {
return m_what.c_str();
}
private:
std::string m_what;
SourceLineInfo m_lineInfo;
};
class ScopedInfo { class ScopedInfo {
public: public:
ScopedInfo() : m_oss() { ScopedInfo() : m_oss() {
@ -130,4 +154,7 @@ inline bool isTrue( bool value ){ return value; }
throw; \ throw; \
}}while( Catch::isTrue( false ) ) }}while( Catch::isTrue( false ) )
///////////////////////////////////////////////////////////////////////////////
#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
#endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED

View File

@ -82,6 +82,11 @@ namespace Catch {
: file( _file ), : file( _file ),
line( _line ) line( _line )
{} {}
SourceLineInfo( const std::string& _function, const std::string& _file, std::size_t _line )
: function( _function ),
file( _file ),
line( _line )
{}
SourceLineInfo( const SourceLineInfo& other ) SourceLineInfo( const SourceLineInfo& other )
: file( other.file ), : file( other.file ),
line( other.line ) line( other.line )
@ -91,6 +96,7 @@ namespace Catch {
std::swap( line, other.line ); std::swap( line, other.line );
} }
std::string function;
std::string file; std::string file;
std::size_t line; std::size_t line;
}; };
@ -113,7 +119,12 @@ namespace Catch {
} }
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ ); #define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
#ifdef __FUNCTION__
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FUNCTION__, __FILE__, __LINE__ )
#else
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ ) #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
#endif
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED

View File

@ -81,8 +81,7 @@ namespace Catch {
virtual void runAll( bool runHiddenTests = false ) { virtual void runAll( bool runHiddenTests = false ) {
const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests(); const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests();
for( std::size_t i=0; i < allTests.size(); ++i ) { for( std::size_t i=0; i < allTests.size(); ++i ) {
if( runHiddenTests || !allTests[i].isHidden() ) if( runHiddenTests || !allTests[i].isHidden() ) {
{
if( aborting() ) { if( aborting() ) {
m_reporter->Aborted(); m_reporter->Aborted();
break; break;

View File

@ -150,3 +150,12 @@ TEST_CASE( "./succeeding/exceptions/error messages", "The error messages produce
} }
} }
inline int thisFunctionNotImplemented( int ) {
CATCH_NOT_IMPLEMENTED;
}
TEST_CASE( "./succeeding/exceptions/notimplemented", "" )
{
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
}

View File

@ -33,7 +33,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
SECTION( "selftest/test counts/succeeding tests", SECTION( "selftest/test counts/succeeding tests",
"Number of 'succeeding' tests is fixed" ) { "Number of 'succeeding' tests is fixed" ) {
runner.runMatching( "./succeeding/*" ); runner.runMatching( "./succeeding/*" );
CHECK( runner.getTotals().assertions.passed == 283 ); CHECK( runner.getTotals().assertions.passed == 284 );
CHECK( runner.getTotals().assertions.failed == 0 ); CHECK( runner.getTotals().assertions.failed == 0 );
} }

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-06-06 08:05:56.928287 * Generated: 2012-07-05 18:37:02.079024
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -90,6 +90,11 @@ namespace Catch {
: file( _file ), : file( _file ),
line( _line ) line( _line )
{} {}
SourceLineInfo( const std::string& _function, const std::string& _file, std::size_t _line )
: function( _function ),
file( _file ),
line( _line )
{}
SourceLineInfo( const SourceLineInfo& other ) SourceLineInfo( const SourceLineInfo& other )
: file( other.file ), : file( other.file ),
line( other.line ) line( other.line )
@ -99,6 +104,7 @@ namespace Catch {
std::swap( line, other.line ); std::swap( line, other.line );
} }
std::string function;
std::string file; std::string file;
std::size_t line; std::size_t line;
}; };
@ -121,7 +127,12 @@ namespace Catch {
} }
#define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ ); #define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ );
#ifdef __FUNCTION__
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FUNCTION__, __FILE__, __LINE__ )
#else
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ ) #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ )
#endif
// #included from: catch_totals.hpp // #included from: catch_totals.hpp
@ -1346,6 +1357,30 @@ namespace Catch {
struct TestFailureException{}; struct TestFailureException{};
class NotImplementedException : public std::exception
{
public:
NotImplementedException( const SourceLineInfo& lineInfo )
: m_lineInfo( lineInfo ) {
std::ostringstream oss;
oss << lineInfo << "function ";
if( !lineInfo.function.empty() )
oss << lineInfo.function << " ";
oss << "not implemented";
m_what = oss.str();
}
virtual ~NotImplementedException() throw() {}
virtual const char* what() const throw() {
return m_what.c_str();
}
private:
std::string m_what;
SourceLineInfo m_lineInfo;
};
class ScopedInfo { class ScopedInfo {
public: public:
ScopedInfo() : m_oss() { ScopedInfo() : m_oss() {
@ -1457,6 +1492,9 @@ inline bool isTrue( bool value ){ return value; }
throw; \ throw; \
}}while( Catch::isTrue( false ) ) }}while( Catch::isTrue( false ) )
///////////////////////////////////////////////////////////////////////////////
#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
// #included from: internal/catch_section.hpp // #included from: internal/catch_section.hpp
#include <string> #include <string>
@ -2174,6 +2212,9 @@ namespace Catch {
inline std::string toString( NSString* const& nsstring ) { inline std::string toString( NSString* const& nsstring ) {
return std::string( "@\"" ) + [nsstring UTF8String] + "\""; return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
} }
inline std::string toString( NSObject* const& nsObject ) {
return toString( [nsObject description] );
}
namespace Matchers { namespace Matchers {
namespace Impl { namespace Impl {
@ -2416,6 +2457,27 @@ namespace Catch {
AsMask = 0xf0 AsMask = 0xf0
}; }; }; };
struct ConfigData {
ConfigData()
: listSpec( List::None ),
shouldDebugBreak( false ),
includeWhichResults( Include::FailedOnly ),
cutoff( -1 ),
allowThrows( true )
{}
std::string reporter;
std::string outputFilename;
List::What listSpec;
std::vector<std::string> testSpecs;
bool shouldDebugBreak;
std::string stream;
Include::WhichResults includeWhichResults;
std::string name;
int cutoff;
bool allowThrows;
};
class Config : public IReporterConfig, public IConfig { class Config : public IReporterConfig, public IConfig {
private: private:
Config( const Config& other ); Config( const Config& other );
@ -2423,14 +2485,14 @@ namespace Catch {
public: public:
Config() Config()
: m_listSpec( List::None ), : m_streambuf( NULL ),
m_shouldDebugBreak( false ), m_os( std::cout.rdbuf() )
m_showHelp( false ), {}
Config( const ConfigData& data )
: m_data( data ),
m_streambuf( NULL ), m_streambuf( NULL ),
m_os( std::cout.rdbuf() ), m_os( std::cout.rdbuf() )
m_includeWhichResults( Include::FailedOnly ),
m_cutoff( -1 ),
m_allowThrows( true )
{} {}
~Config() { ~Config() {
@ -2440,44 +2502,28 @@ namespace Catch {
void setReporter( const std::string& reporterName ) { void setReporter( const std::string& reporterName ) {
if( m_reporter.get() ) if( m_reporter.get() )
return setError( "Only one reporter may be specified" ); throw std::domain_error( "Only one reporter may be specified" );
setReporter( getCurrentContext().getReporterRegistry().create( reporterName, *this ) ); setReporter( getCurrentContext().getReporterRegistry().create( reporterName, *this ) );
} }
void addTestSpec( const std::string& testSpec ) { void setFilename( const std::string& filename ) {
m_testSpecs.push_back( testSpec ); m_data.outputFilename = filename;
} }
bool testsSpecified() const { bool testsSpecified() const {
return !m_testSpecs.empty(); return !m_data.testSpecs.empty();
} }
const std::vector<std::string>& getTestSpecs() const { const std::vector<std::string>& getTestSpecs() const {
return m_testSpecs; return m_data.testSpecs;
} }
List::What getListSpec( void ) const { List::What getListSpec( void ) const {
return m_listSpec; return m_data.listSpec;
}
void setListSpec( List::What listSpec ) {
m_listSpec = listSpec;
}
void setFilename( const std::string& filename ) {
m_filename = filename;
} }
const std::string& getFilename() const { const std::string& getFilename() const {
return m_filename; return m_data.outputFilename ;
}
const std::string& getMessage() const {
return m_message;
}
void setError( const std::string& errorMessage ) {
m_message = errorMessage;
} }
void setReporter( IReporter* reporter ) { void setReporter( IReporter* reporter ) {
@ -2491,39 +2537,19 @@ namespace Catch {
} }
List::What listWhat() const { List::What listWhat() const {
return static_cast<List::What>( m_listSpec & List::WhatMask ); return static_cast<List::What>( m_data.listSpec & List::WhatMask );
} }
List::What listAs() const { List::What listAs() const {
return static_cast<List::What>( m_listSpec & List::AsMask ); return static_cast<List::What>( m_data.listSpec & List::AsMask );
}
void setIncludeWhichResults( Include::WhichResults includeWhichResults ) {
m_includeWhichResults = includeWhichResults;
}
void setShouldDebugBreak( bool shouldDebugBreakFlag ) {
m_shouldDebugBreak = shouldDebugBreakFlag;
}
void setName( const std::string& name ) {
m_name = name;
} }
std::string getName() const { std::string getName() const {
return m_name; return m_data.name;
} }
bool shouldDebugBreak() const { bool shouldDebugBreak() const {
return m_shouldDebugBreak; return m_data.shouldDebugBreak;
}
void setShowHelp( bool showHelpFlag ) {
m_showHelp = showHelpFlag;
}
bool showHelp() const {
return m_showHelp;
} }
virtual std::ostream& stream() const { virtual std::ostream& stream() const {
@ -2542,50 +2568,28 @@ namespace Catch {
} }
virtual bool includeSuccessfulResults() const { virtual bool includeSuccessfulResults() const {
return m_includeWhichResults == Include::SuccessfulResults; return m_data.includeWhichResults == Include::SuccessfulResults;
} }
int getCutoff() const { int getCutoff() const {
return m_cutoff; return m_data.cutoff;
}
void setCutoff( int cutoff ) {
m_cutoff = cutoff;
}
void setAllowThrows( bool allowThrows ) {
m_allowThrows = allowThrows;
} }
virtual bool allowThrows() const { virtual bool allowThrows() const {
return m_allowThrows; return m_data.allowThrows;
}
ConfigData& data() {
return m_data;
} }
private: private:
ConfigData m_data;
// !TBD Move these out of here
Ptr<IReporter> m_reporter; Ptr<IReporter> m_reporter;
std::string m_filename;
std::string m_message;
List::What m_listSpec;
std::vector<std::string> m_testSpecs;
bool m_shouldDebugBreak;
bool m_showHelp;
std::streambuf* m_streambuf; std::streambuf* m_streambuf;
mutable std::ostream m_os; mutable std::ostream m_os;
Include::WhichResults m_includeWhichResults;
std::string m_name;
int m_cutoff;
bool m_allowThrows;
};
struct NewConfig {
std::string reporter;
std::string outputFilename;
List::What listSpec;
std::vector<std::string> testSpecs;
bool shouldDebugBreak;
bool showHelp;
Include::WhichResults includeWhichResults;
std::string name;
}; };
} // end namespace Catch } // end namespace Catch
@ -2816,7 +2820,8 @@ namespace Catch {
m_config( config ), m_config( config ),
m_reporter( config.getReporter() ), m_reporter( config.getReporter() ),
m_prevRunner( &m_context.getRunner() ), m_prevRunner( &m_context.getRunner() ),
m_prevResultCapture( &m_context.getResultCapture() ) m_prevResultCapture( &m_context.getResultCapture() ),
m_prevConfig( m_context.getConfig() )
{ {
m_context.setRunner( this ); m_context.setRunner( this );
m_context.setConfig( &m_config ); m_context.setConfig( &m_config );
@ -2829,13 +2834,13 @@ namespace Catch {
m_context.setRunner( m_prevRunner ); m_context.setRunner( m_prevRunner );
m_context.setConfig( NULL ); m_context.setConfig( NULL );
m_context.setResultCapture( m_prevResultCapture ); m_context.setResultCapture( m_prevResultCapture );
m_context.setConfig( m_prevConfig );
} }
virtual void runAll( bool runHiddenTests = false ) { virtual void runAll( bool runHiddenTests = false ) {
const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests(); const std::vector<TestCaseInfo>& allTests = getCurrentContext().getTestCaseRegistry().getAllTests();
for( std::size_t i=0; i < allTests.size(); ++i ) { for( std::size_t i=0; i < allTests.size(); ++i ) {
if( runHiddenTests || !allTests[i].isHidden() ) if( runHiddenTests || !allTests[i].isHidden() ) {
{
if( aborting() ) { if( aborting() ) {
m_reporter->Aborted(); m_reporter->Aborted();
break; break;
@ -3048,6 +3053,7 @@ namespace Catch {
std::vector<ResultInfo> m_info; std::vector<ResultInfo> m_info;
IRunner* m_prevRunner; IRunner* m_prevRunner;
IResultCapture* m_prevResultCapture; IResultCapture* m_prevResultCapture;
const IConfig* m_prevConfig;
}; };
} // end namespace Catch } // end namespace Catch
@ -3573,9 +3579,8 @@ namespace Catch {
char const * const * m_argv; char const * const * m_argv;
}; };
inline bool parseIntoConfig( const CommandParser& parser, Config& config ) { inline void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
try {
if( Command cmd = parser.find( "-l", "--list" ) ) { if( Command cmd = parser.find( "-l", "--list" ) ) {
if( cmd.argsCount() > 2 ) if( cmd.argsCount() > 2 )
cmd.raiseError( "Expected upto 2 arguments" ); cmd.raiseError( "Expected upto 2 arguments" );
@ -3583,95 +3588,81 @@ namespace Catch {
List::What listSpec = List::All; List::What listSpec = List::All;
if( cmd.argsCount() >= 1 ) { if( cmd.argsCount() >= 1 ) {
if( cmd[0] == "tests" ) if( cmd[0] == "tests" )
listSpec = List::Tests; config.listSpec = List::Tests;
else if( cmd[0] == "reporters" ) else if( cmd[0] == "reporters" )
listSpec = List::Reports; config.listSpec = List::Reports;
else else
cmd.raiseError( "Expected [tests] or [reporters]" ); cmd.raiseError( "Expected [tests] or [reporters]" );
} }
if( cmd.argsCount() >= 2 ) { if( cmd.argsCount() >= 2 ) {
if( cmd[1] == "xml" ) if( cmd[1] == "xml" )
listSpec = static_cast<List::What>( listSpec | List::AsXml ); config.listSpec = static_cast<List::What>( listSpec | List::AsXml );
else if( cmd[1] == "text" ) else if( cmd[1] == "text" )
listSpec = static_cast<List::What>( listSpec | List::AsText ); config.listSpec = static_cast<List::What>( listSpec | List::AsText );
else else
cmd.raiseError( "Expected [xml] or [text]" ); cmd.raiseError( "Expected [xml] or [text]" );
} }
config.setListSpec( static_cast<List::What>( config.getListSpec() | listSpec ) );
} }
if( Command cmd = parser.find( "-t", "--test" ) ) { if( Command cmd = parser.find( "-t", "--test" ) ) {
if( cmd.argsCount() == 0 ) if( cmd.argsCount() == 0 )
cmd.raiseError( "Expected at least one argument" ); cmd.raiseError( "Expected at least one argument" );
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) for( std::size_t i = 0; i < cmd.argsCount(); ++i )
config.addTestSpec( cmd[i] ); config.testSpecs.push_back( cmd[i] );
} }
if( Command cmd = parser.find( "-r", "--reporter" ) ) { if( Command cmd = parser.find( "-r", "--reporter" ) ) {
if( cmd.argsCount() != 1 ) if( cmd.argsCount() != 1 )
cmd.raiseError( "Expected one argument" ); cmd.raiseError( "Expected one argument" );
config.setReporter( cmd[0] ); config.reporter = cmd[0];
} }
if( Command cmd = parser.find( "-o", "--out" ) ) { if( Command cmd = parser.find( "-o", "--out" ) ) {
if( cmd.argsCount() == 0 ) if( cmd.argsCount() == 0 )
cmd.raiseError( "Expected filename" ); cmd.raiseError( "Expected filename" );
if( cmd[0][0] == '%' ) if( cmd[0][0] == '%' )
config.useStream( cmd[0].substr( 1 ) ); config.stream = cmd[0].substr( 1 );
else else
config.setFilename( cmd[0] ); config.outputFilename = cmd[0];
} }
if( Command cmd = parser.find( "-s", "--success" ) ) { if( Command cmd = parser.find( "-s", "--success" ) ) {
if( cmd.argsCount() != 0 ) if( cmd.argsCount() != 0 )
cmd.raiseError( "Does not accept arguments" ); cmd.raiseError( "Does not accept arguments" );
config.setIncludeWhichResults( Include::SuccessfulResults ); config.includeWhichResults = Include::SuccessfulResults;
} }
if( Command cmd = parser.find( "-b", "--break" ) ) { if( Command cmd = parser.find( "-b", "--break" ) ) {
if( cmd.argsCount() != 0 ) if( cmd.argsCount() != 0 )
cmd.raiseError( "Does not accept arguments" ); cmd.raiseError( "Does not accept arguments" );
config.setShouldDebugBreak( true ); config.shouldDebugBreak = true;
} }
if( Command cmd = parser.find( "-n", "--name" ) ) { if( Command cmd = parser.find( "-n", "--name" ) ) {
if( cmd.argsCount() != 1 ) if( cmd.argsCount() != 1 )
cmd.raiseError( "Expected a name" ); cmd.raiseError( "Expected a name" );
config.setName( cmd[0] ); config.name = cmd[0];
}
if( Command cmd = parser.find( "-h", "-?", "--help" ) ) {
if( cmd.argsCount() != 0 )
cmd.raiseError( "Does not accept arguments" );
config.setShowHelp( true );
} }
if( Command cmd = parser.find( "-a", "--abort" ) ) { if( Command cmd = parser.find( "-a", "--abort" ) ) {
if( cmd.argsCount() > 1 ) if( cmd.argsCount() > 1 )
cmd.raiseError( "Only accepts 0-1 arguments" ); cmd.raiseError( "Only accepts 0-1 arguments" );
int threshold = 1; int threshold = 1;
if( cmd.argsCount() == 1 ) if( cmd.argsCount() == 1 ) {
{
std::stringstream ss; std::stringstream ss;
ss << cmd[0]; ss << cmd[0];
ss >> threshold; ss >> threshold;
} }
config.setCutoff( threshold ); config.cutoff = threshold;
} }
if( Command cmd = parser.find( "-nt", "--nothrow" ) ) { if( Command cmd = parser.find( "-nt", "--nothrow" ) ) {
if( cmd.argsCount() != 0 ) if( cmd.argsCount() != 0 )
cmd.raiseError( "Does not accept arguments" ); cmd.raiseError( "Does not accept arguments" );
config.setAllowThrows( false ); config.allowThrows = false;
} }
} }
catch( std::exception& ex ) {
config.setError( ex.what() );
return false;
}
return true;
}
} // end namespace Catch } // end namespace Catch
@ -4670,7 +4661,8 @@ namespace Catch {
} }
inline void showUsage( std::ostream& os ) { inline void showUsage( std::ostream& os ) {
os << "\t-l, --list <tests | reporters> [xml]\n" os << "\t-?, -h, --help\n"
<< "\t-l, --list <tests | reporters> [xml]\n"
<< "\t-t, --test <testspec> [<testspec>...]\n" << "\t-t, --test <testspec> [<testspec>...]\n"
<< "\t-r, --reporter <reporter name>\n" << "\t-r, --reporter <reporter name>\n"
<< "\t-o, --out <file name>|<%stream name>\n" << "\t-o, --out <file name>|<%stream name>\n"
@ -4678,6 +4670,7 @@ namespace Catch {
<< "\t-b, --break\n" << "\t-b, --break\n"
<< "\t-n, --name <name>\n" << "\t-n, --name <name>\n"
<< "\t-a, --abort [#]\n\n" << "\t-a, --abort [#]\n\n"
<< "\t-nt, --nothrow\n\n"
<< "For more detail usage please see: https://github.com/philsquared/Catch/wiki/Command-line" << std::endl; << "For more detail usage please see: https://github.com/philsquared/Catch/wiki/Command-line" << std::endl;
} }
inline void showHelp( std::string exeName ) { inline void showHelp( std::string exeName ) {
@ -4692,21 +4685,38 @@ namespace Catch {
inline int Main( int argc, char* const argv[], Config& config ) { inline int Main( int argc, char* const argv[], Config& config ) {
parseIntoConfig( CommandParser( argc, argv ), config ); try {
CommandParser parser( argc, argv );
if( !config.getMessage().empty() ) { if( Command cmd = parser.find( "-h", "-?", "--help" ) ) {
std::cerr << config.getMessage() << + "\n\nUsage: ...\n\n"; if( cmd.argsCount() != 0 )
cmd.raiseError( "Does not accept arguments" );
showHelp( argv[0] );
Catch::Context::cleanUp();
return 0;
}
parseIntoConfig( parser, config.data() );
// !TBD: wire up (do this lazily?)
if( !config.data().reporter.empty() )
config.setReporter( config.data().reporter );
if( !config.data().stream.empty() ) {
if( config.data().stream[0] == '%' )
config.useStream( config.data().stream.substr( 1 ) );
else
config.setFilename( config.data().stream );
}
}
catch( std::exception& ex ) {
std::cerr << ex.what() << + "\n\nUsage: ...\n\n";
showUsage( std::cerr ); showUsage( std::cerr );
Catch::Context::cleanUp(); Catch::Context::cleanUp();
return (std::numeric_limits<int>::max)(); return (std::numeric_limits<int>::max)();
} }
// Handle help
if( config.showHelp() ) {
showHelp( argv[0] );
Catch::Context::cleanUp();
return 0;
}
return Main( config ); return Main( config );
} }