catch2/include/internal/catch_list.hpp
Phil Nash 5d73c5a008 Resolve reporter outside of Config
config now only only holds reporter name
2012-07-17 08:04:19 +01:00

51 lines
1.9 KiB
C++

/*
* Created by Phil on 5/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
#include "catch_commandline.hpp"
#include <limits>
namespace Catch {
inline int List( Config& config ) {
IContext& context = getCurrentContext();
if( config.listWhat() & List::Reports ) {
std::cout << "Available reports:\n";
IReporterRegistry::FactoryMap::const_iterator it = context.getReporterRegistry().getFactories().begin();
IReporterRegistry::FactoryMap::const_iterator itEnd = context.getReporterRegistry().getFactories().end();
for(; it != itEnd; ++it ) {
// !TBD: consider listAs()
std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
}
std::cout << std::endl;
}
if( config.listWhat() & List::Tests ) {
std::cout << "Available tests:\n";
std::vector<TestCaseInfo>::const_iterator it = context.getTestCaseRegistry().getAllTests().begin();
std::vector<TestCaseInfo>::const_iterator itEnd = context.getTestCaseRegistry().getAllTests().end();
for(; it != itEnd; ++it ) {
// !TBD: consider listAs()
std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
}
std::cout << std::endl;
}
if( ( config.listWhat() & List::All ) == 0 ) {
std::cerr << "Unknown list type" << std::endl;
return (std::numeric_limits<int>::max)();
}
return 0;
}
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED