diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 2306af7f..242d9f82 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -77,10 +77,12 @@ namespace Catch { TestCaseStats::~TestCaseStats() {} TestGroupStats::~TestGroupStats() {} TestRunStats::~TestRunStats() {} - CumulativeReporterBase::SectionNode::~SectionNode() {} - CumulativeReporterBase::~CumulativeReporterBase() {} - - StreamingReporterBase::~StreamingReporterBase() {} + template + CumulativeReporterBase::SectionNode::~SectionNode() {} + template + CumulativeReporterBase::~CumulativeReporterBase() {} + template + StreamingReporterBase::~StreamingReporterBase() {} ConsoleReporter::~ConsoleReporter() {} CompactReporter::~CompactReporter() {} IRunner::~IRunner() {} diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index ea68aa54..5eae83cc 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -208,13 +208,12 @@ namespace Catch struct IStreamingReporter { virtual ~IStreamingReporter(); - // Implementing class must also provide the following static method: + // Implementing class must also provide the following static methods: // static std::string getDescription(); + // static std::set getSupportedVerbosities() virtual ReporterPreferences getPreferences() const = 0; - virtual std::set const& getSupportedVerbosities() const = 0; - virtual void noMatchingTestCases( std::string const& spec ) = 0; virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; diff --git a/include/reporters/catch_reporter_automake.hpp b/include/reporters/catch_reporter_automake.hpp index 00478e1f..7a841a1a 100644 --- a/include/reporters/catch_reporter_automake.hpp +++ b/include/reporters/catch_reporter_automake.hpp @@ -16,7 +16,7 @@ namespace Catch { - struct AutomakeReporter : StreamingReporterBase { + struct AutomakeReporter : StreamingReporterBase { AutomakeReporter( ReporterConfig const& _config ) : StreamingReporterBase( _config ) {} diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index f6a8d28e..9089b616 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -41,7 +41,7 @@ namespace Catch { } } - + template struct StreamingReporterBase : IStreamingReporter { StreamingReporterBase( ReporterConfig const& _config ) @@ -49,16 +49,15 @@ namespace Catch { stream( _config.stream() ) { m_reporterPrefs.shouldRedirectStdOut = false; - CATCH_ENFORCE( getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); + CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); } virtual ReporterPreferences getPreferences() const override { return m_reporterPrefs; } - virtual std::set const& getSupportedVerbosities() const override { - static std::set supported{ Verbosity::Normal }; - return supported; + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; } virtual ~StreamingReporterBase() override; @@ -110,6 +109,7 @@ namespace Catch { ReporterPreferences m_reporterPrefs; }; + template struct CumulativeReporterBase : IStreamingReporter { template struct Node { @@ -161,7 +161,7 @@ namespace Catch { stream( _config.stream() ) { m_reporterPrefs.shouldRedirectStdOut = false; - CATCH_ENFORCE( getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); + CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); } ~CumulativeReporterBase(); @@ -169,9 +169,8 @@ namespace Catch { return m_reporterPrefs; } - virtual std::set const& getSupportedVerbosities() const override { - static std::set supported{ Verbosity::Normal }; - return supported; + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; } virtual void testRunStarting( TestRunInfo const& ) override {} @@ -189,7 +188,7 @@ namespace Catch { } else { SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = + typename SectionNode::ChildSections::const_iterator it = std::find_if( parentNode.childSections.begin(), parentNode.childSections.end(), BySectionInfo( sectionInfo ) ); @@ -284,7 +283,7 @@ namespace Catch { } - struct TestEventListenerBase : StreamingReporterBase { + struct TestEventListenerBase : StreamingReporterBase { TestEventListenerBase( ReporterConfig const& _config ) : StreamingReporterBase( _config ) {} diff --git a/include/reporters/catch_reporter_compact.hpp b/include/reporters/catch_reporter_compact.hpp index 1579a608..ff461f14 100644 --- a/include/reporters/catch_reporter_compact.hpp +++ b/include/reporters/catch_reporter_compact.hpp @@ -15,7 +15,7 @@ namespace Catch { - struct CompactReporter : StreamingReporterBase { + struct CompactReporter : StreamingReporterBase { using StreamingReporterBase::StreamingReporterBase; diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index bbe38a87..3c2130f8 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -19,7 +19,7 @@ namespace Catch { - struct ConsoleReporter : StreamingReporterBase { + struct ConsoleReporter : StreamingReporterBase { using StreamingReporterBase::StreamingReporterBase; virtual ~ConsoleReporter() override; diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index cebdf3c7..08652565 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -47,7 +47,7 @@ namespace Catch { } - class JunitReporter : public CumulativeReporterBase { + class JunitReporter : public CumulativeReporterBase { public: JunitReporter( ReporterConfig const& _config ) : CumulativeReporterBase( _config ), diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp index 57f0974c..36d56584 100644 --- a/include/reporters/catch_reporter_multi.hpp +++ b/include/reporters/catch_reporter_multi.hpp @@ -15,23 +15,9 @@ namespace Catch { class MultipleReporters : public IStreamingReporter { typedef std::vector Reporters; Reporters m_reporters; - std::set m_verbosities; public: void add( IStreamingReporterPtr&& reporter ) { - if( m_reporters.empty() ) { - m_verbosities = reporter->getSupportedVerbosities(); - } - else { - for( auto it = m_verbosities.cbegin(); it != m_verbosities.cend(); ) { - if( reporter->getSupportedVerbosities().count( *it ) == 0 ) { - it = m_verbosities.erase(it); - } - else { - ++it; - } - } - } m_reporters.push_back( std::move( reporter ) ); } @@ -41,8 +27,8 @@ public: // IStreamingReporter return m_reporters[0]->getPreferences(); } - virtual std::set const& getSupportedVerbosities() const override { - return m_verbosities; + static std::set getSupportedVerbosities() { + return { }; } virtual void noMatchingTestCases( std::string const& spec ) override { diff --git a/include/reporters/catch_reporter_tap.hpp b/include/reporters/catch_reporter_tap.hpp index b34acac3..40106649 100644 --- a/include/reporters/catch_reporter_tap.hpp +++ b/include/reporters/catch_reporter_tap.hpp @@ -19,7 +19,7 @@ namespace Catch { - struct TAPReporter : StreamingReporterBase { + struct TAPReporter : StreamingReporterBase { using StreamingReporterBase::StreamingReporterBase; diff --git a/include/reporters/catch_reporter_teamcity.hpp b/include/reporters/catch_reporter_teamcity.hpp index 623ae6a3..33548987 100644 --- a/include/reporters/catch_reporter_teamcity.hpp +++ b/include/reporters/catch_reporter_teamcity.hpp @@ -23,7 +23,7 @@ namespace Catch { - struct TeamCityReporter : StreamingReporterBase { + struct TeamCityReporter : StreamingReporterBase { TeamCityReporter( ReporterConfig const& _config ) : StreamingReporterBase( _config ) { diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index b99ec11f..d685e979 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -16,7 +16,7 @@ #include "../internal/catch_timer.h" namespace Catch { - class XmlReporter : public StreamingReporterBase { + class XmlReporter : public StreamingReporterBase { public: XmlReporter( ReporterConfig const& _config ) : StreamingReporterBase( _config ),