mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
71df66365e
All C++11 toggles are now removed. What is left is either platform specific (POSIX_SIGNALS, WINDOWS_SEH), or possibly still needed (USE_COUNTER). If current CLion is compatible with `__COUNTER__`, then we should also force `__COUNTER__` usage. Changed * CATCH_AUTO_PTR -> std::unique_ptr * CATCH_OVERRIDE -> override * CATCH_NULL -> nullptr * CATCH_NOEXCEPT -> noexcept * CATCH_NOEXCEPT_IS -> noexcept Removed * CATCH_CONFIG_CPP11_UNIQUE_PTR * CATCH_CONFIG_CPP11_SHUFFLE * CATCH_CONFIG_CPP11_TYPE_TRAITS * CATCH_CONFIG_CPP11_OVERRIDE * CATCH_CONFIG_CPP11_LONG_LONG * CATCH_CONFIG_CPP11_TUPLE * CATCH_CONFIG_CPP11_IS_ENUM * CATCH_CONFIG_CPP11_GENERATED_METHODS * CATCH_CONFIG_CPP11_NOEXCEPT * CATCH_CONFIG_CPP11_NULLPTR * CATCH_CONFIG_VARIADIC_MACROS
107 lines
2.7 KiB
C++
107 lines
2.7 KiB
C++
/*
|
|
* Created by Phil Nash on 4/5/2012
|
|
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
|
|
*
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
*/
|
|
#ifndef TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED
|
|
#define TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED
|
|
|
|
#include "catch_section_info.h"
|
|
|
|
namespace Catch {
|
|
|
|
class RunningSection {
|
|
public:
|
|
|
|
typedef std::vector<RunningSection*> SubSections;
|
|
|
|
enum State {
|
|
Root,
|
|
Unknown,
|
|
Branch,
|
|
TestedBranch,
|
|
TestedLeaf
|
|
};
|
|
|
|
RunningSection( RunningSection* parent, std::string const& name )
|
|
: m_state( Unknown ),
|
|
m_parent( parent ),
|
|
m_name( name )
|
|
{}
|
|
|
|
RunningSection( std::string const& name )
|
|
: m_state( Root ),
|
|
m_parent( nullptr ),
|
|
m_name( name )
|
|
{}
|
|
|
|
~RunningSection() {
|
|
deleteAll( m_subSections );
|
|
}
|
|
|
|
std::string getName() const {
|
|
return m_name;
|
|
}
|
|
|
|
bool shouldRun() const {
|
|
return m_state < TestedBranch;
|
|
}
|
|
|
|
bool isBranch() const {
|
|
return m_state == Branch;
|
|
}
|
|
|
|
const RunningSection* getParent() const {
|
|
return m_parent;
|
|
}
|
|
|
|
bool hasUntestedSections() const {
|
|
if( m_state == Unknown )
|
|
return true;
|
|
for( auto subSection : m_subSections )
|
|
if( subSection->hasUntestedSections() )
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
// Mutable methods:
|
|
|
|
RunningSection* getParent() {
|
|
return m_parent;
|
|
}
|
|
|
|
RunningSection* findOrAddSubSection( std::string const& name, bool& changed ) {
|
|
for( auto subSection : m_subSections )
|
|
if( subSection->getName() == name )
|
|
return *it;
|
|
RunningSection* subSection = new RunningSection( this, name );
|
|
m_subSections.push_back( subSection );
|
|
m_state = Branch;
|
|
changed = true;
|
|
return subSection;
|
|
}
|
|
|
|
bool ran() {
|
|
if( m_state >= Branch )
|
|
return false;
|
|
m_state = TestedLeaf;
|
|
return true;
|
|
}
|
|
|
|
void ranToCompletion() {
|
|
if( m_state == Branch && !hasUntestedSections() )
|
|
m_state = TestedBranch;
|
|
}
|
|
|
|
private:
|
|
State m_state;
|
|
RunningSection* m_parent;
|
|
std::string m_name;
|
|
SubSections m_subSections;
|
|
};
|
|
}
|
|
|
|
#endif // TWOBLUECUBES_CATCH_SECTION_INFO_HPP_INCLUDED
|