Cleaned up config class a bit

This commit is contained in:
Phil Nash
2011-01-18 19:49:00 +00:00
parent 2885339287
commit bfc1ee6c62
5 changed files with 35 additions and 20 deletions

View File

@@ -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:

View File

@@ -84,6 +84,24 @@ namespace Catch
{
m_testSpecs.push_back( testSpec );
}
///////////////////////////////////////////////////////////////////////////
bool testsSpecified() const
{
return !m_testSpecs.empty();
}
///////////////////////////////////////////////////////////////////////////
const std::vector<std::string>& 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<Config*>( this )->setReporter( Hub::getReporterRegistry().create( "basic", *this ) );
return m_reporter.get();
}
///////////////////////////////////////////////////////////////////////////
IReporter* getReporter() const
{
return const_cast<Config*>( this )->getReporter();
}
///////////////////////////////////////////////////////////////////////////
List::What listWhat() const
{
@@ -200,7 +218,7 @@ namespace Catch
return m_includeWhat == Include::SuccessfulResults;
}
private:
std::auto_ptr<IReporter> m_reporter;
std::string m_filename;
std::string m_message;

View File

@@ -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;
}