diff --git a/catch.hpp b/catch.hpp index 0dcb9b52..10056ee3 100644 --- a/catch.hpp +++ b/catch.hpp @@ -16,11 +16,8 @@ Later: Finish command line parser (list as xml, specify FP tolerance) - INFO() stores messages until next result Revisit Approx() - Extra reports Tags? - Detect caught "Catch" exception, offer continuation based iteration instead Finish macros, listed here, later (just CHECK_NOFAIL now) */ #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED diff --git a/catch_runner.hpp b/catch_runner.hpp index c5685a96..53e17f60 100644 --- a/catch_runner.hpp +++ b/catch_runner.hpp @@ -30,9 +30,9 @@ namespace Catch Config config; ArgParser( argc, argv, config ); - if( !config.m_message.empty() ) + if( !config.getMessage().empty() ) { - std::cerr << config.m_message << std::endl; + std::cerr << config.getMessage() << std::endl; return std::numeric_limits::max(); } @@ -77,7 +77,7 @@ namespace Catch Runner runner( config ); // Run test specs specified on the command line - or default to all - if( config.m_testSpecs.size() == 0 ) + if( !config.testsSpecified() ) { config.getReporter()->StartGroup( "" ); runner.runAll(); @@ -87,8 +87,8 @@ namespace Catch { // !TBD We should get all the testcases upfront, report any missing, // then just run them - std::vector::const_iterator it = config.m_testSpecs.begin(); - std::vector::const_iterator itEnd = config.m_testSpecs.end(); + std::vector::const_iterator it = config.getTestSpecs().begin(); + std::vector::const_iterator itEnd = config.getTestSpecs().end(); for(; it != itEnd; ++it ) { size_t prevSuccess = runner.getSuccessCount(); diff --git a/internal/catch_commandline.hpp b/internal/catch_commandline.hpp index db0a0012..cfa34095 100644 --- a/internal/catch_commandline.hpp +++ b/internal/catch_commandline.hpp @@ -131,7 +131,7 @@ namespace Catch else return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" ); } - m_config.m_listSpec = (Config::List::What)( m_config.m_listSpec | listSpec ); + m_config.setListSpec( (Config::List::What)( m_config.getListSpec() | listSpec ) ); } break; case modeTest: diff --git a/internal/catch_config.hpp b/internal/catch_config.hpp index 90c130fa..5f2b4916 100644 --- a/internal/catch_config.hpp +++ b/internal/catch_config.hpp @@ -84,6 +84,24 @@ namespace Catch { m_testSpecs.push_back( testSpec ); } + + /////////////////////////////////////////////////////////////////////////// + bool testsSpecified() const + { + return !m_testSpecs.empty(); + } + + /////////////////////////////////////////////////////////////////////////// + const std::vector& getTestSpecs() const + { + return m_testSpecs; + } + + /////////////////////////////////////////////////////////////////////////// + List::What getListSpec( void ) const + { + return m_listSpec; + } /////////////////////////////////////////////////////////////////////////// void setListSpec( List::What listSpec ) @@ -98,11 +116,17 @@ namespace Catch } /////////////////////////////////////////////////////////////////////////// - std::string getFilename() + const std::string& getFilename() const { return m_filename; } + /////////////////////////////////////////////////////////////////////////// + const std::string& getMessage() const + { + return m_message; + } + /////////////////////////////////////////////////////////////////////////// void setError( const std::string& errorMessage ) { @@ -116,19 +140,13 @@ namespace Catch } /////////////////////////////////////////////////////////////////////////// - IReporter* getReporter() + IReporter* getReporter() const { if( !m_reporter.get() ) - setReporter( Hub::getReporterRegistry().create( "basic", *this ) ); + const_cast( this )->setReporter( Hub::getReporterRegistry().create( "basic", *this ) ); return m_reporter.get(); } - /////////////////////////////////////////////////////////////////////////// - IReporter* getReporter() const - { - return const_cast( this )->getReporter(); - } - /////////////////////////////////////////////////////////////////////////// List::What listWhat() const { @@ -200,7 +218,7 @@ namespace Catch return m_includeWhat == Include::SuccessfulResults; } - + private: std::auto_ptr m_reporter; std::string m_filename; std::string m_message; diff --git a/internal/catch_list.hpp b/internal/catch_list.hpp index 76f6f8fa..1628832f 100644 --- a/internal/catch_list.hpp +++ b/internal/catch_list.hpp @@ -54,7 +54,7 @@ namespace Catch { std::cerr << "Reporters ignored when listing" << std::endl; } - if( config.m_testSpecs.size() == 0 ) + if( !config.testsSpecified() ) { std::cerr << "Test specs ignored when listing" << std::endl; }