diff options
| author | Phil Nash | 2015-06-30 18:25:49 +0100 |
|---|---|---|
| committer | Phil Nash | 2015-06-30 18:25:49 +0100 |
| commit | 6d5797231c8d362c94282dd4cc85b0264fc6bec8 (patch) | |
| tree | 40ca2ffd11a29018d9a5d5d934fcb2f240230ea5 /include | |
| parent | 804896cdfaf103c2c25b3edf5509b7d612aacb22 (diff) | |
| download | catch3-6d5797231c8d362c94282dd4cc85b0264fc6bec8.tar.gz | |
Split imply from TrackedSection class to avoid use of incomplete type
- see #450
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_test_case_tracker.hpp | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index 2165e1cc..86b6be50 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -16,9 +16,9 @@ namespace Catch { namespace SectionTracking { class TrackedSection { - + typedef std::map<std::string, TrackedSection> TrackedSections; - + public: enum RunState { NotStarted, @@ -26,53 +26,58 @@ namespace SectionTracking { ExecutingChildren, Completed }; - + TrackedSection( std::string const& name, TrackedSection* parent ) : m_name( name ), m_runState( NotStarted ), m_parent( parent ) {} - + 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() { if( m_runState == NotStarted ) m_runState = Executing; } - 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; - } + void leave(); + TrackedSection* getParent() { return m_parent; } bool hasChildren() const { return !m_children.empty(); } - + private: std::string m_name; RunState m_runState; 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 { public: |