From 2efc1146bfd94780e319d6d9d90e966429d73bda Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 15 May 2012 07:42:26 +0100 Subject: [PATCH] Reformatting --- include/internal/catch_approx.hpp | 206 ++++++------------ include/internal/catch_capture.hpp | 6 +- include/internal/catch_evaluate.hpp | 109 +++------ include/internal/catch_expression.hpp | 9 +- include/internal/catch_generators.hpp | 180 +++------------ include/internal/catch_matchers.hpp | 22 +- include/internal/catch_result_type.h | 59 ++--- include/internal/catch_resultinfo.hpp | 120 +++------- include/internal/catch_resultinfo_builder.hpp | 3 +- include/internal/catch_section.hpp | 35 +-- include/internal/catch_tostring.hpp | 7 +- 11 files changed, 211 insertions(+), 545 deletions(-) diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 04e63df9..86219dab 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -1,13 +1,9 @@ /* - * catch_approx.hpp - * Catch - * * Created by Phil on 28/04/2011. * Copyright 2010 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_APPROX_HPP_INCLUDED #define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED @@ -17,140 +13,78 @@ #include #include -namespace Catch -{ - namespace Detail - { - class Approx - { - public: - /////////////////////////////////////////////////////////////////////////// - explicit Approx - ( - double value - ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_scale( 1.0 ), - m_value( value ) - { - } - - /////////////////////////////////////////////////////////////////////////// - Approx - ( - const Approx& other - ) - : m_epsilon( other.m_epsilon ), - m_scale( other.m_scale ), - m_value( other.m_value ) - { - } +namespace Catch { +namespace Detail { - /////////////////////////////////////////////////////////////////////////// - static Approx custom - () - { - return Approx( 0 ); - } - - /////////////////////////////////////////////////////////////////////////// - Approx operator() - ( - double value - ) - { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.scale( m_scale ); - return approx; - } - - /////////////////////////////////////////////////////////////////////////// - friend bool operator == - ( - double lhs, - const Approx& rhs - ) - { - // Thanks to Richard Harris for his help refining this formula - return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) ); - } - - /////////////////////////////////////////////////////////////////////////// - friend bool operator == - ( - const Approx& lhs, - double rhs - ) - { - return operator==( rhs, lhs ); - } - - /////////////////////////////////////////////////////////////////////////// - friend bool operator != - ( - double lhs, - const Approx& rhs - ) - { - return !operator==( lhs, rhs ); - } + class Approx { + public: + explicit Approx ( double value ) + : m_epsilon( std::numeric_limits::epsilon()*100 ), + m_scale( 1.0 ), + m_value( value ) + {} + + Approx( const Approx& other ) + : m_epsilon( other.m_epsilon ), + m_scale( other.m_scale ), + m_value( other.m_value ) + {} - /////////////////////////////////////////////////////////////////////////// - friend bool operator != - ( - const Approx& lhs, - double rhs - ) - { - return !operator==( rhs, lhs ); - } - - - /////////////////////////////////////////////////////////////////////////// - Approx& epsilon - ( - double newEpsilon - ) - { - m_epsilon = newEpsilon; - return *this; - } - - /////////////////////////////////////////////////////////////////////////// - Approx& scale - ( - double newScale - ) - { - m_scale = newScale; - return *this; - } - - /////////////////////////////////////////////////////////////////////////// - std::string toString() const - { - std::ostringstream oss; - oss << "Approx( " << m_value << ")"; - return oss.str(); - } - - private: - double m_epsilon; - double m_scale; - double m_value; - }; - } - - /////////////////////////////////////////////////////////////////////////////// - template<> - inline std::string toString - ( - const Detail::Approx& value - ) - { - return value.toString(); - } + static Approx custom() { + return Approx( 0 ); + } + + Approx operator()( double value ) { + Approx approx( value ); + approx.epsilon( m_epsilon ); + approx.scale( m_scale ); + return approx; + } + + friend bool operator == ( double lhs, const Approx& rhs ) { + // Thanks to Richard Harris for his help refining this formula + return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) ); + } + + friend bool operator == ( const Approx& lhs, double rhs ) { + return operator==( rhs, lhs ); + } + + friend bool operator != ( double lhs, const Approx& rhs ) { + return !operator==( lhs, rhs ); + } + + friend bool operator != ( const Approx& lhs, double rhs ) { + return !operator==( rhs, lhs ); + } + + Approx& epsilon( double newEpsilon ) { + m_epsilon = newEpsilon; + return *this; + } + + Approx& scale( double newScale ) { + m_scale = newScale; + return *this; + } + + std::string toString() const { + std::ostringstream oss; + oss << "Approx( " << m_value << ")"; + return oss.str(); + } + + private: + double m_epsilon; + double m_scale; + double m_value; + }; +} + +template<> +inline std::string toString( const Detail::Approx& value ) { + return value.toString(); +} } // end namespace Catch diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 32b26e0f..688f8455 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -15,13 +15,11 @@ #include "catch_common.h" #include -namespace Catch -{ +namespace Catch { struct TestFailureException{}; -class ScopedInfo -{ +class ScopedInfo { public: ScopedInfo() : m_oss() { Context::getResultCapture().pushScopedInfo( this ); diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index a17b3341..78472f6b 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -1,24 +1,17 @@ /* - * catch_evaluate.hpp - * Catch - * * Created by Phil on 04/03/2011. * Copyright 2011 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_EVALUATE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED -namespace Catch -{ -namespace Internal -{ - enum Operator - { +namespace Catch { +namespace Internal { + + enum Operator { IsEqualTo, IsNotEqualTo, IsLessThan, @@ -54,146 +47,116 @@ namespace Internal class Evaluator{}; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs) { return const_cast( lhs ) == const_cast( rhs ); } }; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs ) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs ) { return const_cast( lhs ) != const_cast( rhs ); } }; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs ) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs ) { return const_cast( lhs ) < const_cast( rhs ); } }; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs ) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs ) { return const_cast( lhs ) > const_cast( rhs ); } }; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs ) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs ) { return const_cast( lhs ) >= const_cast( rhs ); } }; template - struct Evaluator - { - static bool evaluate( const T1& lhs, const T2& rhs ) - { + struct Evaluator { + static bool evaluate( const T1& lhs, const T2& rhs ) { return const_cast( lhs ) <= const_cast( rhs ); } }; template - bool applyEvaluator( const T1& lhs, const T2& rhs ) - { + bool applyEvaluator( const T1& lhs, const T2& rhs ) { return Evaluator::evaluate( lhs, rhs ); } // "base" overload template - bool compare( const T1& lhs, const T2& rhs ) - { + bool compare( const T1& lhs, const T2& rhs ) { return Evaluator::evaluate( lhs, rhs ); } // unsigned X to int - template bool compare( unsigned int lhs, int rhs ) - { + template bool compare( unsigned int lhs, int rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } - template bool compare( unsigned long lhs, int rhs ) - { + template bool compare( unsigned long lhs, int rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } - template bool compare( unsigned char lhs, int rhs ) - { + template bool compare( unsigned char lhs, int rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } // unsigned X to long - template bool compare( unsigned int lhs, long rhs ) - { + template bool compare( unsigned int lhs, long rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } - template bool compare( unsigned long lhs, long rhs ) - { + template bool compare( unsigned long lhs, long rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } - template bool compare( unsigned char lhs, long rhs ) - { + template bool compare( unsigned char lhs, long rhs ) { return applyEvaluator( lhs, static_cast( rhs ) ); } // int to unsigned X - template bool compare( int lhs, unsigned int rhs ) - { + template bool compare( int lhs, unsigned int rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - template bool compare( int lhs, unsigned long rhs ) - { + template bool compare( int lhs, unsigned long rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - template bool compare( int lhs, unsigned char rhs ) - { + template bool compare( int lhs, unsigned char rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } // long to unsigned X - template bool compare( long lhs, unsigned int rhs ) - { + template bool compare( long lhs, unsigned int rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - template bool compare( long lhs, unsigned long rhs ) - { + template bool compare( long lhs, unsigned long rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - template bool compare( long lhs, unsigned char rhs ) - { + template bool compare( long lhs, unsigned char rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } template - bool compare( long lhs, const T* rhs ) - { + bool compare( long lhs, const T* rhs ) { return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); } template - bool compare( long lhs, T* rhs ) - { + bool compare( long lhs, T* rhs ) { return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); } template - bool compare( const T* lhs, long rhs ) - { + bool compare( const T* lhs, long rhs ) { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } + } template - bool compare( T* lhs, long rhs ) - { + bool compare( T* lhs, long rhs ) { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } + } } // end of namespace Internal } // end of namespace Catch diff --git a/include/internal/catch_expression.hpp b/include/internal/catch_expression.hpp index 2a3dcf87..4fe147f6 100644 --- a/include/internal/catch_expression.hpp +++ b/include/internal/catch_expression.hpp @@ -11,12 +11,10 @@ #include "catch_resultinfo_builder.hpp" #include "catch_evaluate.hpp" -namespace Catch -{ +namespace Catch { template -class Expression -{ +class Expression { void operator = ( const Expression& ); public: @@ -79,8 +77,7 @@ private: }; template -class PtrExpression -{ +class PtrExpression { public: PtrExpression ( ResultInfoBuilder& result, const LhsT* lhs ) diff --git a/include/internal/catch_generators.hpp b/include/internal/catch_generators.hpp index 08bfa4bb..6c72c397 100644 --- a/include/internal/catch_generators.hpp +++ b/include/internal/catch_generators.hpp @@ -1,15 +1,10 @@ /* - * catch_generators.hpp - * Catch - * * Created by Phil on 27/01/2011. * Copyright 2011 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_GENERATORS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED @@ -20,54 +15,25 @@ #include #include -namespace Catch -{ +namespace Catch { template -struct IGenerator -{ - virtual ~IGenerator - () - {} - - virtual T getValue - ( std::size_t index - ) const = 0; - - virtual std::size_t size - () const = 0; +struct IGenerator { + virtual ~IGenerator() {} + virtual T getValue( std::size_t index ) const = 0; + virtual std::size_t size () const = 0; }; template -class BetweenGenerator : public IGenerator -{ +class BetweenGenerator : public IGenerator { public: - /////////////////////////////////////////////////////////////////////////// - BetweenGenerator - ( - T from, - T to - ) - : m_from( from ), - m_to( to ) - { - } + BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){} - /////////////////////////////////////////////////////////////////////////// - virtual T getValue - ( - std::size_t index - ) - const - { + virtual T getValue( std::size_t index ) const { return m_from+static_cast( index ); } - /////////////////////////////////////////////////////////////////////////// - virtual std::size_t size - () - const - { + virtual std::size_t size() const { return static_cast( 1+m_to-m_from ); } @@ -78,88 +44,49 @@ private: }; template -class ValuesGenerator : public IGenerator -{ +class ValuesGenerator : public IGenerator { public: - /////////////////////////////////////////////////////////////////////////// - ValuesGenerator - () - { - } + ValuesGenerator(){} - /////////////////////////////////////////////////////////////////////////// - void add - ( - T value - ) - { + void add( T value ) { m_values.push_back( value ); } - /////////////////////////////////////////////////////////////////////////// - virtual T getValue - ( - std::size_t index - ) - const - { + virtual T getValue( std::size_t index ) const { return m_values[index]; } - /////////////////////////////////////////////////////////////////////////// - virtual std::size_t size - () - const - { + virtual std::size_t size() const { return m_values.size(); } private: - std::vector m_values; }; template -class CompositeGenerator -{ +class CompositeGenerator { public: - /////////////////////////////////////////////////////////////////////////// - CompositeGenerator() - : m_totalSize( 0 ) - { - } + CompositeGenerator() : m_totalSize( 0 ) {} - /////////////////////////////////////////////////////////////////////////// // *** Move semantics, similar to auto_ptr *** - CompositeGenerator( CompositeGenerator& other ) - : m_fileInfo( other.m_fileInfo ), - m_totalSize( 0 ) + CompositeGenerator( CompositeGenerator& other ) + : m_fileInfo( other.m_fileInfo ), + m_totalSize( 0 ) { move( other ); } - /////////////////////////////////////////////////////////////////////////// - CompositeGenerator& setFileInfo - ( - const char* fileInfo - ) - { + CompositeGenerator& setFileInfo( const char* fileInfo ) { m_fileInfo = fileInfo; return *this; } - /////////////////////////////////////////////////////////////////////////// - ~CompositeGenerator - () - { + ~CompositeGenerator() { deleteAll( m_composed ); } - /////////////////////////////////////////////////////////////////////////// - operator T - () - const - { + operator T () const { size_t overallIndex = Context::getGeneratorIndex( m_fileInfo, m_totalSize ); typename std::vector*>::const_iterator it = m_composed.begin(); @@ -177,32 +104,17 @@ public: return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so } - /////////////////////////////////////////////////////////////////////////// - void add - ( - const IGenerator* generator - ) - { + void add( const IGenerator* generator ) { m_totalSize += generator->size(); m_composed.push_back( generator ); } - /////////////////////////////////////////////////////////////////////////// - CompositeGenerator& then - ( - CompositeGenerator& other - ) - { + CompositeGenerator& then( CompositeGenerator& other ) { move( other ); return *this; } - /////////////////////////////////////////////////////////////////////////// - CompositeGenerator& then - ( - T value - ) - { + CompositeGenerator& then( T value ) { ValuesGenerator* valuesGen = new ValuesGenerator(); valuesGen->add( value ); add( valuesGen ); @@ -211,12 +123,7 @@ public: private: - /////////////////////////////////////////////////////////////////////////// - void move - ( - CompositeGenerator& other - ) - { + void move( CompositeGenerator& other ) { std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) ); m_totalSize += other.m_totalSize; other.m_composed.clear(); @@ -229,27 +136,15 @@ private: namespace Generators { - /////////////////////////////////////////////////////////////////////////// template - CompositeGenerator between - ( - T from, - T to - ) - { + CompositeGenerator between( T from, T to ) { CompositeGenerator generators; generators.add( new BetweenGenerator( from, to ) ); return generators; } - /////////////////////////////////////////////////////////////////////////// template - CompositeGenerator values - ( - T val1, - T val2 - ) - { + CompositeGenerator values( T val1, T val2 ) { CompositeGenerator generators; ValuesGenerator* valuesGen = new ValuesGenerator(); valuesGen->add( val1 ); @@ -258,15 +153,8 @@ namespace Generators return generators; } - /////////////////////////////////////////////////////////////////////////// template - CompositeGenerator values - ( - T val1, - T val2, - T val3 - ) - { + CompositeGenerator values( T val1, T val2, T val3 ){ CompositeGenerator generators; ValuesGenerator* valuesGen = new ValuesGenerator(); valuesGen->add( val1 ); @@ -276,16 +164,8 @@ namespace Generators return generators; } - /////////////////////////////////////////////////////////////////////////// template - CompositeGenerator values - ( - T val1, - T val2, - T val3, - T val4 - ) - { + CompositeGenerator values( T val1, T val2, T val3, T val4 ) { CompositeGenerator generators; ValuesGenerator* valuesGen = new ValuesGenerator(); valuesGen->add( val1 ); diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index a57bb56c..81085bbe 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -8,16 +8,12 @@ #ifndef TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED -namespace Catch -{ -namespace Matchers -{ - namespace Impl - { - namespace StdString - { - struct Contains - { +namespace Catch { +namespace Matchers { + namespace Impl { + namespace StdString { + + struct Contains { Contains( const std::string& substr ) : m_substr( substr ){} bool operator()( const std::string& str ) const @@ -33,8 +29,7 @@ namespace Matchers std::string m_substr; }; - struct StartsWith - { + struct StartsWith { StartsWith( const std::string& substr ) : m_substr( substr ){} bool operator()( const std::string& str ) const @@ -50,8 +45,7 @@ namespace Matchers std::string m_substr; }; - struct EndsWith - { + struct EndsWith { EndsWith( const std::string& substr ) : m_substr( substr ){} bool operator()( const std::string& str ) const diff --git a/include/internal/catch_result_type.h b/include/internal/catch_result_type.h index e8f6f528..f7d14ed9 100644 --- a/include/internal/catch_result_type.h +++ b/include/internal/catch_result_type.h @@ -1,51 +1,40 @@ /* - * catch_result_type.h - * Catch - * * Created by Phil on 07/01/2011. * Copyright 2011 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_RESULT_TYPE_H_INCLUDED #define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED -namespace Catch -{ +namespace Catch { -struct ResultWas{ enum OfType - { - Unknown = -1, - Ok = 0, - Info = 1, - Warning = 2, - - FailureBit = 0x10, - - ExpressionFailed = FailureBit | 1, - ExplicitFailure = FailureBit | 2, - - Exception = 0x100 | FailureBit, - - ThrewException = Exception | 1, - DidntThrowException = Exception | 2 - - }; }; +struct ResultWas { enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, + + FailureBit = 0x10, + + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, + + Exception = 0x100 | FailureBit, + + ThrewException = Exception | 1, + DidntThrowException = Exception | 2 + +}; }; - struct ResultAction - { - enum Value - { - None, - Failed = 1, // Failure - but no debug break if Debug bit not set - DebugFailed = 3 // Indicates that the debugger should break, if possible - }; - }; +struct ResultAction { enum Value { + None, + Failed = 1, // Failure - but no debug break if Debug bit not set + DebugFailed = 3 // Indicates that the debugger should break, if possible + +}; }; } - #endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED diff --git a/include/internal/catch_resultinfo.hpp b/include/internal/catch_resultinfo.hpp index bc420bdf..da291414 100644 --- a/include/internal/catch_resultinfo.hpp +++ b/include/internal/catch_resultinfo.hpp @@ -1,13 +1,9 @@ /* - * catch_resultinfo.hpp - * Catch - * * Created by Phil on 28/10/2010. * Copyright 2010 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_RESULT_INFO_HPP_INCLUDED #define TWOBLUECUBES_CATCH_RESULT_INFO_HPP_INCLUDED @@ -15,15 +11,11 @@ #include #include "catch_result_type.h" -namespace Catch -{ - class ResultInfo - { +namespace Catch { + + class ResultInfo { public: - - /////////////////////////////////////////////////////////////////////////// - ResultInfo - () + ResultInfo() : m_macroName(), m_expr(), m_lhs(), @@ -34,16 +26,12 @@ namespace Catch m_isNot( false ) {} - /////////////////////////////////////////////////////////////////////////// - ResultInfo - ( - const char* expr, - ResultWas::OfType result, - bool isNot, - const SourceLineInfo& lineInfo, - const char* macroName, - const char* message - ) + ResultInfo( const char* expr, + ResultWas::OfType result, + bool isNot, + const SourceLineInfo& lineInfo, + const char* macroName, + const char* message ) : m_macroName( macroName ), m_lineInfo( lineInfo ), m_expr( expr ), @@ -52,113 +40,61 @@ namespace Catch m_op( isNotExpression( expr ) ? "!" : "" ), m_message( message ), m_result( result ), - m_isNot( isNot ) + m_isNot( isNot ) { if( isNot ) m_expr = "!" + m_expr; } - /////////////////////////////////////////////////////////////////////////// - virtual ~ResultInfo - () - { - } + virtual ~ResultInfo() {} - /////////////////////////////////////////////////////////////////////////// - bool ok - () - const - { + bool ok() const { return ( m_result & ResultWas::FailureBit ) != ResultWas::FailureBit; } - /////////////////////////////////////////////////////////////////////////// - ResultWas::OfType getResultType - () - const - { + ResultWas::OfType getResultType() const { return m_result; } - /////////////////////////////////////////////////////////////////////////// - bool hasExpression - () - const - { + bool hasExpression() const { return !m_expr.empty(); } - /////////////////////////////////////////////////////////////////////////// - bool hasMessage - () - const - { + bool hasMessage() const { return !m_message.empty(); } - /////////////////////////////////////////////////////////////////////////// - std::string getExpression - () - const - { + std::string getExpression() const { return m_expr; } - /////////////////////////////////////////////////////////////////////////// - bool hasExpandedExpression - () - const - { + bool hasExpandedExpression() const { return hasExpression() && getExpandedExpressionInternal() != m_expr; } - /////////////////////////////////////////////////////////////////////////// - std::string getExpandedExpression - () - const - { + std::string getExpandedExpression() const { return hasExpression() ? getExpandedExpressionInternal() : ""; } - /////////////////////////////////////////////////////////////////////////// - std::string getMessage - () - const - { + std::string getMessage() const { return m_message; } - /////////////////////////////////////////////////////////////////////////// - std::string getFilename - () - const - { + std::string getFilename() const { return m_lineInfo.file; } - /////////////////////////////////////////////////////////////////////////// - std::size_t getLine - () - const - { + std::size_t getLine() const { return m_lineInfo.line; } - /////////////////////////////////////////////////////////////////////////// - std::string getTestMacroName - () - const - { + std::string getTestMacroName() const { return m_macroName; } protected: - /////////////////////////////////////////////////////////////////////////// - std::string getExpandedExpressionInternal - () - const - { + std::string getExpandedExpressionInternal() const { if( m_op == "" || m_isNot ) return m_lhs.empty() ? m_expr : m_op + m_lhs; else if( m_op == "matches" ) @@ -176,12 +112,7 @@ namespace Catch return "{can't expand - use " + m_macroName + "_FALSE( " + m_expr.substr(1) + " ) instead of " + m_macroName + "( " + m_expr + " ) for better diagnostics}"; } - /////////////////////////////////////////////////////////////////////////// - bool isNotExpression - ( - const char* expr - ) - { + bool isNotExpression( const char* expr ) { return expr && expr[0] == '!'; } @@ -196,5 +127,4 @@ namespace Catch } // end namespace Catch - #endif // TWOBLUECUBES_CATCH_RESULT_INFO_HPP_INCLUDED diff --git a/include/internal/catch_resultinfo_builder.hpp b/include/internal/catch_resultinfo_builder.hpp index 0b613c1e..60091566 100644 --- a/include/internal/catch_resultinfo_builder.hpp +++ b/include/internal/catch_resultinfo_builder.hpp @@ -14,8 +14,7 @@ #include "catch_evaluate.hpp" #include "catch_common.h" -namespace Catch -{ +namespace Catch { struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; diff --git a/include/internal/catch_section.hpp b/include/internal/catch_section.hpp index a0335435..0b2e3089 100644 --- a/include/internal/catch_section.hpp +++ b/include/internal/catch_section.hpp @@ -1,15 +1,10 @@ /* - * catch_section.hpp - * Catch - * * Created by Phil on 03/11/2010. * Copyright 2010 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_HPP_INCLUDED #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED @@ -18,36 +13,24 @@ #include -namespace Catch -{ - class Section - { +namespace Catch{ + + class Section { public: - /////////////////////////////////////////////////////////////////////// - Section - ( - const std::string& name, - const std::string& description, - const SourceLineInfo& lineInfo - ) + Section( const std::string& name, + const std::string& description, + const SourceLineInfo& lineInfo ) : m_name( name ), m_sectionIncluded( Context::getResultCapture().sectionStarted( name, description, lineInfo, m_assertions ) ) - { - } + {} - /////////////////////////////////////////////////////////////////////// - ~Section - () - { + ~Section() { if( m_sectionIncluded ) Context::getResultCapture().sectionEnded( m_name, m_assertions ); } - /////////////////////////////////////////////////////////////////////// // This indicates whether the section should be executed or not - operator bool - () - { + operator bool() { return m_sectionIncluded; } diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index 98ed8191..367a88a8 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -11,10 +11,9 @@ #include "catch_common.h" #include -namespace Catch -{ -namespace Detail -{ +namespace Catch { +namespace Detail { + struct NonStreamable { template NonStreamable( const T& ){} };