From b47139d24574fb5dfca059121c88572b4c99b9b4 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Sat, 1 Jan 2011 00:37:49 +0000 Subject: [PATCH] tweaked list enum --- catch_runner.hpp | 2 +- internal/catch_commandline.hpp | 12 ++++++------ internal/catch_config.hpp | 34 +++++++++++++++++----------------- internal/catch_list.hpp | 6 +++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/catch_runner.hpp b/catch_runner.hpp index dfbc948a..20195b32 100644 --- a/catch_runner.hpp +++ b/catch_runner.hpp @@ -57,7 +57,7 @@ namespace Catch } // Handle list request - if( config.listWhat() != Config::listNone ) + if( config.listWhat() != Config::List::None ) return List( config ); // Open output file, if specified diff --git a/internal/catch_commandline.hpp b/internal/catch_commandline.hpp index 8befcdfa..0155fa00 100644 --- a/internal/catch_commandline.hpp +++ b/internal/catch_commandline.hpp @@ -112,26 +112,26 @@ namespace Catch } else { - Config::ListInfo listSpec = Config::listAll; + Config::List::What listSpec = Config::List::All; if( m_args.size() >= 1 ) { if( m_args[0] == "tests" ) - listSpec = Config::listTests; + listSpec = Config::List::Tests; else if( m_args[0] == "reporters" ) - listSpec = Config::listReports; + listSpec = Config::List::Reports; else return setErrorMode( m_command + " expected [tests] or [reporters] but recieved: [" + m_args[0] + "]" ); } if( m_args.size() >= 2 ) { 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" ) - listSpec = (Config::ListInfo)( listSpec | Config::listAsText ); + listSpec = (Config::List::What)( listSpec | Config::List::AsText ); else 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; case modeTest: diff --git a/internal/catch_config.hpp b/internal/catch_config.hpp index d9087b7c..ee56fa8f 100644 --- a/internal/catch_config.hpp +++ b/internal/catch_config.hpp @@ -34,26 +34,26 @@ namespace Catch SuccessfulResults }; }; - enum ListInfo + struct List{ enum What { - listNone = 0, + None = 0, - listReports = 1, - listTests = 2, - listAll = 3, + Reports = 1, + Tests = 2, + All = 3, - listWhatMask = 0xf, + WhatMask = 0xf, - listAsText = 0x10, - listAsXml = 0x11, + AsText = 0x10, + AsXml = 0x11, - listAsMask = 0xf0 - }; + AsMask = 0xf0 + }; }; Config() : m_reporter( NULL ), - m_listSpec( listNone ), + m_listSpec( List::None ), m_shouldDebugBreak( false ), m_showHelp( false ), m_os( std::cout.rdbuf() ), @@ -71,7 +71,7 @@ namespace Catch { m_testSpecs.push_back( testSpec ); } - void setListSpec( ListInfo listSpec ) + void setListSpec( List::What listSpec ) { m_listSpec = listSpec; } @@ -108,14 +108,14 @@ namespace Catch return const_cast( 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 ) @@ -162,7 +162,7 @@ namespace Catch std::auto_ptr m_reporter; std::string m_filename; std::string m_message; - ListInfo m_listSpec; + List::What m_listSpec; std::vector m_testSpecs; bool m_shouldDebugBreak; bool m_showHelp; diff --git a/internal/catch_list.hpp b/internal/catch_list.hpp index a83bd83b..343dd3f5 100644 --- a/internal/catch_list.hpp +++ b/internal/catch_list.hpp @@ -20,7 +20,7 @@ namespace Catch { inline int List( const Config& config ) { - if( config.listWhat() & Config::listReports ) + if( config.listWhat() & Config::List::Reports ) { std::cout << "Available reports:\n"; IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin(); @@ -32,7 +32,7 @@ namespace Catch } std::cout << std::endl; } - if( config.listWhat() & Config::listTests ) + if( config.listWhat() & Config::List::Tests ) { std::cout << "Available tests:\n"; std::vector::const_iterator it = TestRegistry::instance().getAllTests().begin(); @@ -44,7 +44,7 @@ namespace Catch } std::cout << std::endl; } - if( ( config.listWhat() & Config::listAll ) == 0 ) + if( ( config.listWhat() & Config::List::All ) == 0 ) { std::cerr << "Unknown list type" << std::endl; return std::numeric_limits::max();