mirror of
https://github.com/catchorg/Catch2.git
synced 2025-02-16 19:43:28 +01:00
Split imply from TrackedSection class to avoid use of incomplete type
- see #450
This commit is contained in:
parent
804896cdfa
commit
6d5797231c
@ -16,9 +16,9 @@ namespace Catch {
|
|||||||
namespace SectionTracking {
|
namespace SectionTracking {
|
||||||
|
|
||||||
class TrackedSection {
|
class TrackedSection {
|
||||||
|
|
||||||
typedef std::map<std::string, TrackedSection> TrackedSections;
|
typedef std::map<std::string, TrackedSection> TrackedSections;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum RunState {
|
enum RunState {
|
||||||
NotStarted,
|
NotStarted,
|
||||||
@ -26,53 +26,58 @@ namespace SectionTracking {
|
|||||||
ExecutingChildren,
|
ExecutingChildren,
|
||||||
Completed
|
Completed
|
||||||
};
|
};
|
||||||
|
|
||||||
TrackedSection( std::string const& name, TrackedSection* parent )
|
TrackedSection( std::string const& name, TrackedSection* parent )
|
||||||
: m_name( name ), m_runState( NotStarted ), m_parent( parent )
|
: m_name( name ), m_runState( NotStarted ), m_parent( parent )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RunState runState() const { return m_runState; }
|
RunState runState() const { return m_runState; }
|
||||||
|
|
||||||
|
TrackedSection* findChild( std::string const& childName );
|
||||||
|
TrackedSection* acquireChild( std::string const& childName );
|
||||||
|
|
||||||
TrackedSection* findChild( std::string const& childName ) {
|
|
||||||
TrackedSections::iterator it = m_children.find( childName );
|
|
||||||
return it != m_children.end()
|
|
||||||
? &it->second
|
|
||||||
: NULL;
|
|
||||||
}
|
|
||||||
TrackedSection* acquireChild( std::string const& childName ) {
|
|
||||||
if( TrackedSection* child = findChild( childName ) )
|
|
||||||
return child;
|
|
||||||
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
|
|
||||||
return findChild( childName );
|
|
||||||
}
|
|
||||||
void enter() {
|
void enter() {
|
||||||
if( m_runState == NotStarted )
|
if( m_runState == NotStarted )
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
}
|
}
|
||||||
void leave() {
|
void leave();
|
||||||
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
|
|
||||||
it != itEnd;
|
|
||||||
++it )
|
|
||||||
if( it->second.runState() != Completed ) {
|
|
||||||
m_runState = ExecutingChildren;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_runState = Completed;
|
|
||||||
}
|
|
||||||
TrackedSection* getParent() {
|
TrackedSection* getParent() {
|
||||||
return m_parent;
|
return m_parent;
|
||||||
}
|
}
|
||||||
bool hasChildren() const {
|
bool hasChildren() const {
|
||||||
return !m_children.empty();
|
return !m_children.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
RunState m_runState;
|
RunState m_runState;
|
||||||
TrackedSections m_children;
|
TrackedSections m_children;
|
||||||
TrackedSection* m_parent;
|
TrackedSection* m_parent;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
|
||||||
|
TrackedSections::iterator it = m_children.find( childName );
|
||||||
|
return it != m_children.end()
|
||||||
|
? &it->second
|
||||||
|
: NULL;
|
||||||
|
}
|
||||||
|
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
||||||
|
if( TrackedSection* child = findChild( childName ) )
|
||||||
|
return child;
|
||||||
|
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
|
||||||
|
return findChild( childName );
|
||||||
|
}
|
||||||
|
inline void TrackedSection::leave() {
|
||||||
|
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
if( it->second.runState() != Completed ) {
|
||||||
|
m_runState = ExecutingChildren;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_runState = Completed;
|
||||||
|
}
|
||||||
|
|
||||||
class TestCaseTracker {
|
class TestCaseTracker {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user