Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorPhil Nash2012-05-09 08:17:51 +0100
committerPhil Nash2012-05-09 08:17:51 +0100
commitd06dcedfdccda5d7177089202cb6a44f42f1ea42 (patch)
tree5bbf70617b6214e07405656d7a7125910e96d529 /include/internal
parente83f8397412e024853998df3cb5ec1c8430c7e75 (diff)
downloadcatch3-d06dcedfdccda5d7177089202cb6a44f42f1ea42.tar.gz
Some more reformatting.
Also fixed some warnings
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_capture.hpp57
-rw-r--r--include/internal/catch_common.h2
-rw-r--r--include/internal/catch_evaluate.hpp2
-rw-r--r--include/internal/catch_generators.hpp2
-rw-r--r--include/internal/catch_interfaces_reporter.h129
-rw-r--r--include/internal/catch_stream.hpp2
6 files changed, 48 insertions, 146 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index b882c05b..120883ba 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -364,35 +364,21 @@ private:
class ScopedInfo
{
public:
- ///////////////////////////////////////////////////////////////////////////
- ScopedInfo
- () : m_oss()
- {
+ ScopedInfo() : m_oss() {
Hub::getResultCapture().pushScopedInfo( this );
}
- ///////////////////////////////////////////////////////////////////////////
- ~ScopedInfo
- ()
- {
+ ~ScopedInfo() {
Hub::getResultCapture().popScopedInfo( this );
}
- ///////////////////////////////////////////////////////////////////////////
- ScopedInfo& operator <<
- (
- const char* str
- )
- {
- m_oss << str;
+ template<typename T>
+ ScopedInfo& operator << ( const T& value ) {
+ m_oss << value;
return *this;
}
- ///////////////////////////////////////////////////////////////////////////
- std::string getInfo
- ()
- const
- {
+ std::string getInfo () const {
return m_oss.str();
}
@@ -400,35 +386,28 @@ private:
std::ostringstream m_oss;
};
-///////////////////////////////////////////////////////////////////////////////
// This is just here to avoid compiler warnings with macro constants
-inline bool isTrue
-(
- bool value
-)
-{
- return value;
-}
+inline bool isTrue( bool value ){ return value; }
} // end namespace Catch
///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure ) \
+#define INTERNAL_CATCH_ACCEPT_EXPR( expr, stopOnFailure, originalExpr ) \
if( Catch::ResultAction::Value internal_catch_action = Catch::Hub::getResultCapture().acceptExpression( expr ) ) \
{ \
if( internal_catch_action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \
if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \
+ if( Catch::isTrue( false ) ){ bool this_is_here_to_invoke_warnings = ( originalExpr ); Catch::isTrue( this_is_here_to_invoke_warnings ); } \
}
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ) \
do{ try{ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr, isNot )->*expr ), stopOnFailure ); \
- if( Catch::isTrue( false ) ){ bool internal_catch_dummyResult = ( expr ); Catch::isTrue( internal_catch_dummyResult ); } \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr, isNot )->*expr ), stopOnFailure, expr ); \
}catch( Catch::TestFailureException& ){ \
throw; \
} catch( ... ){ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, expr ); \
throw; \
}}while( Catch::isTrue( false ) )
@@ -447,11 +426,11 @@ inline bool isTrue
try \
{ \
expr; \
- INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
} \
catch( ... ) \
{ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
}
///////////////////////////////////////////////////////////////////////////////
@@ -459,7 +438,7 @@ inline bool isTrue
try \
{ \
expr; \
- INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::DidntThrowException ), stopOnFailure, false ); \
} \
catch( Catch::TestFailureException& ) \
{ \
@@ -467,7 +446,7 @@ inline bool isTrue
} \
catch( exceptionType ) \
{ \
- INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ).setResultType( Catch::ResultWas::Ok ), stopOnFailure, false ); \
}
///////////////////////////////////////////////////////////////////////////////
@@ -475,7 +454,7 @@ inline bool isTrue
INTERNAL_CATCH_THROWS( expr, exceptionType, stopOnFailure, macroName ) \
catch( ... ) \
{ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #expr ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), stopOnFailure, false ); \
}
///////////////////////////////////////////////////////////////////////////////
@@ -490,11 +469,11 @@ inline bool isTrue
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \
do{ try{ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure, false ); \
}catch( Catch::TestFailureException& ){ \
throw; \
} catch( ... ){ \
- INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false ); \
+ INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ResultBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher ) << Catch::Hub::getExceptionTranslatorRegistry().translateActiveException() ).setResultType( Catch::ResultWas::ThrewException ), false, false ); \
throw; \
}}while( Catch::isTrue( false ) )
diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index e28b58ec..3b69959f 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -94,7 +94,7 @@ namespace Catch
}
ATTRIBUTE_NORETURN
- inline void throwLogicError( const std::string& message, const std::string& file, long line ) {
+ inline void throwLogicError( const std::string& message, const std::string& file, std::size_t line ) {
std::ostringstream oss;
oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line );
throw std::logic_error( oss.str() );
diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp
index 38e14f1a..a17b3341 100644
--- a/include/internal/catch_evaluate.hpp
+++ b/include/internal/catch_evaluate.hpp
@@ -58,7 +58,7 @@ namespace Internal
{
static bool evaluate( const T1& lhs, const T2& rhs)
{
- return const_cast<T1&>( lhs ) == const_cast<T2&>( rhs );
+ return const_cast<T1&>( lhs ) == const_cast<T2&>( rhs );
}
};
template<typename T1, typename T2>
diff --git a/include/internal/catch_generators.hpp b/include/internal/catch_generators.hpp
index c0701714..2d0cdbe0 100644
--- a/include/internal/catch_generators.hpp
+++ b/include/internal/catch_generators.hpp
@@ -68,7 +68,7 @@ public:
()
const
{
- return 1+m_to-m_from;
+ return static_cast<std::size_t>( 1+m_to-m_from );
}
private:
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index fd0e87bf..03f2439a 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -1,15 +1,10 @@
/*
- * catch_interfaces_reporter.h
- * Test
- *
* Created by Phil on 31/12/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_IREPORTERREGISTRY_INCLUDED
#define TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
@@ -23,115 +18,45 @@
namespace Catch
{
- ///////////////////////////////////////////////////////////////////////////
- struct IReporterConfig
- {
- virtual ~IReporterConfig
- ()
- {}
-
- virtual std::ostream& stream
- () const = 0;
-
- virtual bool includeSuccessfulResults
- () const = 0;
-
- virtual std::string getName
- () const = 0;
+ struct IReporterConfig {
+ virtual ~IReporterConfig() {}
+ virtual std::ostream& stream () const = 0;
+ virtual bool includeSuccessfulResults () const = 0;
+ virtual std::string getName () const = 0;
};
class TestCaseInfo;
class ResultInfo;
- ///////////////////////////////////////////////////////////////////////////
- struct IReporter : IShared
- {
- virtual ~IReporter
- (){}
-
- virtual bool shouldRedirectStdout
- () const = 0;
-
- virtual void StartTesting
- () = 0;
-
- virtual void EndTesting
- ( const Totals& totals
- ) = 0;
-
- virtual void StartGroup
- ( const std::string& groupName
- ) = 0;
-
- virtual void EndGroup
- ( const std::string& groupName,
- const Totals& totals
- ) = 0;
-
- virtual void StartSection
- ( const std::string& sectionName,
- const std::string description
- ) = 0;
-
- virtual void EndSection
- ( const std::string& sectionName,
- const Counts& assertions
- ) = 0;
-
- virtual void StartTestCase
- ( const TestCaseInfo& testInfo
- ) = 0;
-
- virtual void EndTestCase
- ( const TestCaseInfo& testInfo,
- const Totals& totals,
- const std::string& stdOut,
- const std::string& stdErr
- ) = 0;
-
- virtual void Result
- ( const ResultInfo& result
- ) = 0;
+ struct IReporter : IShared {
+ virtual ~IReporter() {}
+ virtual bool shouldRedirectStdout() const = 0;
+ virtual void StartTesting() = 0;
+ virtual void EndTesting( const Totals& totals ) = 0;
+ virtual void StartGroup( const std::string& groupName ) = 0;
+ virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0;
+ virtual void StartSection( const std::string& sectionName, const std::string description ) = 0;
+ virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0;
+ virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;
+ virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0;
+ virtual void Result( const ResultInfo& result ) = 0;
};
- ///////////////////////////////////////////////////////////////////////////
- struct IReporterFactory
- {
- virtual ~IReporterFactory
- (){}
-
- virtual IReporter* create
- ( const IReporterConfig& config
- ) const = 0;
-
- virtual std::string getDescription
- () const = 0;
+ struct IReporterFactory {
+ virtual ~IReporterFactory() {}
+ virtual IReporter* create( const IReporterConfig& config ) const = 0;
+ virtual std::string getDescription() const = 0;
};
- ///////////////////////////////////////////////////////////////////////////
- struct IReporterRegistry
- {
+ struct IReporterRegistry {
typedef std::map<std::string, IReporterFactory*> FactoryMap;
- virtual ~IReporterRegistry
- (){}
-
- virtual IReporter* create
- ( const std::string& name,
- const IReporterConfig& config
- ) const = 0;
-
- virtual void registerReporter
- ( const std::string& name,
- IReporterFactory* factory
- ) = 0;
-
- virtual const FactoryMap& getFactories
- () const = 0;
-
+ virtual ~IReporterRegistry() {}
+ virtual IReporter* create( const std::string& name, const IReporterConfig& config ) const = 0;
+ virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
+ virtual const FactoryMap& getFactories() const = 0;
};
- ///////////////////////////////////////////////////////////////////////////
inline std::string trim( const std::string& str )
{
std::string::size_type start = str.find_first_not_of( "\n\r\t " );
@@ -139,8 +64,6 @@ namespace Catch
return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
}
-
-
}
#endif // TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
diff --git a/include/internal/catch_stream.hpp b/include/internal/catch_stream.hpp
index 7717a798..e26b2f33 100644
--- a/include/internal/catch_stream.hpp
+++ b/include/internal/catch_stream.hpp
@@ -64,7 +64,7 @@ namespace Catch
{
if( pbase() != pptr() )
{
- m_writer( std::string( pbase(), pptr() - pbase() ) );
+ m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
setp( pbase(), epptr() );
}
return 0;