From 27cae858d0c03a2f9775a8b044a304866831b161 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 7 Jun 2013 18:56:43 +0100 Subject: [PATCH] Use Text formatter to list reporters --- include/internal/catch_list.hpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index 842beca..0be1c5a 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -95,9 +95,9 @@ namespace Catch { } } if( config.filters().empty() ) - std::cout << pluralise( matchedTests, "test case" ) << std::endl; + std::cout << pluralise( matchedTests, "test case" ) << "\n" << std::endl; else - std::cout << pluralise( matchedTests, "matching test case" ) << std::endl; + std::cout << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl; return matchedTests; } @@ -150,16 +150,29 @@ namespace Catch { std::cout << countIt->second << "\n"; } - std::cout << pluralise( tagCounts.size(), "tag" ) << std::endl; + std::cout << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl; return tagCounts.size(); } inline std::size_t listReporters( 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(); - for(; it != itEnd; ++it ) - std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n"; + IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it; + std::size_t maxNameLen = 0; + 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; return factories.size(); }