mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-04 19:08:12 +00:00
Moar reformatting
This commit is contained in:
parent
d0be9ed5d9
commit
c67a7eef2b
8 changed files with 140 additions and 429 deletions
|
@ -11,12 +11,11 @@
|
|||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_section_info.hpp"
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
class RunningTest
|
||||
{
|
||||
enum RunStatus
|
||||
{
|
||||
namespace Catch {
|
||||
|
||||
class RunningTest {
|
||||
|
||||
enum RunStatus {
|
||||
NothingRun,
|
||||
EncounteredASection,
|
||||
RanAtLeastOneSection,
|
||||
|
@ -25,74 +24,49 @@ namespace Catch
|
|||
};
|
||||
|
||||
public:
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
explicit RunningTest
|
||||
(
|
||||
const TestCaseInfo* info = NULL
|
||||
)
|
||||
explicit RunningTest( const TestCaseInfo* info = NULL )
|
||||
: m_info( info ),
|
||||
m_runStatus( RanAtLeastOneSection ),
|
||||
m_currentSection( &m_rootSection ),
|
||||
m_changed( false )
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
bool wasSectionSeen
|
||||
()
|
||||
const
|
||||
{
|
||||
bool wasSectionSeen() const {
|
||||
return m_runStatus == RanAtLeastOneSection ||
|
||||
m_runStatus == RanToCompletionWithSections;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void reset
|
||||
()
|
||||
{
|
||||
void reset() {
|
||||
m_runStatus = NothingRun;
|
||||
m_changed = false;
|
||||
m_lastSectionToRun = NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void ranToCompletion
|
||||
()
|
||||
{
|
||||
void ranToCompletion() {
|
||||
if( m_runStatus == RanAtLeastOneSection ||
|
||||
m_runStatus == EncounteredASection )
|
||||
{
|
||||
m_runStatus == EncounteredASection ) {
|
||||
m_runStatus = RanToCompletionWithSections;
|
||||
if( m_lastSectionToRun )
|
||||
{
|
||||
if( m_lastSectionToRun ) {
|
||||
m_lastSectionToRun->ranToCompletion();
|
||||
m_changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
m_runStatus = RanToCompletionWithNoSections;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
bool addSection
|
||||
(
|
||||
const std::string& name
|
||||
)
|
||||
{
|
||||
bool addSection( const std::string& name ) {
|
||||
if( m_runStatus == NothingRun )
|
||||
m_runStatus = EncounteredASection;
|
||||
|
||||
SectionInfo* thisSection = m_currentSection->findSubSection( name );
|
||||
if( !thisSection )
|
||||
{
|
||||
if( !thisSection ) {
|
||||
thisSection = m_currentSection->addSubSection( name );
|
||||
m_changed = true;
|
||||
}
|
||||
|
||||
if( !wasSectionSeen() && thisSection->shouldRun() )
|
||||
{
|
||||
if( !wasSectionSeen() && thisSection->shouldRun() ) {
|
||||
m_currentSection = thisSection;
|
||||
m_lastSectionToRun = NULL;
|
||||
return true;
|
||||
|
@ -100,38 +74,23 @@ namespace Catch
|
|||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void endSection
|
||||
(
|
||||
const std::string&
|
||||
)
|
||||
{
|
||||
if( m_currentSection->ran() )
|
||||
{
|
||||
void endSection( const std::string& ) {
|
||||
if( m_currentSection->ran() ) {
|
||||
m_runStatus = RanAtLeastOneSection;
|
||||
m_changed = true;
|
||||
}
|
||||
else if( m_runStatus == EncounteredASection )
|
||||
{
|
||||
else if( m_runStatus == EncounteredASection ) {
|
||||
m_runStatus = RanAtLeastOneSection;
|
||||
m_lastSectionToRun = m_currentSection;
|
||||
}
|
||||
m_currentSection = m_currentSection->getParent();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
const TestCaseInfo& getTestCaseInfo
|
||||
()
|
||||
const
|
||||
{
|
||||
const TestCaseInfo& getTestCaseInfo() const {
|
||||
return *m_info;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
bool hasUntestedSections
|
||||
()
|
||||
const
|
||||
{
|
||||
bool hasUntestedSections() const {
|
||||
return m_runStatus == RanAtLeastOneSection ||
|
||||
( m_rootSection.hasUntestedSections() && m_changed );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue