mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +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;
|
bool aborting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MultipleReporters;
|
||||||
|
|
||||||
struct IStreamingReporter : IShared {
|
struct IStreamingReporter : IShared {
|
||||||
virtual ~IStreamingReporter();
|
virtual ~IStreamingReporter();
|
||||||
@ -247,6 +248,8 @@ namespace Catch
|
|||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,13 +118,18 @@ public: // IStreamingReporter
|
|||||||
++it )
|
++it )
|
||||||
(*it)->skipTest( testInfo );
|
(*it)->skipTest( testInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
||||||
Ptr<IStreamingReporter> resultingReporter;
|
Ptr<IStreamingReporter> resultingReporter;
|
||||||
|
|
||||||
if( existingReporter ) {
|
if( existingReporter ) {
|
||||||
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
MultipleReporters* multi = existingReporter->tryAsMulti();
|
||||||
if( !multi ) {
|
if( !multi ) {
|
||||||
multi = new MultipleReporters;
|
multi = new MultipleReporters;
|
||||||
resultingReporter = Ptr<IStreamingReporter>( multi );
|
resultingReporter = Ptr<IStreamingReporter>( multi );
|
||||||
|
Loading…
Reference in New Issue
Block a user