fixed merge

This commit is contained in:
Phil Nash
2010-11-29 22:33:48 +00:00
13 changed files with 564 additions and 33 deletions

View File

@@ -195,6 +195,8 @@ struct IResultListener
{
virtual ~IResultListener(){}
virtual void testEnded( const ResultInfo& result ) = 0;
virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures ) = 0;
virtual void sectionEnded( const std::string& name, std::size_t successes, std::size_t failures ) = 0;
};
class ResultsCapture
@@ -269,6 +271,16 @@ public:
{
}
static bool acceptSectionStart( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures )
{
return instance().m_listener->sectionStarted( name, description, successes, failures );
}
static void acceptSectionEnd( const std::string& name, std::size_t successes, std::size_t failures )
{
instance().m_listener->sectionEnded( name, successes, failures );
}
private:
MutableResultInfo currentResult;
IResultListener* m_listener;

View File

@@ -79,16 +79,19 @@ namespace Catch
{
virtual ~ITestReporter(){}
// !TBD
// StartTesting
// EndTesting
// StartGroup
// EndGroup
// StartSection
// EndSection
virtual void StartTesting() = 0;
virtual void EndTesting( std::size_t succeeded, std::size_t failed ) = 0;
virtual void StartGroup( const std::string& groupName ) = 0;
virtual void EndGroup( const std::string& groupName, std::size_t succeeded, std::size_t failed ) = 0;
virtual void StartSection( const std::string& sectionName, const std::string description ) = 0;
virtual void EndSection( const std::string& sectionName, std::size_t succeeded, std::size_t failed ) = 0;
virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;
virtual void Result( const ResultInfo& result ) = 0;
virtual void EndTestCase( const TestCaseInfo& testInfo ) = 0;
virtual void Result( const ResultInfo& result ) = 0;
};
struct IReporterFactory

View File

@@ -20,13 +20,15 @@ namespace Catch
{
Unknown = -1,
Ok = 0,
ExpressionFailed = 1,
Info = 1,
Warning = 2,
FailureBit = 0x10,
Info = 2,
Warning = 3,
ExplicitFailure = 4,
ExpressionFailed = FailureBit | 1,
ExplicitFailure = FailureBit | 2,
Exception = 0x100,
Exception = 0x110,
ThrewException = Exception | 1,
DidntThrowException = Exception | 2
@@ -58,7 +60,7 @@ namespace Catch
bool ok() const
{
return m_result == ResultWas::Ok;
return ( m_result & ResultWas::FailureBit ) != ResultWas::FailureBit;
}
ResultWas::OfType getResultType() const

View File

@@ -48,16 +48,17 @@ namespace Catch
class Runner : public IResultListener
{
public:
Runner()
explicit Runner( ITestReporter* reporter )
: m_successes( 0 ),
m_failures( 0 ),
m_reporter( 0 )
m_reporter( reporter )
{
m_reporter->StartTesting();
}
void setReporter( ITestReporter* reporter )
~Runner()
{
m_reporter = reporter;
m_reporter->EndTesting( m_successes, m_failures );
}
void runAll()
@@ -134,6 +135,19 @@ namespace Catch
m_reporter->Result( result );
}
virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures )
{
m_reporter->StartSection( name, description );
successes = m_successes;
failures = m_failures;
return true;
}
virtual void sectionEnded( const std::string& name, std::size_t prevSuccesses, std::size_t prevFailures )
{
m_reporter->EndSection( name, m_successes - prevSuccesses, m_failures - prevFailures );
}
private:
std::size_t m_successes;

View File

@@ -13,6 +13,8 @@
#ifndef TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
#include "catch_capture.hpp"
#include <string>
namespace Catch
@@ -21,25 +23,27 @@ namespace Catch
{
public:
Section( const std::string& name, const std::string& description )
: m_name( name ), m_description( description )
: m_name( name ),
m_sectionIncluded( ResultsCapture::acceptSectionStart( name, description, m_successes, m_failures ) )
{
ResultsCapture::acceptSectionStart( name, description );
}
~Section()
{
ResultsCapture::acceptSectionEnd( m_name );
ResultsCapture::acceptSectionEnd( m_name, m_successes, m_failures );
}
// This returns whether the section should be included or not
// This indicates whether the section should be executed or not
operator bool()
{
// !TBD get this from runner
return true;
return m_sectionIncluded;
}
private:
std::string m_name;
std::string m_description;
std::size_t m_successes;
std::size_t m_failures;
bool m_sectionIncluded;
};
} // end namespace Catch