mirror of
https://github.com/catchorg/Catch2
synced 2026-02-24 04:32:12 +00:00
Simplify IGeneratorTracker
* Removed `IGeneratorTracker::hasGenerator`, as it was never used. * Removed `IGeneratorTracker::setGenerator`, as actually using it after the tracker was used would lead to inconsistent behaviour. Instead, the tracker is given the generator it guards during construction.
This commit is contained in:
@@ -105,9 +105,7 @@ namespace Catch {
|
||||
class IGeneratorTracker {
|
||||
public:
|
||||
virtual ~IGeneratorTracker(); // = default;
|
||||
virtual auto hasGenerator() const -> bool = 0;
|
||||
virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;
|
||||
virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0;
|
||||
};
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
@@ -39,8 +39,13 @@ namespace Catch {
|
||||
GeneratorTracker(
|
||||
TestCaseTracking::NameAndLocation&& nameAndLocation,
|
||||
TrackerContext& ctx,
|
||||
ITracker* parent ):
|
||||
TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {}
|
||||
ITracker* parent,
|
||||
GeneratorBasePtr&& generator ):
|
||||
TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ),
|
||||
m_generator( CATCH_MOVE( generator ) ) {
|
||||
assert( m_generator &&
|
||||
"Cannot create tracker without generator" );
|
||||
}
|
||||
|
||||
static GeneratorTracker*
|
||||
acquire( TrackerContext& ctx,
|
||||
@@ -84,9 +89,6 @@ namespace Catch {
|
||||
|
||||
// TrackerBase interface
|
||||
bool isGeneratorTracker() const override { return true; }
|
||||
auto hasGenerator() const -> bool override {
|
||||
return !!m_generator;
|
||||
}
|
||||
void close() override {
|
||||
TrackerBase::close();
|
||||
// If a generator has a child (it is followed by a section)
|
||||
@@ -157,9 +159,6 @@ namespace Catch {
|
||||
auto getGenerator() const -> GeneratorBasePtr const& override {
|
||||
return m_generator;
|
||||
}
|
||||
void setGenerator( GeneratorBasePtr&& generator ) override {
|
||||
m_generator = CATCH_MOVE( generator );
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
}
|
||||
@@ -497,12 +496,15 @@ namespace Catch {
|
||||
currentTracker.nameAndLocation() != nameAndLoc &&
|
||||
"Trying to create tracker for a generator that already has one" );
|
||||
|
||||
auto newTracker = Catch::Detail::make_unique<Generators::GeneratorTracker>(
|
||||
CATCH_MOVE(nameAndLoc), m_trackerContext, ¤tTracker );
|
||||
auto newTracker =
|
||||
Catch::Detail::make_unique<Generators::GeneratorTracker>(
|
||||
CATCH_MOVE( nameAndLoc ),
|
||||
m_trackerContext,
|
||||
¤tTracker,
|
||||
CATCH_MOVE( generator ) );
|
||||
auto ret = newTracker.get();
|
||||
currentTracker.addChild( CATCH_MOVE( newTracker ) );
|
||||
|
||||
ret->setGenerator( CATCH_MOVE( generator ) );
|
||||
ret->open();
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user