diff options
| author | Martin Hořeňovský | 2019-11-30 20:45:34 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-11-30 20:45:34 +0100 |
| commit | fef4f217b12ec6cbcb6b680555ddd69c7c1e4a08 (patch) | |
| tree | 2af4cc93bd7cacb15d2ca2f87a68198709b1451b /src/catch2 | |
| parent | e341b1146771aeb654674e7ef6101e67d12f491b (diff) | |
| download | catch3-fef4f217b12ec6cbcb6b680555ddd69c7c1e4a08.tar.gz | |
Unit tests build and run (todo: projects, includes, extras)
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/catch_reporter_registrars.hpp | 24 | ||||
| -rw-r--r-- | src/catch2/catch_reporter_registry.cpp | 14 | ||||
| -rw-r--r-- | src/catch2/catch_reporter_registry.h | 4 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_compact.cpp | 3 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_console.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_xml.cpp | 3 |
7 files changed, 27 insertions, 25 deletions
diff --git a/src/catch2/catch_reporter_registrars.hpp b/src/catch2/catch_reporter_registrars.hpp index a1950536..842c82e8 100644 --- a/src/catch2/catch_reporter_registrars.hpp +++ b/src/catch2/catch_reporter_registrars.hpp @@ -13,24 +13,24 @@ namespace Catch { - template<typename T> - class ReporterRegistrar { + template <typename T> + class ReporterFactory : public IReporterFactory { - class ReporterFactory : public IReporterFactory { + IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr<T>( new T( config ) ); + } - IStreamingReporterPtr create( ReporterConfig const& config ) const override { - return std::unique_ptr<T>( new T( config ) ); - } + std::string getDescription() const override { + return T::getDescription(); + } + }; - std::string getDescription() const override { - return T::getDescription(); - } - }; + template<typename T> + class ReporterRegistrar { public: - explicit ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() ); + getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory<T>>() ); } }; diff --git a/src/catch2/catch_reporter_registry.cpp b/src/catch2/catch_reporter_registry.cpp index f017e059..235fab1a 100644 --- a/src/catch2/catch_reporter_registry.cpp +++ b/src/catch2/catch_reporter_registry.cpp @@ -6,9 +6,21 @@ */ #include "catch_reporter_registry.h" +#include <catch2/catch_reporter_registrars.hpp> +#include <catch2/reporters/catch_reporter_compact.h> +#include <catch2/reporters/catch_reporter_console.h> +#include <catch2/reporters/catch_reporter_junit.h> +#include <catch2/reporters/catch_reporter_xml.h> + namespace Catch { - ReporterRegistry::~ReporterRegistry() = default; + ReporterRegistry::ReporterRegistry(): + m_factories({ + {"compact", std::make_shared<ReporterFactory<CompactReporter>>() }, + {"console", std::make_shared<ReporterFactory<ConsoleReporter>>() }, + {"junit", std::make_shared<ReporterFactory<JunitReporter>>() }, + {"xml", std::make_shared<ReporterFactory<XmlReporter>>() }, + }) {} IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { auto it = m_factories.find( name ); diff --git a/src/catch2/catch_reporter_registry.h b/src/catch2/catch_reporter_registry.h index 916e9247..31fd01f8 100644 --- a/src/catch2/catch_reporter_registry.h +++ b/src/catch2/catch_reporter_registry.h @@ -15,10 +15,10 @@ namespace Catch { class ReporterRegistry : public IReporterRegistry { - public: - ~ReporterRegistry() override; + ReporterRegistry(); + ~ReporterRegistry() override = default; IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index 705144b1..2b9b35cf 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -7,7 +7,6 @@ #include "catch_reporter_compact.h" -#include "../catch_reporter_registrars.hpp" #include "../catch_console_colour.h" namespace { @@ -288,6 +287,4 @@ private: CompactReporter::~CompactReporter() {} - CATCH_REGISTER_REPORTER( "compact", CompactReporter ) - } // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index 2d1dbdfa..35698ef7 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -688,8 +688,6 @@ void ConsoleReporter::printTestFilters() { stream << Colour(Colour::BrightYellow) << "Filters: " << serializeFilters( m_config->getTestsOrTags() ) << '\n'; } -CATCH_REGISTER_REPORTER("console", ConsoleReporter) - } // end namespace Catch #if defined(_MSC_VER) diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 22ae4b37..3531d3e4 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -280,6 +280,4 @@ namespace Catch { } } - CATCH_REGISTER_REPORTER( "junit", JunitReporter ) - } // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index 212b02f6..d02488e5 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -318,9 +318,6 @@ namespace Catch { } } - - CATCH_REGISTER_REPORTER( "xml", XmlReporter ) - } // end namespace Catch #if defined(_MSC_VER) |