mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
parent
b6f62af7d1
commit
1e59ccee41
@ -110,7 +110,7 @@ namespace Catch {
|
|||||||
Catch::cleanUp();
|
Catch::cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showHelp() {
|
void showHelp() const {
|
||||||
Catch::cout()
|
Catch::cout()
|
||||||
<< "\nCatch v" << libraryVersion() << "\n"
|
<< "\nCatch v" << libraryVersion() << "\n"
|
||||||
<< m_cli << std::endl
|
<< m_cli << std::endl
|
||||||
|
@ -55,7 +55,7 @@ namespace Catch {
|
|||||||
auto const setRngSeed = [&]( std::string const& seed ) {
|
auto const setRngSeed = [&]( std::string const& seed ) {
|
||||||
if( seed != "time" )
|
if( seed != "time" )
|
||||||
return clara::detail::convertInto( seed, config.rngSeed );
|
return clara::detail::convertInto( seed, config.rngSeed );
|
||||||
config.rngSeed = static_cast<unsigned int>( std::time(0) );
|
config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
|
||||||
return ParserResult::ok( ParseResultType::Matched );
|
return ParserResult::ok( ParseResultType::Matched );
|
||||||
};
|
};
|
||||||
auto const setColourUsage = [&]( std::string const& useColour ) {
|
auto const setColourUsage = [&]( std::string const& useColour ) {
|
||||||
|
@ -98,7 +98,7 @@ namespace Catch {
|
|||||||
// as well as
|
// as well as
|
||||||
// >> stuff +StreamEndStop
|
// >> stuff +StreamEndStop
|
||||||
struct StreamEndStop {
|
struct StreamEndStop {
|
||||||
std::string operator+() {
|
std::string operator+() const {
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@ namespace {
|
|||||||
originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
|
originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void use( Colour::Code _colourCode ) {
|
virtual void use( Colour::Code _colourCode ) override {
|
||||||
switch( _colourCode ) {
|
switch( _colourCode ) {
|
||||||
case Colour::None: return setTextAttribute( originalForegroundAttributes );
|
case Colour::None: return setTextAttribute( originalForegroundAttributes );
|
||||||
case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
|
case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
|
||||||
@ -118,7 +118,7 @@ namespace {
|
|||||||
// https://github.com/philsquared/Catch/pull/131
|
// https://github.com/philsquared/Catch/pull/131
|
||||||
class PosixColourImpl : public IColourImpl {
|
class PosixColourImpl : public IColourImpl {
|
||||||
public:
|
public:
|
||||||
virtual void use( Colour::Code _colourCode ) {
|
virtual void use( Colour::Code _colourCode ) override {
|
||||||
switch( _colourCode ) {
|
switch( _colourCode ) {
|
||||||
case Colour::None:
|
case Colour::None:
|
||||||
case Colour::White: return setColour( "[0m" );
|
case Colour::White: return setColour( "[0m" );
|
||||||
@ -179,10 +179,13 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
Colour::Colour( Code _colourCode ) { use( _colourCode ); }
|
Colour::Colour( Code _colourCode ) { use( _colourCode ); }
|
||||||
Colour::Colour( Colour&& _other ) { const_cast<Colour&>( _other ).m_moved = true; }
|
Colour::Colour( Colour&& rhs ) noexcept {
|
||||||
Colour& Colour::operator=( Colour&& _other ) {
|
m_moved = rhs.m_moved;
|
||||||
m_moved = false;
|
rhs.m_moved = true;
|
||||||
const_cast<Colour&>( _other ).m_moved = true;
|
}
|
||||||
|
Colour& Colour::operator=( Colour&& rhs ) noexcept {
|
||||||
|
m_moved = rhs.m_moved;
|
||||||
|
rhs.m_moved = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ namespace Catch {
|
|||||||
|
|
||||||
// Use constructed object for RAII guard
|
// Use constructed object for RAII guard
|
||||||
Colour( Code _colourCode );
|
Colour( Code _colourCode );
|
||||||
Colour( Colour&& other );
|
Colour( Colour&& other ) noexcept;
|
||||||
Colour& operator=( Colour&& other );
|
Colour& operator=( Colour&& other ) noexcept;
|
||||||
~Colour();
|
~Colour();
|
||||||
|
|
||||||
// Use static method for one-shot changes
|
// Use static method for one-shot changes
|
||||||
|
@ -16,32 +16,30 @@ namespace Catch {
|
|||||||
class Context : public IMutableContext, NonCopyable {
|
class Context : public IMutableContext, NonCopyable {
|
||||||
|
|
||||||
public: // IContext
|
public: // IContext
|
||||||
virtual IResultCapture* getResultCapture() {
|
virtual IResultCapture* getResultCapture() override {
|
||||||
return m_resultCapture;
|
return m_resultCapture;
|
||||||
}
|
}
|
||||||
virtual IRunner* getRunner() {
|
virtual IRunner* getRunner() override {
|
||||||
return m_runner;
|
return m_runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual IConfigPtr getConfig() const {
|
virtual IConfigPtr getConfig() const override {
|
||||||
return m_config;
|
return m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // IMutableContext
|
public: // IMutableContext
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) {
|
virtual void setResultCapture( IResultCapture* resultCapture ) override {
|
||||||
m_resultCapture = resultCapture;
|
m_resultCapture = resultCapture;
|
||||||
}
|
}
|
||||||
virtual void setRunner( IRunner* runner ) {
|
virtual void setRunner( IRunner* runner ) override {
|
||||||
m_runner = runner;
|
m_runner = runner;
|
||||||
}
|
}
|
||||||
virtual void setConfig( IConfigPtr const& config ) {
|
virtual void setConfig( IConfigPtr const& config ) override {
|
||||||
m_config = config;
|
m_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend IMutableContext& getCurrentMutableContext();
|
friend IMutableContext& getCurrentMutableContext();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IConfigPtr m_config;
|
IConfigPtr m_config;
|
||||||
IRunner* m_runner = nullptr;
|
IRunner* m_runner = nullptr;
|
||||||
|
@ -46,7 +46,7 @@ namespace Internal {
|
|||||||
// So the compare overloads can be operator agnostic we convey the operator as a template
|
// So the compare overloads can be operator agnostic we convey the operator as a template
|
||||||
// enum, which is used to specialise an Evaluator for doing the comparison.
|
// enum, which is used to specialise an Evaluator for doing the comparison.
|
||||||
template<typename T1, typename T2, Operator Op>
|
template<typename T1, typename T2, Operator Op>
|
||||||
class Evaluator{};
|
struct Evaluator{};
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsEqualTo> {
|
struct Evaluator<T1, T2, IsEqualTo> {
|
||||||
|
@ -19,7 +19,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
~ExceptionTranslatorRegistry();
|
~ExceptionTranslatorRegistry();
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator );
|
virtual void registerTranslator( const IExceptionTranslator* translator );
|
||||||
virtual std::string translateActiveException() const;
|
virtual std::string translateActiveException() const override;
|
||||||
std::string tryTranslators() const;
|
std::string tryTranslators() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -19,7 +19,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual ~NotImplementedException() noexcept = default;
|
virtual ~NotImplementedException() noexcept = default;
|
||||||
|
|
||||||
virtual const char* what() const noexcept;
|
virtual const char* what() const noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_what;
|
std::string m_what;
|
||||||
|
@ -17,11 +17,11 @@ namespace Catch {
|
|||||||
|
|
||||||
class ReporterFactory : public IReporterFactory {
|
class ReporterFactory : public IReporterFactory {
|
||||||
|
|
||||||
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const {
|
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
||||||
return std::unique_ptr<T>( new T( config ) );
|
return std::unique_ptr<T>( new T( config ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string getDescription() const {
|
virtual std::string getDescription() const override {
|
||||||
return T::getDescription();
|
return T::getDescription();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -38,10 +38,10 @@ namespace Catch {
|
|||||||
|
|
||||||
class ListenerFactory : public IReporterFactory {
|
class ListenerFactory : public IReporterFactory {
|
||||||
|
|
||||||
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const {
|
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
||||||
return std::make_shared<T>( config );
|
return std::make_shared<T>( config );
|
||||||
}
|
}
|
||||||
virtual std::string getDescription() const {
|
virtual std::string getDescription() const override {
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -63,33 +63,30 @@ namespace Catch {
|
|||||||
private: // IResultCapture
|
private: // IResultCapture
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionEnded(AssertionResult const& result);
|
virtual void assertionEnded(AssertionResult const& result) override;
|
||||||
|
|
||||||
virtual bool sectionStarted(
|
virtual bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override;
|
||||||
SectionInfo const& sectionInfo,
|
|
||||||
Counts& assertions
|
|
||||||
);
|
|
||||||
bool testForMissingAssertions(Counts& assertions);
|
bool testForMissingAssertions(Counts& assertions);
|
||||||
|
|
||||||
virtual void sectionEnded(SectionEndInfo const& endInfo);
|
virtual void sectionEnded(SectionEndInfo const& endInfo) override;
|
||||||
|
|
||||||
virtual void sectionEndedEarly(SectionEndInfo const& endInfo);
|
virtual void sectionEndedEarly(SectionEndInfo const& endInfo) override;
|
||||||
|
|
||||||
virtual void pushScopedMessage(MessageInfo const& message);
|
virtual void pushScopedMessage(MessageInfo const& message) override;
|
||||||
|
|
||||||
virtual void popScopedMessage(MessageInfo const& message);
|
virtual void popScopedMessage(MessageInfo const& message) override;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const;
|
virtual std::string getCurrentTestName() const override;
|
||||||
|
|
||||||
virtual const AssertionResult* getLastResult() const;
|
virtual const AssertionResult* getLastResult() const override;
|
||||||
|
|
||||||
virtual void exceptionEarlyReported();
|
virtual void exceptionEarlyReported() override;
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition(std::string const& message);
|
virtual void handleFatalErrorCondition(std::string const& message) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// !TBD We need to do this another way!
|
// !TBD We need to do this another way!
|
||||||
bool aborting() const;
|
bool aborting() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -30,11 +30,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~StreamBufImpl() noexcept {
|
~StreamBufImpl() noexcept {
|
||||||
sync();
|
StreamBufImpl::sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int overflow( int c ) {
|
int overflow( int c ) override {
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
if( c != EOF ) {
|
if( c != EOF ) {
|
||||||
@ -46,7 +46,7 @@ namespace Catch {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sync() {
|
int sync() override {
|
||||||
if( pbase() != pptr() ) {
|
if( pbase() != pptr() ) {
|
||||||
m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
|
m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
|
||||||
setp( pbase(), epptr() );
|
setp( pbase(), epptr() );
|
||||||
|
@ -32,7 +32,7 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
m_data->addRef();
|
m_data->addRef();
|
||||||
}
|
}
|
||||||
String::String( String&& other )
|
String::String( String&& other ) noexcept
|
||||||
: m_data( other.m_data )
|
: m_data( other.m_data )
|
||||||
{
|
{
|
||||||
other.m_data = StringData::getEmpty();
|
other.m_data = StringData::getEmpty();
|
||||||
|
@ -28,7 +28,7 @@ namespace Catch {
|
|||||||
String( StringRef const& stringRef );
|
String( StringRef const& stringRef );
|
||||||
String( char const* rawString );
|
String( char const* rawString );
|
||||||
String( String const& other );
|
String( String const& other );
|
||||||
String( String&& other );
|
String( String&& other ) noexcept;
|
||||||
String( StringBuilder&& stringBuf );
|
String( StringBuilder&& stringBuf );
|
||||||
|
|
||||||
~String() noexcept;
|
~String() noexcept;
|
||||||
|
@ -55,7 +55,7 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
size_type rawSize = rawChars == nullptr ? 0 : static_cast<size_type>( std::strlen( rawChars ) );
|
size_type rawSize = rawChars == nullptr ? 0 : static_cast<size_type>( std::strlen( rawChars ) );
|
||||||
if( rawSize < size )
|
if( rawSize < size )
|
||||||
size = rawSize;
|
m_size = rawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef::StringRef( String const& other ) noexcept
|
StringRef::StringRef( String const& other ) noexcept
|
||||||
|
@ -63,7 +63,7 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
|
|
||||||
TrackerBase::TrackerHasName::TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {}
|
TrackerBase::TrackerHasName::TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {}
|
||||||
bool TrackerBase::TrackerHasName::operator ()( ITrackerPtr const& tracker ) {
|
bool TrackerBase::TrackerHasName::operator ()( ITrackerPtr const& tracker ) const {
|
||||||
return
|
return
|
||||||
tracker->nameAndLocation().name == m_nameAndLocation.name &&
|
tracker->nameAndLocation().name == m_nameAndLocation.name &&
|
||||||
tracker->nameAndLocation().location == m_nameAndLocation.location;
|
tracker->nameAndLocation().location == m_nameAndLocation.location;
|
||||||
@ -133,7 +133,7 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
switch( m_runState ) {
|
switch( m_runState ) {
|
||||||
case NeedsAnotherRun:
|
case NeedsAnotherRun:
|
||||||
break;;
|
break;
|
||||||
|
|
||||||
case Executing:
|
case Executing:
|
||||||
m_runState = CompletedSuccessfully;
|
m_runState = CompletedSuccessfully;
|
||||||
|
@ -101,7 +101,7 @@ namespace TestCaseTracking {
|
|||||||
NameAndLocation m_nameAndLocation;
|
NameAndLocation m_nameAndLocation;
|
||||||
public:
|
public:
|
||||||
TrackerHasName( NameAndLocation const& nameAndLocation );
|
TrackerHasName( NameAndLocation const& nameAndLocation );
|
||||||
bool operator ()( ITrackerPtr const& tracker );
|
bool operator ()( ITrackerPtr const& tracker ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<ITrackerPtr> Children;
|
typedef std::vector<ITrackerPtr> Children;
|
||||||
|
@ -33,7 +33,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
NamePattern( std::string const& name );
|
NamePattern( std::string const& name );
|
||||||
virtual ~NamePattern() = default;
|
virtual ~NamePattern() = default;
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const;
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
||||||
private:
|
private:
|
||||||
WildcardPattern m_wildcardPattern;
|
WildcardPattern m_wildcardPattern;
|
||||||
};
|
};
|
||||||
@ -42,7 +42,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
TagPattern( std::string const& tag );
|
TagPattern( std::string const& tag );
|
||||||
virtual ~TagPattern() = default;
|
virtual ~TagPattern() = default;
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const;
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
||||||
private:
|
private:
|
||||||
std::string m_tag;
|
std::string m_tag;
|
||||||
};
|
};
|
||||||
@ -51,7 +51,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
ExcludedPattern( PatternPtr const& underlyingPattern );
|
ExcludedPattern( PatternPtr const& underlyingPattern );
|
||||||
virtual ~ExcludedPattern() = default;
|
virtual ~ExcludedPattern() = default;
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const;
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
||||||
private:
|
private:
|
||||||
PatternPtr m_underlyingPattern;
|
PatternPtr m_underlyingPattern;
|
||||||
};
|
};
|
||||||
|
@ -65,11 +65,11 @@ namespace Catch {
|
|||||||
: m_writer( writer )
|
: m_writer( writer )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other )
|
XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept
|
||||||
: m_writer( other.m_writer ){
|
: m_writer( other.m_writer ){
|
||||||
other.m_writer = nullptr;
|
other.m_writer = nullptr;
|
||||||
}
|
}
|
||||||
XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) {
|
XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept {
|
||||||
if ( m_writer ) {
|
if ( m_writer ) {
|
||||||
m_writer->endElement();
|
m_writer->endElement();
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
ScopedElement( XmlWriter* writer );
|
ScopedElement( XmlWriter* writer );
|
||||||
|
|
||||||
ScopedElement( ScopedElement&& other );
|
ScopedElement( ScopedElement&& other ) noexcept;
|
||||||
ScopedElement& operator=( ScopedElement&& other );
|
ScopedElement& operator=( ScopedElement&& other ) noexcept;
|
||||||
|
|
||||||
~ScopedElement();
|
~ScopedElement();
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
void prepareExpandedExpression(AssertionResult& result) {
|
||||||
|
if (result.isOk())
|
||||||
|
result.discardDecomposedExpression();
|
||||||
|
else
|
||||||
|
result.expandDecomposedExpression();
|
||||||
|
}
|
||||||
|
|
||||||
// Because formatting using c++ streams is stateful, drop down to C is required
|
// Because formatting using c++ streams is stateful, drop down to C is required
|
||||||
// Alternatively we could use stringstream, but its performance is... not good.
|
// Alternatively we could use stringstream, but its performance is... not good.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
void prepareExpandedExpression(AssertionResult& result);
|
||||||
|
|
||||||
// Returns double formatted as %.3f (format expected on output)
|
// Returns double formatted as %.3f (format expected on output)
|
||||||
std::string getFormattedDuration( double duration );
|
std::string getFormattedDuration( double duration );
|
||||||
@ -230,13 +231,6 @@ namespace Catch {
|
|||||||
|
|
||||||
void skipTest(TestCaseInfo const&) override {}
|
void skipTest(TestCaseInfo const&) override {}
|
||||||
|
|
||||||
void prepareExpandedExpression(AssertionResult& result) const {
|
|
||||||
if (result.isOk())
|
|
||||||
result.discardDecomposedExpression();
|
|
||||||
else
|
|
||||||
result.expandDecomposedExpression();
|
|
||||||
}
|
|
||||||
|
|
||||||
IConfigPtr m_config;
|
IConfigPtr m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
std::vector<AssertionStats> m_assertions;
|
std::vector<AssertionStats> m_assertions;
|
||||||
|
@ -11,6 +11,25 @@
|
|||||||
#include "../internal/catch_reporter_registrars.hpp"
|
#include "../internal/catch_reporter_registrars.hpp"
|
||||||
#include "../internal/catch_console_colour.hpp"
|
#include "../internal/catch_console_colour.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
#ifdef CATCH_PLATFORM_MAC
|
||||||
|
const char* failedString() { return "FAILED"; }
|
||||||
|
const char* passedString() { return "PASSED"; }
|
||||||
|
#else
|
||||||
|
const char* failedString() { return "failed"; }
|
||||||
|
const char* passedString() { return "passed"; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Colour::LightGrey
|
||||||
|
Catch::Colour::Code dimColour() { return Catch::Colour::FileName; }
|
||||||
|
|
||||||
|
std::string bothOrAll( std::size_t count ) {
|
||||||
|
return count == 1 ? std::string() :
|
||||||
|
count == 2 ? "both " : "all " ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct CompactReporter : StreamingReporterBase<CompactReporter> {
|
struct CompactReporter : StreamingReporterBase<CompactReporter> {
|
||||||
@ -148,18 +167,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Colour::LightGrey
|
|
||||||
|
|
||||||
static Colour::Code dimColour() { return Colour::FileName; }
|
|
||||||
|
|
||||||
#ifdef CATCH_PLATFORM_MAC
|
|
||||||
static const char* failedString() { return "FAILED"; }
|
|
||||||
static const char* passedString() { return "PASSED"; }
|
|
||||||
#else
|
|
||||||
static const char* failedString() { return "failed"; }
|
|
||||||
static const char* passedString() { return "passed"; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void printSourceInfo() const {
|
void printSourceInfo() const {
|
||||||
Colour colourGuard( Colour::FileName );
|
Colour colourGuard( Colour::FileName );
|
||||||
stream << result.getSourceInfo() << ':';
|
stream << result.getSourceInfo() << ':';
|
||||||
@ -253,10 +260,6 @@ namespace Catch {
|
|||||||
// - red: Failed N tests cases, failed M assertions.
|
// - red: Failed N tests cases, failed M assertions.
|
||||||
// - green: Passed [both/all] N tests cases with M assertions.
|
// - green: Passed [both/all] N tests cases with M assertions.
|
||||||
|
|
||||||
std::string bothOrAll( std::size_t count ) const {
|
|
||||||
return count == 1 ? std::string() : count == 2 ? "both " : "all " ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printTotals( const Totals& totals ) const {
|
void printTotals( const Totals& totals ) const {
|
||||||
if( totals.testCases.total() == 0 ) {
|
if( totals.testCases.total() == 0 ) {
|
||||||
stream << "No tests ran.";
|
stream << "No tests ran.";
|
||||||
|
@ -16,6 +16,22 @@
|
|||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::size_t makeRatio( std::size_t number, std::size_t total ) {
|
||||||
|
std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
|
||||||
|
return ( ratio == 0 && number > 0 ) ? 1 : ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
|
||||||
|
if( i > j && i > k )
|
||||||
|
return i;
|
||||||
|
else if( j > k )
|
||||||
|
return j;
|
||||||
|
else
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
|
struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
|
||||||
@ -390,19 +406,6 @@ namespace Catch {
|
|||||||
stream << '\n';
|
stream << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
|
|
||||||
std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
|
|
||||||
return ( ratio == 0 && number > 0 ) ? 1 : ratio;
|
|
||||||
}
|
|
||||||
static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
|
|
||||||
if( i > j && i > k )
|
|
||||||
return i;
|
|
||||||
else if( j > k )
|
|
||||||
return j;
|
|
||||||
else
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printTotalsDivider( Totals const& totals ) {
|
void printTotalsDivider( Totals const& totals ) {
|
||||||
if( totals.testCases.total() > 0 ) {
|
if( totals.testCases.total() > 0 ) {
|
||||||
std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() );
|
std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() );
|
||||||
|
@ -187,7 +187,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// if string has a : in first line will set indent to follow it on
|
// if string has a : in first line will set indent to follow it on
|
||||||
// subsequent lines
|
// subsequent lines
|
||||||
void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
|
static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
|
||||||
std::size_t i = _string.find( ": " );
|
std::size_t i = _string.find( ": " );
|
||||||
if( i != std::string::npos )
|
if( i != std::string::npos )
|
||||||
i+=2;
|
i+=2;
|
||||||
|
Loading…
Reference in New Issue
Block a user