tweaked list enum

This commit is contained in:
Phil Nash 2011-01-01 00:37:49 +00:00
parent 92f3b9398b
commit b47139d245
4 changed files with 27 additions and 27 deletions

View File

@ -57,7 +57,7 @@ namespace Catch
} }
// Handle list request // Handle list request
if( config.listWhat() != Config::listNone ) if( config.listWhat() != Config::List::None )
return List( config ); return List( config );
// Open output file, if specified // Open output file, if specified

View File

@ -112,26 +112,26 @@ namespace Catch
} }
else else
{ {
Config::ListInfo listSpec = Config::listAll; Config::List::What listSpec = Config::List::All;
if( m_args.size() >= 1 ) if( m_args.size() >= 1 )
{ {
if( m_args[0] == "tests" ) if( m_args[0] == "tests" )
listSpec = Config::listTests; listSpec = Config::List::Tests;
else if( m_args[0] == "reporters" ) else if( m_args[0] == "reporters" )
listSpec = Config::listReports; listSpec = Config::List::Reports;
else else
return setErrorMode( m_command + " expected [tests] or [reporters] but recieved: [" + m_args[0] + "]" ); return setErrorMode( m_command + " expected [tests] or [reporters] but recieved: [" + m_args[0] + "]" );
} }
if( m_args.size() >= 2 ) if( m_args.size() >= 2 )
{ {
if( m_args[1] == "xml" ) if( m_args[1] == "xml" )
listSpec = (Config::ListInfo)( listSpec | Config::listAsXml ); listSpec = (Config::List::What)( listSpec | Config::List::AsXml );
else if( m_args[1] == "text" ) else if( m_args[1] == "text" )
listSpec = (Config::ListInfo)( listSpec | Config::listAsText ); listSpec = (Config::List::What)( listSpec | Config::List::AsText );
else else
return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" ); return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" );
} }
m_config.m_listSpec = (Config::ListInfo)( m_config.m_listSpec | listSpec ); m_config.m_listSpec = (Config::List::What)( m_config.m_listSpec | listSpec );
} }
break; break;
case modeTest: case modeTest:

View File

@ -34,26 +34,26 @@ namespace Catch
SuccessfulResults SuccessfulResults
}; }; }; };
enum ListInfo struct List{ enum What
{ {
listNone = 0, None = 0,
listReports = 1, Reports = 1,
listTests = 2, Tests = 2,
listAll = 3, All = 3,
listWhatMask = 0xf, WhatMask = 0xf,
listAsText = 0x10, AsText = 0x10,
listAsXml = 0x11, AsXml = 0x11,
listAsMask = 0xf0 AsMask = 0xf0
}; }; };
Config() Config()
: m_reporter( NULL ), : m_reporter( NULL ),
m_listSpec( listNone ), m_listSpec( List::None ),
m_shouldDebugBreak( false ), m_shouldDebugBreak( false ),
m_showHelp( false ), m_showHelp( false ),
m_os( std::cout.rdbuf() ), m_os( std::cout.rdbuf() ),
@ -71,7 +71,7 @@ namespace Catch
{ {
m_testSpecs.push_back( testSpec ); m_testSpecs.push_back( testSpec );
} }
void setListSpec( ListInfo listSpec ) void setListSpec( List::What listSpec )
{ {
m_listSpec = listSpec; m_listSpec = listSpec;
} }
@ -108,14 +108,14 @@ namespace Catch
return const_cast<Config*>( this )->getReporter(); return const_cast<Config*>( this )->getReporter();
} }
ListInfo listWhat() const List::What listWhat() const
{ {
return (ListInfo)( m_listSpec & listWhatMask ); return (List::What)( m_listSpec & List::WhatMask );
} }
ListInfo listAs() const List::What listAs() const
{ {
return (ListInfo)( m_listSpec & listAsMask ); return (List::What)( m_listSpec & List::AsMask );
} }
void setIncludeWhat( Include::What includeWhat ) void setIncludeWhat( Include::What includeWhat )
@ -162,7 +162,7 @@ namespace Catch
std::auto_ptr<IReporter> m_reporter; std::auto_ptr<IReporter> m_reporter;
std::string m_filename; std::string m_filename;
std::string m_message; std::string m_message;
ListInfo m_listSpec; List::What m_listSpec;
std::vector<std::string> m_testSpecs; std::vector<std::string> m_testSpecs;
bool m_shouldDebugBreak; bool m_shouldDebugBreak;
bool m_showHelp; bool m_showHelp;

View File

@ -20,7 +20,7 @@ namespace Catch
{ {
inline int List( const Config& config ) inline int List( const Config& config )
{ {
if( config.listWhat() & Config::listReports ) if( config.listWhat() & Config::List::Reports )
{ {
std::cout << "Available reports:\n"; std::cout << "Available reports:\n";
IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin(); IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin();
@ -32,7 +32,7 @@ namespace Catch
} }
std::cout << std::endl; std::cout << std::endl;
} }
if( config.listWhat() & Config::listTests ) if( config.listWhat() & Config::List::Tests )
{ {
std::cout << "Available tests:\n"; std::cout << "Available tests:\n";
std::vector<TestCaseInfo>::const_iterator it = TestRegistry::instance().getAllTests().begin(); std::vector<TestCaseInfo>::const_iterator it = TestRegistry::instance().getAllTests().begin();
@ -44,7 +44,7 @@ namespace Catch
} }
std::cout << std::endl; std::cout << std::endl;
} }
if( ( config.listWhat() & Config::listAll ) == 0 ) if( ( config.listWhat() & Config::List::All ) == 0 )
{ {
std::cerr << "Unknown list type" << std::endl; std::cerr << "Unknown list type" << std::endl;
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();