Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2016-04-28 07:54:57 +0100
committerPhil Nash2016-04-28 08:11:12 +0100
commit3b19458fed6cf6f34970a6103c70abbca9d63f92 (patch)
tree5715fb1e8dbc35c3b8c94afda055d9538ecc78cf /include
parente5537842d02b4fff68db23b461d1a8f4562a08e0 (diff)
downloadcatch3-3b19458fed6cf6f34970a6103c70abbca9d63f92.tar.gz
Removed use of dynamic_cast for MultipleReporters
(Thanks to #630, #636 and #648)
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_interfaces_reporter.h3
-rw-r--r--include/reporters/catch_reporter_multi.hpp7
2 files changed, 9 insertions, 1 deletions
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index d1c6e704..98e2cd6a 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -219,6 +219,7 @@ namespace Catch
bool aborting;
};
+ class MultipleReporters;
struct IStreamingReporter : IShared {
virtual ~IStreamingReporter();
@@ -247,6 +248,8 @@ namespace Catch
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
+
+ virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
};
diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp
index d3282666..7fc08f69 100644
--- a/include/reporters/catch_reporter_multi.hpp
+++ b/include/reporters/catch_reporter_multi.hpp
@@ -118,13 +118,18 @@ public: // IStreamingReporter
++it )
(*it)->skipTest( testInfo );
}
+
+ virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
+ return this;
+ }
+
};
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
Ptr<IStreamingReporter> resultingReporter;
if( existingReporter ) {
- MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
+ MultipleReporters* multi = existingReporter->tryAsMulti();
if( !multi ) {
multi = new MultipleReporters;
resultingReporter = Ptr<IStreamingReporter>( multi );