Use Text formatter to list reporters

This commit is contained in:
Phil Nash 2013-06-07 18:56:43 +01:00
parent 80557647d6
commit 27cae858d0

View File

@ -95,9 +95,9 @@ namespace Catch {
} }
} }
if( config.filters().empty() ) if( config.filters().empty() )
std::cout << pluralise( matchedTests, "test case" ) << std::endl; std::cout << pluralise( matchedTests, "test case" ) << "\n" << std::endl;
else else
std::cout << pluralise( matchedTests, "matching test case" ) << std::endl; std::cout << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl;
return matchedTests; return matchedTests;
} }
@ -150,16 +150,29 @@ namespace Catch {
std::cout << countIt->second std::cout << countIt->second
<< "\n"; << "\n";
} }
std::cout << pluralise( tagCounts.size(), "tag" ) << std::endl; std::cout << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl;
return tagCounts.size(); return tagCounts.size();
} }
inline std::size_t listReporters( Config const& /*config*/ ) { inline std::size_t listReporters( Config const& /*config*/ ) {
std::cout << "Available reports:\n"; std::cout << "Available reports:\n";
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
IReporterRegistry::FactoryMap::const_iterator it = factories.begin(), itEnd = factories.end(); IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it;
for(; it != itEnd; ++it ) std::size_t maxNameLen = 0;
std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n"; for(it = itBegin; it != itEnd; ++it )
maxNameLen = (std::max)( maxNameLen, it->first.size() );
for(it = itBegin; it != itEnd; ++it ) {
Text wrapper( it->second->getDescription(), TextAttributes()
.setInitialIndent( 0 )
.setIndent( 7+maxNameLen )
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
std::cout << " "
<< it->first
<< ":"
<< std::string( maxNameLen - it->first.size() + 2, ' ' )
<< wrapper << "\n";
}
std::cout << std::endl; std::cout << std::endl;
return factories.size(); return factories.size();
} }