Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2013-05-29 07:59:01 +0100
committerPhil Nash2013-05-29 07:59:01 +0100
commitf6892bfdf0e230f6a77b3215d71be412f778ec17 (patch)
tree522253eb16528ec953e64ef9c8117ee93658ddb1 /include
parent6b8837bd9360f26c03112ce4e104ec7aa96b264d (diff)
downloadcatch3-f6892bfdf0e230f6a77b3215d71be412f778ec17.tar.gz
Listing is now in terms of interface (and calls to bool functions)
Diffstat (limited to 'include')
-rw-r--r--include/catch_runner.hpp15
-rw-r--r--include/internal/catch_config.hpp14
-rw-r--r--include/internal/catch_list.hpp36
3 files changed, 31 insertions, 34 deletions
diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp
index b0cef9be..5c699c95 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_runner.hpp
@@ -24,8 +24,8 @@ namespace Catch {
class Runner2 { // This will become Runner when Runner becomes Context
public:
- Runner2( ConfigData const& config )
- : m_config( new Config( config ) )
+ Runner2( Ptr<Config> const& config )
+ : m_config( config )
{
openStream();
makeReporter();
@@ -110,15 +110,14 @@ namespace Catch {
std::set<TestCase> m_testsAlreadyRun;
};
- inline int Main( ConfigData const& configData ) {
+ inline int Main( Ptr<Config> const& config ) {
int result = 0;
try
{
- Runner2 runner( configData );
+ Runner2 runner( config );
// Handle list request
- if( configData.listSpec != List::None ) {
- list( configData );
+ if( list( config ) ) {
Catch::cleanUp();
return 0;
}
@@ -195,8 +194,8 @@ namespace Catch {
Catch::cleanUp();
return (std::numeric_limits<int>::max)();
}
-
- return Main( configData );
+ Ptr<Config> config = new Config( configData );
+ return Main( config );
}
} // end namespace Catch
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index baaad59f..dc320553 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -101,22 +101,14 @@ namespace Catch {
m_data.outputFilename = filename;
}
- List::What getListSpec( void ) const {
- return m_data.listSpec;
- }
-
std::string const& getFilename() const {
return m_data.outputFilename ;
}
- List::What listWhat() const {
- return static_cast<List::What>( m_data.listSpec & List::WhatMask );
- }
+ bool listTests() const { return m_data.listSpec & List::Tests; }
+ bool listTags() const { return m_data.listSpec & List::Tags; }
+ bool listReporters() const { return m_data.listSpec & List::Reports; }
- List::What listAs() const {
- return static_cast<List::What>( m_data.listSpec & List::AsMask );
- }
-
std::string getName() const {
return m_data.name;
}
diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp
index aa47b132..e583bb87 100644
--- a/include/internal/catch_list.hpp
+++ b/include/internal/catch_list.hpp
@@ -25,8 +25,8 @@ namespace Catch {
return true;
}
- inline void listTests( ConfigData const& config ) {
- if( config.filters.empty() )
+ inline void listTests( Ptr<Config> const& config ) {
+ if( config->filters().empty() )
std::cout << "All available test cases:\n";
else
std::cout << "Matching test cases:\n";
@@ -37,7 +37,7 @@ namespace Catch {
std::size_t maxTagLen = 0;
std::size_t maxNameLen = 0;
for(; it != itEnd; ++it ) {
- if( matchesFilters( config.filters, *it ) ) {
+ if( matchesFilters( config->filters(), *it ) ) {
maxTagLen = (std::max)( it->getTestCaseInfo().tagsAsString.size(), maxTagLen );
maxNameLen = (std::max)( it->getTestCaseInfo().name.size(), maxNameLen );
}
@@ -54,7 +54,7 @@ namespace Catch {
std::size_t matchedTests = 0;
for( it = allTests.begin(); it != itEnd; ++it ) {
- if( matchesFilters( config.filters, *it ) ) {
+ if( matchesFilters( config->filters(), *it ) ) {
matchedTests++;
// !TBD: consider listAs()
Text nameWrapper( it->getTestCaseInfo().name,
@@ -94,14 +94,14 @@ namespace Catch {
}
}
}
- if( config.filters.empty() )
+ if( config->filters().empty() )
std::cout << pluralise( matchedTests, "test case" ) << std::endl;
else
std::cout << pluralise( matchedTests, "matching test case" ) << std::endl;
}
- inline void listTags( ConfigData const& config ) {
- if( config.filters.empty() )
+ inline void listTags( Ptr<Config> const& config ) {
+ if( config->filters().empty() )
std::cout << "All available tags:\n";
else
std::cout << "Matching tags:\n";
@@ -113,7 +113,7 @@ namespace Catch {
std::size_t maxTagLen = 0;
for(; it != itEnd; ++it ) {
- if( matchesFilters( config.filters, *it ) ) {
+ if( matchesFilters( config->filters(), *it ) ) {
for( std::set<std::string>::const_iterator tagIt = it->getTestCaseInfo().tags.begin(),
tagItEnd = it->getTestCaseInfo().tags.end();
tagIt != tagItEnd;
@@ -152,7 +152,7 @@ namespace Catch {
std::cout << pluralise( tagCounts.size(), "tag" ) << std::endl;
}
- inline void listReporters( ConfigData const& /*config*/ ) {
+ inline void listReporters( Ptr<Config> const& /*config*/ ) {
std::cout << "Available reports:\n";
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
IReporterRegistry::FactoryMap::const_iterator it = factories.begin(), itEnd = factories.end();
@@ -163,15 +163,21 @@ namespace Catch {
std::cout << std::endl;
}
- inline void list( ConfigData const& config ) {
- if( config.listSpec & List::Tests )
+ inline bool list( Ptr<Config> const& config ) {
+ bool listed = false;
+ if( config->listTests() ) {
listTests( config );
- if( config.listSpec & List::Tags )
+ listed = true;
+ }
+ if( config->listTags() ) {
listTags( config );
- if( config.listSpec & List::Reports )
+ listed = true;
+ }
+ if( config->listReporters() ) {
listReporters( config );
- if( ( config.listSpec & List::All ) == 0 )
- throw std::logic_error( "Unknown list type" );
+ listed = true;
+ }
+ return listed;
}
} // end namespace Catch