mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
Removed use of dynamic_cast for MultipleReporters
(Thanks to #630, #636 and #648)
This commit is contained in:
parent
e5537842d0
commit
3b19458fed
@ -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; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user