mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Changed "const X ref"s to "X const ref"s
- Brought older code up to current convention (with the help of a Python script)
This commit is contained in:
parent
d0d4d93a6b
commit
2a9d8d9e36
@ -24,7 +24,7 @@ namespace Detail {
|
|||||||
m_value( value )
|
m_value( value )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Approx( const Approx& other )
|
Approx( Approx const& other )
|
||||||
: m_epsilon( other.m_epsilon ),
|
: m_epsilon( other.m_epsilon ),
|
||||||
m_scale( other.m_scale ),
|
m_scale( other.m_scale ),
|
||||||
m_value( other.m_value )
|
m_value( other.m_value )
|
||||||
@ -41,20 +41,20 @@ namespace Detail {
|
|||||||
return approx;
|
return approx;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator == ( double lhs, const Approx& rhs ) {
|
friend bool operator == ( double lhs, Approx const& rhs ) {
|
||||||
// Thanks to Richard Harris for his help refining this formula
|
// 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) ) );
|
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 ) {
|
friend bool operator == ( Approx const& lhs, double rhs ) {
|
||||||
return operator==( rhs, lhs );
|
return operator==( rhs, lhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator != ( double lhs, const Approx& rhs ) {
|
friend bool operator != ( double lhs, Approx const& rhs ) {
|
||||||
return !operator==( lhs, rhs );
|
return !operator==( lhs, rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator != ( const Approx& lhs, double rhs ) {
|
friend bool operator != ( Approx const& lhs, double rhs ) {
|
||||||
return !operator==( rhs, lhs );
|
return !operator==( rhs, lhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace Detail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline std::string toString<Detail::Approx>( const Detail::Approx& value ) {
|
inline std::string toString<Detail::Approx>( Detail::Approx const& value ) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ namespace Catch {
|
|||||||
struct AssertionInfo
|
struct AssertionInfo
|
||||||
{
|
{
|
||||||
AssertionInfo() {}
|
AssertionInfo() {}
|
||||||
AssertionInfo( const std::string& _macroName,
|
AssertionInfo( std::string const& _macroName,
|
||||||
const SourceLineInfo& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
const std::string& _capturedExpression,
|
std::string const& _capturedExpression,
|
||||||
ResultDisposition::Flags _resultDisposition );
|
ResultDisposition::Flags _resultDisposition );
|
||||||
|
|
||||||
std::string macroName;
|
std::string macroName;
|
||||||
@ -39,7 +39,7 @@ namespace Catch {
|
|||||||
class AssertionResult {
|
class AssertionResult {
|
||||||
public:
|
public:
|
||||||
AssertionResult();
|
AssertionResult();
|
||||||
AssertionResult( const AssertionInfo& info, const AssertionResultData& data );
|
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
||||||
~AssertionResult();
|
~AssertionResult();
|
||||||
|
|
||||||
bool isOk() const;
|
bool isOk() const;
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
|
||||||
AssertionInfo::AssertionInfo( const std::string& _macroName,
|
AssertionInfo::AssertionInfo( std::string const& _macroName,
|
||||||
const SourceLineInfo& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
const std::string& _capturedExpression,
|
std::string const& _capturedExpression,
|
||||||
ResultDisposition::Flags _resultDisposition )
|
ResultDisposition::Flags _resultDisposition )
|
||||||
: macroName( _macroName ),
|
: macroName( _macroName ),
|
||||||
lineInfo( _lineInfo ),
|
lineInfo( _lineInfo ),
|
||||||
@ -28,7 +28,7 @@ namespace Catch {
|
|||||||
|
|
||||||
AssertionResult::AssertionResult() {}
|
AssertionResult::AssertionResult() {}
|
||||||
|
|
||||||
AssertionResult::AssertionResult( const AssertionInfo& info, const AssertionResultData& data )
|
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_resultData( data )
|
m_resultData( data )
|
||||||
{}
|
{}
|
||||||
|
@ -27,8 +27,8 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatcherT>
|
template<typename MatcherT>
|
||||||
ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
|
ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
|
||||||
const std::string& matcherCallAsString ) {
|
std::string const& matcherCallAsString ) {
|
||||||
std::string matcherAsString = matcher.toString();
|
std::string matcherAsString = matcher.toString();
|
||||||
if( matcherAsString == "{?}" )
|
if( matcherAsString == "{?}" )
|
||||||
matcherAsString = matcherCallAsString;
|
matcherAsString = matcherCallAsString;
|
||||||
@ -38,18 +38,18 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatcherT, typename ArgT>
|
template<typename MatcherT, typename ArgT>
|
||||||
ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
|
ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
|
||||||
const ArgT& arg,
|
ArgT const& arg,
|
||||||
const std::string& matcherCallAsString ) {
|
std::string const& matcherCallAsString ) {
|
||||||
return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
|
return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
|
||||||
.setLhs( Catch::toString( arg ) )
|
.setLhs( Catch::toString( arg ) )
|
||||||
.setResultType( matcher.match( arg ) );
|
.setResultType( matcher.match( arg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatcherT, typename ArgT>
|
template<typename MatcherT, typename ArgT>
|
||||||
ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher,
|
ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher,
|
||||||
ArgT* arg,
|
ArgT* arg,
|
||||||
const std::string& matcherCallAsString ) {
|
std::string const& matcherCallAsString ) {
|
||||||
return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
|
return expressionResultBuilderFromMatcher( matcher, matcherCallAsString )
|
||||||
.setLhs( Catch::toString( arg ) )
|
.setLhs( Catch::toString( arg ) )
|
||||||
.setResultType( matcher.match( arg ) );
|
.setResultType( matcher.match( arg ) );
|
||||||
|
@ -17,20 +17,20 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
Command(){}
|
Command(){}
|
||||||
|
|
||||||
explicit Command( const std::string& name ) : m_name( name ) {
|
explicit Command( std::string const& name ) : m_name( name ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Command& operator += ( const std::string& arg ) {
|
Command& operator += ( std::string const& arg ) {
|
||||||
m_args.push_back( arg );
|
m_args.push_back( arg );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Command& operator += ( const Command& other ) {
|
Command& operator += ( Command const& other ) {
|
||||||
std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
|
std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
|
||||||
if( m_name.empty() )
|
if( m_name.empty() )
|
||||||
m_name = other.m_name;
|
m_name = other.m_name;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Command operator + ( const Command& other ) {
|
Command operator + ( Command const& other ) {
|
||||||
Command newCommand( *this );
|
Command newCommand( *this );
|
||||||
newCommand += other;
|
newCommand += other;
|
||||||
return newCommand;
|
return newCommand;
|
||||||
@ -45,7 +45,7 @@ namespace Catch {
|
|||||||
std::size_t argsCount() const { return m_args.size(); }
|
std::size_t argsCount() const { return m_args.size(); }
|
||||||
|
|
||||||
CATCH_ATTRIBUTE_NORETURN
|
CATCH_ATTRIBUTE_NORETURN
|
||||||
void raiseError( const std::string& message ) const {
|
void raiseError( std::string const& message ) const {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if( m_name.empty() )
|
if( m_name.empty() )
|
||||||
oss << "Error while parsing " << m_name << ". " << message << ".";
|
oss << "Error while parsing " << m_name << ". " << message << ".";
|
||||||
@ -76,14 +76,14 @@ namespace Catch {
|
|||||||
exeName = exeName.substr( pos+1 );
|
exeName = exeName.substr( pos+1 );
|
||||||
return exeName;
|
return exeName;
|
||||||
}
|
}
|
||||||
Command find( const std::string& arg1, const std::string& arg2, const std::string& arg3 ) const {
|
Command find( std::string const& arg1, std::string const& arg2, std::string const& arg3 ) const {
|
||||||
return find( arg1 ) + find( arg2 ) + find( arg3 );
|
return find( arg1 ) + find( arg2 ) + find( arg3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Command find( const std::string& shortArg, const std::string& longArg ) const {
|
Command find( std::string const& shortArg, std::string const& longArg ) const {
|
||||||
return find( shortArg ) + find( longArg );
|
return find( shortArg ) + find( longArg );
|
||||||
}
|
}
|
||||||
Command find( const std::string& arg ) const {
|
Command find( std::string const& arg ) const {
|
||||||
if( arg.empty() )
|
if( arg.empty() )
|
||||||
return getArgs( "", 1 );
|
return getArgs( "", 1 );
|
||||||
else
|
else
|
||||||
@ -97,7 +97,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Command getArgs( const std::string& cmdName, std::size_t from ) const {
|
Command getArgs( std::string const& cmdName, std::size_t from ) const {
|
||||||
Command command( cmdName );
|
Command command( cmdName );
|
||||||
for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i )
|
for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i )
|
||||||
command += m_argv[i];
|
command += m_argv[i];
|
||||||
@ -116,7 +116,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual ~OptionParser() {}
|
virtual ~OptionParser() {}
|
||||||
|
|
||||||
Command find( const CommandParser& parser ) const {
|
Command find( CommandParser const& parser ) const {
|
||||||
Command cmd;
|
Command cmd;
|
||||||
for( std::vector<std::string>::const_iterator it = m_optionNames.begin();
|
for( std::vector<std::string>::const_iterator it = m_optionNames.begin();
|
||||||
it != m_optionNames.end();
|
it != m_optionNames.end();
|
||||||
@ -125,7 +125,7 @@ namespace Catch {
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateArgs( const Command& args ) const {
|
void validateArgs( Command const& args ) const {
|
||||||
if( tooFewArgs( args ) || tooManyArgs( args ) ) {
|
if( tooFewArgs( args ) || tooManyArgs( args ) ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if( m_maxArgs == -1 )
|
if( m_maxArgs == -1 )
|
||||||
@ -138,14 +138,14 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
|
void parseIntoConfig( CommandParser const& parser, ConfigData& config ) {
|
||||||
if( Command cmd = find( parser ) ) {
|
if( Command cmd = find( parser ) ) {
|
||||||
validateArgs( cmd );
|
validateArgs( cmd );
|
||||||
parseIntoConfig( cmd, config );
|
parseIntoConfig( cmd, config );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) = 0;
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) = 0;
|
||||||
virtual std::string argsSynopsis() const = 0;
|
virtual std::string argsSynopsis() const = 0;
|
||||||
virtual std::string optionSummary() const = 0;
|
virtual std::string optionSummary() const = 0;
|
||||||
virtual std::string optionDescription() const { return ""; }
|
virtual std::string optionDescription() const { return ""; }
|
||||||
@ -171,10 +171,10 @@ namespace Catch {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool tooFewArgs( const Command& args ) const {
|
bool tooFewArgs( Command const& args ) const {
|
||||||
return args.argsCount() < static_cast<std::size_t>( m_minArgs );
|
return args.argsCount() < static_cast<std::size_t>( m_minArgs );
|
||||||
}
|
}
|
||||||
bool tooManyArgs( const Command& args ) const {
|
bool tooManyArgs( Command const& args ) const {
|
||||||
return m_maxArgs >= 0 && args.argsCount() > static_cast<std::size_t>( m_maxArgs );
|
return m_maxArgs >= 0 && args.argsCount() > static_cast<std::size_t>( m_maxArgs );
|
||||||
}
|
}
|
||||||
std::vector<std::string> m_optionNames;
|
std::vector<std::string> m_optionNames;
|
||||||
@ -201,7 +201,7 @@ namespace Catch {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command&, ConfigData& ) {
|
virtual void parseIntoConfig( Command const&, ConfigData& ) {
|
||||||
// Does not affect config
|
// Does not affect config
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -254,7 +254,7 @@ namespace Catch {
|
|||||||
"that start with 'a/b/', except 'a/b/c', which is included";
|
"that start with 'a/b/', except 'a/b/c', which is included";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
std::string groupName;
|
std::string groupName;
|
||||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
||||||
if( i != 0 )
|
if( i != 0 )
|
||||||
@ -300,7 +300,7 @@ namespace Catch {
|
|||||||
"matches all tests tagged [one], except those also tagged [two]";
|
"matches all tests tagged [one], except those also tagged [two]";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
std::string groupName;
|
std::string groupName;
|
||||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
||||||
if( i != 0 )
|
if( i != 0 )
|
||||||
@ -345,7 +345,7 @@ namespace Catch {
|
|||||||
;//" -l xml";
|
;//" -l xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
config.listSpec = List::Tests;
|
config.listSpec = List::Tests;
|
||||||
if( cmd.argsCount() >= 1 ) {
|
if( cmd.argsCount() >= 1 ) {
|
||||||
if( cmd[0] == "all" )
|
if( cmd[0] == "all" )
|
||||||
@ -404,7 +404,7 @@ namespace Catch {
|
|||||||
"of the root node.";
|
"of the root node.";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
config.reporter = cmd[0];
|
config.reporter = cmd[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -438,7 +438,7 @@ namespace Catch {
|
|||||||
" -o %debug \t(The IDE's debug output window - currently only Windows' "
|
" -o %debug \t(The IDE's debug output window - currently only Windows' "
|
||||||
"OutputDebugString is supported).";
|
"OutputDebugString is supported).";
|
||||||
}
|
}
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
if( cmd[0][0] == '%' )
|
if( cmd[0][0] == '%' )
|
||||||
config.stream = cmd[0].substr( 1 );
|
config.stream = cmd[0].substr( 1 );
|
||||||
else
|
else
|
||||||
@ -465,7 +465,7 @@ namespace Catch {
|
|||||||
"added worked first time!). To see successful, as well as failing, test results "
|
"added worked first time!). To see successful, as well as failing, test results "
|
||||||
"just pass this option.";
|
"just pass this option.";
|
||||||
}
|
}
|
||||||
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const&, ConfigData& config ) {
|
||||||
config.includeWhichResults = Include::SuccessfulResults;
|
config.includeWhichResults = Include::SuccessfulResults;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -491,7 +491,7 @@ namespace Catch {
|
|||||||
"built your code with the DEBUG preprocessor symbol";
|
"built your code with the DEBUG preprocessor symbol";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const&, ConfigData& config ) {
|
||||||
config.shouldDebugBreak = true;
|
config.shouldDebugBreak = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -521,7 +521,7 @@ namespace Catch {
|
|||||||
" -n \"tests of the widget component\"";
|
" -n \"tests of the widget component\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
config.name = cmd[0];
|
config.name = cmd[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -550,7 +550,7 @@ namespace Catch {
|
|||||||
"number causes it to abort after that number of assertion failures.";
|
"number causes it to abort after that number of assertion failures.";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
int threshold = 1;
|
int threshold = 1;
|
||||||
if( cmd.argsCount() == 1 ) {
|
if( cmd.argsCount() == 1 ) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@ -589,7 +589,7 @@ namespace Catch {
|
|||||||
"as not to contribute additional noise.";
|
"as not to contribute additional noise.";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const&, ConfigData& config ) {
|
||||||
config.allowThrows = false;
|
config.allowThrows = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -620,7 +620,7 @@ namespace Catch {
|
|||||||
" -w NoAssertions";
|
" -w NoAssertions";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
||||||
if( cmd[i] == "NoAssertions" )
|
if( cmd[i] == "NoAssertions" )
|
||||||
config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions );
|
config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions );
|
||||||
@ -655,7 +655,7 @@ namespace Catch {
|
|||||||
add<Options::HelpOptionParser>(); // Keep this one last
|
add<Options::HelpOptionParser>(); // Keep this one last
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
|
void parseIntoConfig( CommandParser const& parser, ConfigData& config ) {
|
||||||
config.name = parser.exeName();
|
config.name = parser.exeName();
|
||||||
if( endsWith( config.name, ".exe" ) )
|
if( endsWith( config.name, ".exe" ) )
|
||||||
config.name = config.name.substr( 0, config.name.size()-4 );
|
config.name = config.name.substr( 0, config.name.size()-4 );
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class NonCopyable {
|
class NonCopyable {
|
||||||
NonCopyable( const NonCopyable& );
|
NonCopyable( NonCopyable const& );
|
||||||
void operator = ( const NonCopyable& );
|
void operator = ( NonCopyable const& );
|
||||||
protected:
|
protected:
|
||||||
NonCopyable() {}
|
NonCopyable() {}
|
||||||
virtual ~NonCopyable();
|
virtual ~NonCopyable();
|
||||||
@ -67,17 +67,17 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ContainerT, typename Function>
|
template<typename ContainerT, typename Function>
|
||||||
inline void forEach( const ContainerT& container, Function function ) {
|
inline void forEach( ContainerT const& container, Function function ) {
|
||||||
std::for_each( container.begin(), container.end(), function );
|
std::for_each( container.begin(), container.end(), function );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool startsWith( const std::string& s, const std::string& prefix ) {
|
inline bool startsWith( std::string const& s, std::string const& prefix ) {
|
||||||
return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
|
return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
|
||||||
}
|
}
|
||||||
inline bool endsWith( const std::string& s, const std::string& suffix ) {
|
inline bool endsWith( std::string const& s, std::string const& suffix ) {
|
||||||
return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
|
return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
|
||||||
}
|
}
|
||||||
inline bool contains( const std::string& s, const std::string& infix ) {
|
inline bool contains( std::string const& s, std::string const& infix ) {
|
||||||
return s.find( infix ) != std::string::npos;
|
return s.find( infix ) != std::string::npos;
|
||||||
}
|
}
|
||||||
inline void toLowerInPlace( std::string& s ) {
|
inline void toLowerInPlace( std::string& s ) {
|
||||||
@ -90,12 +90,12 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct pluralise {
|
struct pluralise {
|
||||||
pluralise( std::size_t count, const std::string& label )
|
pluralise( std::size_t count, std::string const& label )
|
||||||
: m_count( count ),
|
: m_count( count ),
|
||||||
m_label( label )
|
m_label( label )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend std::ostream& operator << ( std::ostream& os, const pluralise& pluraliser ) {
|
friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
|
||||||
os << pluraliser.m_count << " " << pluraliser.m_label;
|
os << pluraliser.m_count << " " << pluraliser.m_label;
|
||||||
if( pluraliser.m_count != 1 )
|
if( pluraliser.m_count != 1 )
|
||||||
os << "s";
|
os << "s";
|
||||||
@ -109,11 +109,11 @@ namespace Catch {
|
|||||||
struct SourceLineInfo {
|
struct SourceLineInfo {
|
||||||
|
|
||||||
SourceLineInfo() : line( 0 ){}
|
SourceLineInfo() : line( 0 ){}
|
||||||
SourceLineInfo( const std::string& _file, std::size_t _line )
|
SourceLineInfo( std::string const& _file, std::size_t _line )
|
||||||
: file( _file ),
|
: file( _file ),
|
||||||
line( _line )
|
line( _line )
|
||||||
{}
|
{}
|
||||||
SourceLineInfo( const SourceLineInfo& other )
|
SourceLineInfo( SourceLineInfo const& other )
|
||||||
: file( other.file ),
|
: file( other.file ),
|
||||||
line( other.line )
|
line( other.line )
|
||||||
{}
|
{}
|
||||||
@ -125,7 +125,7 @@ namespace Catch {
|
|||||||
std::size_t line;
|
std::size_t line;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator << ( std::ostream& os, const SourceLineInfo& info ) {
|
inline std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
||||||
#ifndef __GNUG__
|
#ifndef __GNUG__
|
||||||
os << info.file << "(" << info.line << ")";
|
os << info.file << "(" << info.line << ")";
|
||||||
#else
|
#else
|
||||||
@ -135,7 +135,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CATCH_ATTRIBUTE_NORETURN
|
CATCH_ATTRIBUTE_NORETURN
|
||||||
inline void throwLogicError( const std::string& message, const SourceLineInfo& locationInfo ) {
|
inline void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << locationInfo << ": Internal Catch error: '" << message << "'";
|
oss << locationInfo << ": Internal Catch error: '" << message << "'";
|
||||||
throw std::logic_error( oss.str() );
|
throw std::logic_error( oss.str() );
|
||||||
|
@ -77,8 +77,8 @@ namespace Catch {
|
|||||||
|
|
||||||
class Config : public IConfig {
|
class Config : public IConfig {
|
||||||
private:
|
private:
|
||||||
Config( const Config& other );
|
Config( Config const& other );
|
||||||
Config& operator = ( const Config& other );
|
Config& operator = ( Config const& other );
|
||||||
virtual void dummy();
|
virtual void dummy();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace Catch {
|
|||||||
: m_os( std::cout.rdbuf() )
|
: m_os( std::cout.rdbuf() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Config( const ConfigData& data )
|
Config( ConfigData const& data )
|
||||||
: m_data( data ),
|
: m_data( data ),
|
||||||
m_os( std::cout.rdbuf() )
|
m_os( std::cout.rdbuf() )
|
||||||
{}
|
{}
|
||||||
@ -96,7 +96,7 @@ namespace Catch {
|
|||||||
m_stream.release();
|
m_stream.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFilename( const std::string& filename ) {
|
void setFilename( std::string const& filename ) {
|
||||||
m_data.outputFilename = filename;
|
m_data.outputFilename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ namespace Catch {
|
|||||||
return m_data.listSpec;
|
return m_data.listSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& getFilename() const {
|
std::string const& getFilename() const {
|
||||||
return m_data.outputFilename ;
|
return m_data.outputFilename ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,14 +132,14 @@ namespace Catch {
|
|||||||
m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
|
m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void useStream( const std::string& streamName ) {
|
void useStream( std::string const& streamName ) {
|
||||||
Stream stream = createStream( streamName );
|
Stream stream = createStream( streamName );
|
||||||
setStreamBuf( stream.streamBuf );
|
setStreamBuf( stream.streamBuf );
|
||||||
m_stream.release();
|
m_stream.release();
|
||||||
m_stream = stream;
|
m_stream = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTestSpec( const std::string& testSpec ) {
|
void addTestSpec( std::string const& testSpec ) {
|
||||||
TestCaseFilters filters( testSpec );
|
TestCaseFilters filters( testSpec );
|
||||||
filters.addFilter( TestCaseFilter( testSpec ) );
|
filters.addFilter( TestCaseFilter( testSpec ) );
|
||||||
m_data.filters.push_back( filters );
|
m_data.filters.push_back( filters );
|
||||||
@ -157,7 +157,7 @@ namespace Catch {
|
|||||||
return m_data.allowThrows;
|
return m_data.allowThrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConfigData& data() const {
|
ConfigData const& data() const {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
ConfigData& data() {
|
ConfigData& data() {
|
||||||
|
@ -29,7 +29,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual IResultCapture& getResultCapture() = 0;
|
virtual IResultCapture& getResultCapture() = 0;
|
||||||
virtual IRunner& getRunner() = 0;
|
virtual IRunner& getRunner() = 0;
|
||||||
virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) = 0;
|
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
|
||||||
virtual bool advanceGeneratorsForCurrentTest() = 0;
|
virtual bool advanceGeneratorsForCurrentTest() = 0;
|
||||||
virtual const IConfig* getConfig() const = 0;
|
virtual const IConfig* getConfig() const = 0;
|
||||||
};
|
};
|
||||||
@ -45,7 +45,7 @@ namespace Catch {
|
|||||||
IContext& getCurrentContext();
|
IContext& getCurrentContext();
|
||||||
IMutableContext& getCurrentMutableContext();
|
IMutableContext& getCurrentMutableContext();
|
||||||
void cleanUpContext();
|
void cleanUpContext();
|
||||||
Stream createStream( const std::string& streamName );
|
Stream createStream( std::string const& streamName );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ namespace Catch {
|
|||||||
class Context : public IMutableContext {
|
class Context : public IMutableContext {
|
||||||
|
|
||||||
Context() : m_config( NULL ) {}
|
Context() : m_config( NULL ) {}
|
||||||
Context( const Context& );
|
Context( Context const& );
|
||||||
void operator=( const Context& );
|
void operator=( Context const& );
|
||||||
|
|
||||||
public: // IContext
|
public: // IContext
|
||||||
virtual IResultCapture& getResultCapture() {
|
virtual IResultCapture& getResultCapture() {
|
||||||
@ -28,7 +28,7 @@ namespace Catch {
|
|||||||
virtual IRunner& getRunner() {
|
virtual IRunner& getRunner() {
|
||||||
return *m_runner;
|
return *m_runner;
|
||||||
}
|
}
|
||||||
virtual size_t getGeneratorIndex( const std::string& fileInfo, size_t totalSize ) {
|
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
|
||||||
return getGeneratorsForCurrentTest()
|
return getGeneratorsForCurrentTest()
|
||||||
.getGeneratorInfo( fileInfo, totalSize )
|
.getGeneratorInfo( fileInfo, totalSize )
|
||||||
.getCurrentIndex();
|
.getCurrentIndex();
|
||||||
@ -95,7 +95,7 @@ namespace Catch {
|
|||||||
return getCurrentMutableContext();
|
return getCurrentMutableContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream createStream( const std::string& streamName ) {
|
Stream createStream( std::string const& streamName ) {
|
||||||
if( streamName == "stdout" ) return Stream( std::cout.rdbuf(), false );
|
if( streamName == "stdout" ) return Stream( std::cout.rdbuf(), false );
|
||||||
if( streamName == "stderr" ) return Stream( std::cerr.rdbuf(), false );
|
if( streamName == "stderr" ) return Stream( std::cerr.rdbuf(), false );
|
||||||
if( streamName == "debug" ) return Stream( new StreamBufImpl<OutputDebugWriter>, true );
|
if( streamName == "debug" ) return Stream( new StreamBufImpl<OutputDebugWriter>, true );
|
||||||
|
@ -103,11 +103,11 @@
|
|||||||
|
|
||||||
#ifdef CATCH_PLATFORM_WINDOWS
|
#ifdef CATCH_PLATFORM_WINDOWS
|
||||||
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
|
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
|
||||||
inline void writeToDebugConsole( const std::string& text ) {
|
inline void writeToDebugConsole( std::string const& text ) {
|
||||||
::OutputDebugStringA( text.c_str() );
|
::OutputDebugStringA( text.c_str() );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline void writeToDebugConsole( const std::string& text ) {
|
inline void writeToDebugConsole( std::string const& text ) {
|
||||||
// !TBD: Need a version for Mac/ XCode and other IDEs
|
// !TBD: Need a version for Mac/ XCode and other IDEs
|
||||||
std::cout << text;
|
std::cout << text;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace Internal {
|
|||||||
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T& opCast(const T& t) { return const_cast<T&>(t); }
|
inline T& opCast(T const& t) { return const_cast<T&>(t); }
|
||||||
|
|
||||||
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
@ -49,43 +49,43 @@ namespace Internal {
|
|||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsEqualTo> {
|
struct Evaluator<T1, T2, IsEqualTo> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs) {
|
||||||
return opCast( lhs ) == opCast( rhs );
|
return opCast( lhs ) == opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsNotEqualTo> {
|
struct Evaluator<T1, T2, IsNotEqualTo> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs ) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs ) {
|
||||||
return opCast( lhs ) != opCast( rhs );
|
return opCast( lhs ) != opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsLessThan> {
|
struct Evaluator<T1, T2, IsLessThan> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs ) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs ) {
|
||||||
return opCast( lhs ) < opCast( rhs );
|
return opCast( lhs ) < opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsGreaterThan> {
|
struct Evaluator<T1, T2, IsGreaterThan> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs ) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs ) {
|
||||||
return opCast( lhs ) > opCast( rhs );
|
return opCast( lhs ) > opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
|
struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs ) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs ) {
|
||||||
return opCast( lhs ) >= opCast( rhs );
|
return opCast( lhs ) >= opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
|
struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
|
||||||
static bool evaluate( const T1& lhs, const T2& rhs ) {
|
static bool evaluate( T1 const& lhs, T2 const& rhs ) {
|
||||||
return opCast( lhs ) <= opCast( rhs );
|
return opCast( lhs ) <= opCast( rhs );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Operator Op, typename T1, typename T2>
|
template<Operator Op, typename T1, typename T2>
|
||||||
bool applyEvaluator( const T1& lhs, const T2& rhs ) {
|
bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
|
||||||
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ namespace Internal {
|
|||||||
|
|
||||||
// "base" overload
|
// "base" overload
|
||||||
template<Operator Op, typename T1, typename T2>
|
template<Operator Op, typename T1, typename T2>
|
||||||
bool compare( const T1& lhs, const T2& rhs ) {
|
bool compare( T1 const& lhs, T2 const& rhs ) {
|
||||||
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ class ExpressionDecomposer {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ExpressionLhs<const T&> operator->* ( const T & operand ) {
|
ExpressionLhs<T const&> operator->* ( T const& operand ) {
|
||||||
return ExpressionLhs<const T&>( operand );
|
return ExpressionLhs<T const&>( operand );
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionLhs<bool> operator->* ( bool value ) {
|
ExpressionLhs<bool> operator->* ( bool value ) {
|
||||||
|
@ -19,38 +19,38 @@ struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
|||||||
// in an ExpressionResultBuilder object
|
// in an ExpressionResultBuilder object
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ExpressionLhs {
|
class ExpressionLhs {
|
||||||
void operator = ( const ExpressionLhs& );
|
void operator = ( ExpressionLhs const& );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExpressionLhs( T lhs ) : m_lhs( lhs ) {}
|
ExpressionLhs( T lhs ) : m_lhs( lhs ) {}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator == ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator == ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsEqualTo>( rhs );
|
return captureExpression<Internal::IsEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator != ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator != ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
return captureExpression<Internal::IsNotEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator < ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator < ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsLessThan>( rhs );
|
return captureExpression<Internal::IsLessThan>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator > ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator > ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsGreaterThan>( rhs );
|
return captureExpression<Internal::IsGreaterThan>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator <= ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator <= ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
|
return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RhsT>
|
template<typename RhsT>
|
||||||
ExpressionResultBuilder& operator >= ( const RhsT& rhs ) {
|
ExpressionResultBuilder& operator >= ( RhsT const& rhs ) {
|
||||||
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
|
return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,14 +72,14 @@ public:
|
|||||||
|
|
||||||
// Only simple binary expressions are allowed on the LHS.
|
// Only simple binary expressions are allowed on the LHS.
|
||||||
// If more complex compositions are required then place the sub expression in parentheses
|
// If more complex compositions are required then place the sub expression in parentheses
|
||||||
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( const RhsT& );
|
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& );
|
||||||
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( const RhsT& );
|
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& );
|
||||||
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( const RhsT& );
|
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& );
|
||||||
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( const RhsT& );
|
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<Internal::Operator Op, typename RhsT>
|
template<Internal::Operator Op, typename RhsT>
|
||||||
ExpressionResultBuilder& captureExpression( const RhsT& rhs ) {
|
ExpressionResultBuilder& captureExpression( RhsT const& rhs ) {
|
||||||
return m_result
|
return m_result
|
||||||
.setResultType( Internal::compare<Op>( m_lhs, rhs ) )
|
.setResultType( Internal::compare<Op>( m_lhs, rhs ) )
|
||||||
.setLhs( Catch::toString( m_lhs ) )
|
.setLhs( Catch::toString( m_lhs ) )
|
||||||
|
@ -22,26 +22,26 @@ class ExpressionResultBuilder {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
||||||
ExpressionResultBuilder( const ExpressionResultBuilder& other );
|
ExpressionResultBuilder( ExpressionResultBuilder const& other );
|
||||||
ExpressionResultBuilder& operator=(const ExpressionResultBuilder& other );
|
ExpressionResultBuilder& operator=(ExpressionResultBuilder const& other );
|
||||||
|
|
||||||
ExpressionResultBuilder& setResultType( ResultWas::OfType result );
|
ExpressionResultBuilder& setResultType( ResultWas::OfType result );
|
||||||
ExpressionResultBuilder& setResultType( bool result );
|
ExpressionResultBuilder& setResultType( bool result );
|
||||||
ExpressionResultBuilder& setLhs( const std::string& lhs );
|
ExpressionResultBuilder& setLhs( std::string const& lhs );
|
||||||
ExpressionResultBuilder& setRhs( const std::string& rhs );
|
ExpressionResultBuilder& setRhs( std::string const& rhs );
|
||||||
ExpressionResultBuilder& setOp( const std::string& op );
|
ExpressionResultBuilder& setOp( std::string const& op );
|
||||||
|
|
||||||
ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
|
ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ExpressionResultBuilder& operator << ( const T& value ) {
|
ExpressionResultBuilder& operator << ( T const& value ) {
|
||||||
m_stream << value;
|
m_stream << value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string reconstructExpression( const AssertionInfo& info ) const;
|
std::string reconstructExpression( AssertionInfo const& info ) const;
|
||||||
|
|
||||||
AssertionResult buildResult( const AssertionInfo& info ) const;
|
AssertionResult buildResult( AssertionInfo const& info ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AssertionResultData m_data;
|
AssertionResultData m_data;
|
||||||
|
@ -17,13 +17,13 @@ namespace Catch {
|
|||||||
ExpressionResultBuilder::ExpressionResultBuilder( ResultWas::OfType resultType ) {
|
ExpressionResultBuilder::ExpressionResultBuilder( ResultWas::OfType resultType ) {
|
||||||
m_data.resultType = resultType;
|
m_data.resultType = resultType;
|
||||||
}
|
}
|
||||||
ExpressionResultBuilder::ExpressionResultBuilder( const ExpressionResultBuilder& other )
|
ExpressionResultBuilder::ExpressionResultBuilder( ExpressionResultBuilder const& other )
|
||||||
: m_data( other.m_data ),
|
: m_data( other.m_data ),
|
||||||
m_exprComponents( other.m_exprComponents )
|
m_exprComponents( other.m_exprComponents )
|
||||||
{
|
{
|
||||||
m_stream << other.m_stream.str();
|
m_stream << other.m_stream.str();
|
||||||
}
|
}
|
||||||
ExpressionResultBuilder& ExpressionResultBuilder::operator=(const ExpressionResultBuilder& other ) {
|
ExpressionResultBuilder& ExpressionResultBuilder::operator=(ExpressionResultBuilder const& other ) {
|
||||||
m_data = other.m_data;
|
m_data = other.m_data;
|
||||||
m_exprComponents = other.m_exprComponents;
|
m_exprComponents = other.m_exprComponents;
|
||||||
m_stream.str("");
|
m_stream.str("");
|
||||||
@ -42,19 +42,19 @@ namespace Catch {
|
|||||||
m_exprComponents.shouldNegate = shouldNegate( resultDisposition );
|
m_exprComponents.shouldNegate = shouldNegate( resultDisposition );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ExpressionResultBuilder& ExpressionResultBuilder::setLhs( const std::string& lhs ) {
|
ExpressionResultBuilder& ExpressionResultBuilder::setLhs( std::string const& lhs ) {
|
||||||
m_exprComponents.lhs = lhs;
|
m_exprComponents.lhs = lhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ExpressionResultBuilder& ExpressionResultBuilder::setRhs( const std::string& rhs ) {
|
ExpressionResultBuilder& ExpressionResultBuilder::setRhs( std::string const& rhs ) {
|
||||||
m_exprComponents.rhs = rhs;
|
m_exprComponents.rhs = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ExpressionResultBuilder& ExpressionResultBuilder::setOp( const std::string& op ) {
|
ExpressionResultBuilder& ExpressionResultBuilder::setOp( std::string const& op ) {
|
||||||
m_exprComponents.op = op;
|
m_exprComponents.op = op;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
AssertionResult ExpressionResultBuilder::buildResult( const AssertionInfo& info ) const
|
AssertionResult ExpressionResultBuilder::buildResult( AssertionInfo const& info ) const
|
||||||
{
|
{
|
||||||
assert( m_data.resultType != ResultWas::Unknown );
|
assert( m_data.resultType != ResultWas::Unknown );
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
return AssertionResult( info, data );
|
return AssertionResult( info, data );
|
||||||
}
|
}
|
||||||
std::string ExpressionResultBuilder::reconstructExpression( const AssertionInfo& info ) const {
|
std::string ExpressionResultBuilder::reconstructExpression( AssertionInfo const& info ) const {
|
||||||
if( m_exprComponents.op == "" )
|
if( m_exprComponents.op == "" )
|
||||||
return m_exprComponents.lhs.empty() ? info.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
|
return m_exprComponents.lhs.empty() ? info.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
|
||||||
else if( m_exprComponents.op == "matches" )
|
else if( m_exprComponents.op == "matches" )
|
||||||
|
@ -50,7 +50,7 @@ namespace Catch {
|
|||||||
deleteAll( m_generatorsInOrder );
|
deleteAll( m_generatorsInOrder );
|
||||||
}
|
}
|
||||||
|
|
||||||
IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) {
|
IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) {
|
||||||
std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
|
std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
|
||||||
if( it == m_generatorsByName.end() ) {
|
if( it == m_generatorsByName.end() ) {
|
||||||
IGeneratorInfo* info = new GeneratorInfo( size );
|
IGeneratorInfo* info = new GeneratorInfo( size );
|
||||||
|
@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual bool shouldDebugBreak() const = 0;
|
virtual bool shouldDebugBreak() const = 0;
|
||||||
|
|
||||||
virtual void acceptMessage( const MessageBuilder& messageBuilder ) = 0;
|
virtual void acceptMessage( MessageBuilder const& messageBuilder ) = 0;
|
||||||
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0;
|
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const = 0;
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
|
@ -21,7 +21,7 @@ namespace Catch {
|
|||||||
struct IGeneratorsForTest {
|
struct IGeneratorsForTest {
|
||||||
virtual ~IGeneratorsForTest();
|
virtual ~IGeneratorsForTest();
|
||||||
|
|
||||||
virtual IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) = 0;
|
virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
|
||||||
virtual bool moveNext() = 0;
|
virtual bool moveNext() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,15 +23,15 @@ namespace Catch {
|
|||||||
struct IRegistryHub {
|
struct IRegistryHub {
|
||||||
virtual ~IRegistryHub();
|
virtual ~IRegistryHub();
|
||||||
|
|
||||||
virtual const IReporterRegistry& getReporterRegistry() const = 0;
|
virtual IReporterRegistry const& getReporterRegistry() const = 0;
|
||||||
virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0;
|
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
|
||||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
|
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IMutableRegistryHub {
|
struct IMutableRegistryHub {
|
||||||
virtual ~IMutableRegistryHub();
|
virtual ~IMutableRegistryHub();
|
||||||
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0;
|
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0;
|
||||||
virtual void registerTest( const TestCase& testInfo ) = 0;
|
virtual void registerTest( TestCase const& testInfo ) = 0;
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -303,11 +303,11 @@ namespace Catch
|
|||||||
virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0;
|
virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0;
|
||||||
virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0;
|
virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0;
|
||||||
virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0;
|
virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0;
|
||||||
virtual void EndSection( std::string const& sectionName, const Counts& assertions ) = 0;
|
virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0;
|
||||||
virtual void NoAssertionsInSection( std::string const& sectionName ) = 0;
|
virtual void NoAssertionsInSection( std::string const& sectionName ) = 0;
|
||||||
virtual void NoAssertionsInTestCase( std::string const& testName ) = 0;
|
virtual void NoAssertionsInTestCase( std::string const& testName ) = 0;
|
||||||
virtual void Aborted() = 0;
|
virtual void Aborted() = 0;
|
||||||
virtual void Result( const AssertionResult& result ) = 0;
|
virtual void Result( AssertionResult const& result ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ namespace Catch
|
|||||||
|
|
||||||
virtual ~IReporterRegistry();
|
virtual ~IReporterRegistry();
|
||||||
virtual IStreamingReporter* create( std::string const& name, ReporterConfig const& config ) const = 0;
|
virtual IStreamingReporter* create( std::string const& name, ReporterConfig const& config ) const = 0;
|
||||||
virtual const FactoryMap& getFactories() const = 0;
|
virtual FactoryMap const& getFactories() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::string trim( std::string const& str ) {
|
inline std::string trim( std::string const& str ) {
|
||||||
|
@ -26,8 +26,8 @@ namespace Catch {
|
|||||||
|
|
||||||
struct ITestCaseRegistry {
|
struct ITestCaseRegistry {
|
||||||
virtual ~ITestCaseRegistry();
|
virtual ~ITestCaseRegistry();
|
||||||
virtual const std::vector<TestCase>& getAllTests() const = 0;
|
virtual std::vector<TestCase> const& getAllTests() const = 0;
|
||||||
virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const = 0;
|
virtual std::vector<TestCase> getMatchingTestCases( std::string const& rawTestSpec ) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
inline bool matchesFilters( const std::vector<TestCaseFilters>& filters, const TestCase& testCase ) {
|
inline bool matchesFilters( std::vector<TestCaseFilters> const& filters, TestCase const& testCase ) {
|
||||||
std::vector<TestCaseFilters>::const_iterator it = filters.begin();
|
std::vector<TestCaseFilters>::const_iterator it = filters.begin();
|
||||||
std::vector<TestCaseFilters>::const_iterator itEnd = filters.end();
|
std::vector<TestCaseFilters>::const_iterator itEnd = filters.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
@ -25,7 +25,7 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void listTests( const ConfigData& config ) {
|
inline void listTests( ConfigData const& config ) {
|
||||||
if( config.filters.empty() )
|
if( config.filters.empty() )
|
||||||
std::cout << "All available test cases:\n";
|
std::cout << "All available test cases:\n";
|
||||||
else
|
else
|
||||||
@ -100,7 +100,7 @@ namespace Catch {
|
|||||||
std::cout << pluralise( matchedTests, "matching test case" ) << std::endl;
|
std::cout << pluralise( matchedTests, "matching test case" ) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void listTags( const ConfigData& config ) {
|
inline void listTags( ConfigData const& config ) {
|
||||||
if( config.filters.empty() )
|
if( config.filters.empty() )
|
||||||
std::cout << "All available tags:\n";
|
std::cout << "All available tags:\n";
|
||||||
else
|
else
|
||||||
@ -152,7 +152,7 @@ namespace Catch {
|
|||||||
std::cout << pluralise( tagCounts.size(), "tag" ) << std::endl;
|
std::cout << pluralise( tagCounts.size(), "tag" ) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void listReporters( const ConfigData& /*config*/ ) {
|
inline void listReporters( ConfigData const& /*config*/ ) {
|
||||||
std::cout << "Available reports:\n";
|
std::cout << "Available reports:\n";
|
||||||
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
|
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
|
||||||
IReporterRegistry::FactoryMap::const_iterator it = factories.begin(), itEnd = factories.end();
|
IReporterRegistry::FactoryMap::const_iterator it = factories.begin(), itEnd = factories.end();
|
||||||
@ -163,7 +163,7 @@ namespace Catch {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void list( const ConfigData& config ) {
|
inline void list( ConfigData const& config ) {
|
||||||
if( config.listSpec & List::Tests )
|
if( config.listSpec & List::Tests )
|
||||||
listTests( config );
|
listTests( config );
|
||||||
if( config.listSpec & List::Tags )
|
if( config.listSpec & List::Tags )
|
||||||
|
@ -27,7 +27,7 @@ namespace Matchers {
|
|||||||
struct MatcherImpl : Matcher<ExpressionT> {
|
struct MatcherImpl : Matcher<ExpressionT> {
|
||||||
|
|
||||||
virtual Ptr<Matcher<ExpressionT> > clone() const {
|
virtual Ptr<Matcher<ExpressionT> > clone() const {
|
||||||
return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<const DerivedT&>( *this ) ) );
|
return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<DerivedT const&>( *this ) ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ namespace Matchers {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
AllOf() {}
|
AllOf() {}
|
||||||
AllOf( const AllOf& other ) : m_matchers( other.m_matchers ) {}
|
AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
|
||||||
|
|
||||||
AllOf& add( const Matcher<ExpressionT>& matcher ) {
|
AllOf& add( Matcher<ExpressionT> const& matcher ) {
|
||||||
m_matchers.push_back( matcher.clone() );
|
m_matchers.push_back( matcher.clone() );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
virtual bool match( const ExpressionT& expr ) const
|
virtual bool match( ExpressionT const& expr ) const
|
||||||
{
|
{
|
||||||
for( std::size_t i = 0; i < m_matchers.size(); ++i )
|
for( std::size_t i = 0; i < m_matchers.size(); ++i )
|
||||||
if( !m_matchers[i]->match( expr ) )
|
if( !m_matchers[i]->match( expr ) )
|
||||||
@ -72,13 +72,13 @@ namespace Matchers {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
AnyOf() {}
|
AnyOf() {}
|
||||||
AnyOf( const AnyOf& other ) : m_matchers( other.m_matchers ) {}
|
AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
|
||||||
|
|
||||||
AnyOf& add( const Matcher<ExpressionT>& matcher ) {
|
AnyOf& add( Matcher<ExpressionT> const& matcher ) {
|
||||||
m_matchers.push_back( matcher.clone() );
|
m_matchers.push_back( matcher.clone() );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
virtual bool match( const ExpressionT& expr ) const
|
virtual bool match( ExpressionT const& expr ) const
|
||||||
{
|
{
|
||||||
for( std::size_t i = 0; i < m_matchers.size(); ++i )
|
for( std::size_t i = 0; i < m_matchers.size(); ++i )
|
||||||
if( m_matchers[i]->match( expr ) )
|
if( m_matchers[i]->match( expr ) )
|
||||||
@ -105,16 +105,16 @@ namespace Matchers {
|
|||||||
|
|
||||||
namespace StdString {
|
namespace StdString {
|
||||||
|
|
||||||
inline std::string makeString( const std::string& str ) { return str; }
|
inline std::string makeString( std::string const& str ) { return str; }
|
||||||
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
|
inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
|
||||||
|
|
||||||
struct Equals : MatcherImpl<Equals, std::string> {
|
struct Equals : MatcherImpl<Equals, std::string> {
|
||||||
Equals( const std::string& str ) : m_str( str ){}
|
Equals( std::string const& str ) : m_str( str ){}
|
||||||
Equals( const Equals& other ) : m_str( other.m_str ){}
|
Equals( Equals const& other ) : m_str( other.m_str ){}
|
||||||
|
|
||||||
virtual ~Equals();
|
virtual ~Equals();
|
||||||
|
|
||||||
virtual bool match( const std::string& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return m_str == expr;
|
return m_str == expr;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
@ -125,12 +125,12 @@ namespace Matchers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Contains : MatcherImpl<Contains, std::string> {
|
struct Contains : MatcherImpl<Contains, std::string> {
|
||||||
Contains( const std::string& substr ) : m_substr( substr ){}
|
Contains( std::string const& substr ) : m_substr( substr ){}
|
||||||
Contains( const Contains& other ) : m_substr( other.m_substr ){}
|
Contains( Contains const& other ) : m_substr( other.m_substr ){}
|
||||||
|
|
||||||
virtual ~Contains();
|
virtual ~Contains();
|
||||||
|
|
||||||
virtual bool match( const std::string& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) != std::string::npos;
|
return expr.find( m_substr ) != std::string::npos;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
@ -141,12 +141,12 @@ namespace Matchers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
struct StartsWith : MatcherImpl<StartsWith, std::string> {
|
||||||
StartsWith( const std::string& substr ) : m_substr( substr ){}
|
StartsWith( std::string const& substr ) : m_substr( substr ){}
|
||||||
StartsWith( const StartsWith& other ) : m_substr( other.m_substr ){}
|
StartsWith( StartsWith const& other ) : m_substr( other.m_substr ){}
|
||||||
|
|
||||||
virtual ~StartsWith();
|
virtual ~StartsWith();
|
||||||
|
|
||||||
virtual bool match( const std::string& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) == 0;
|
return expr.find( m_substr ) == 0;
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
@ -157,12 +157,12 @@ namespace Matchers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct EndsWith : MatcherImpl<EndsWith, std::string> {
|
struct EndsWith : MatcherImpl<EndsWith, std::string> {
|
||||||
EndsWith( const std::string& substr ) : m_substr( substr ){}
|
EndsWith( std::string const& substr ) : m_substr( substr ){}
|
||||||
EndsWith( const EndsWith& other ) : m_substr( other.m_substr ){}
|
EndsWith( EndsWith const& other ) : m_substr( other.m_substr ){}
|
||||||
|
|
||||||
virtual ~EndsWith();
|
virtual ~EndsWith();
|
||||||
|
|
||||||
virtual bool match( const std::string& expr ) const {
|
virtual bool match( std::string const& expr ) const {
|
||||||
return expr.find( m_substr ) == expr.size() - m_substr.size();
|
return expr.find( m_substr ) == expr.size() - m_substr.size();
|
||||||
}
|
}
|
||||||
virtual std::string toString() const {
|
virtual std::string toString() const {
|
||||||
@ -177,47 +177,47 @@ namespace Matchers {
|
|||||||
// The following functions create the actual matcher objects.
|
// The following functions create the actual matcher objects.
|
||||||
// This allows the types to be inferred
|
// This allows the types to be inferred
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
inline Impl::Generic::AllOf<ExpressionT> AllOf( const Impl::Matcher<ExpressionT>& m1,
|
inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
|
||||||
const Impl::Matcher<ExpressionT>& m2 ) {
|
Impl::Matcher<ExpressionT> const& m2 ) {
|
||||||
return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
|
return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
|
||||||
}
|
}
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
inline Impl::Generic::AllOf<ExpressionT> AllOf( const Impl::Matcher<ExpressionT>& m1,
|
inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
|
||||||
const Impl::Matcher<ExpressionT>& m2,
|
Impl::Matcher<ExpressionT> const& m2,
|
||||||
const Impl::Matcher<ExpressionT>& m3 ) {
|
Impl::Matcher<ExpressionT> const& m3 ) {
|
||||||
return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
||||||
}
|
}
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
inline Impl::Generic::AnyOf<ExpressionT> AnyOf( const Impl::Matcher<ExpressionT>& m1,
|
inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
|
||||||
const Impl::Matcher<ExpressionT>& m2 ) {
|
Impl::Matcher<ExpressionT> const& m2 ) {
|
||||||
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
|
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
|
||||||
}
|
}
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
inline Impl::Generic::AnyOf<ExpressionT> AnyOf( const Impl::Matcher<ExpressionT>& m1,
|
inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
|
||||||
const Impl::Matcher<ExpressionT>& m2,
|
Impl::Matcher<ExpressionT> const& m2,
|
||||||
const Impl::Matcher<ExpressionT>& m3 ) {
|
Impl::Matcher<ExpressionT> const& m3 ) {
|
||||||
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Impl::StdString::Equals Equals( const std::string& str ) {
|
inline Impl::StdString::Equals Equals( std::string const& str ) {
|
||||||
return Impl::StdString::Equals( str );
|
return Impl::StdString::Equals( str );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Equals Equals( const char* str ) {
|
inline Impl::StdString::Equals Equals( const char* str ) {
|
||||||
return Impl::StdString::Equals( Impl::StdString::makeString( str ) );
|
return Impl::StdString::Equals( Impl::StdString::makeString( str ) );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Contains Contains( const std::string& substr ) {
|
inline Impl::StdString::Contains Contains( std::string const& substr ) {
|
||||||
return Impl::StdString::Contains( substr );
|
return Impl::StdString::Contains( substr );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::Contains Contains( const char* substr ) {
|
inline Impl::StdString::Contains Contains( const char* substr ) {
|
||||||
return Impl::StdString::Contains( Impl::StdString::makeString( substr ) );
|
return Impl::StdString::Contains( Impl::StdString::makeString( substr ) );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::StartsWith StartsWith( const std::string& substr ) {
|
inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
|
||||||
return Impl::StdString::StartsWith( substr );
|
return Impl::StdString::StartsWith( substr );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
|
inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
|
||||||
return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
|
return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::EndsWith EndsWith( const std::string& substr ) {
|
inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) {
|
||||||
return Impl::StdString::EndsWith( substr );
|
return Impl::StdString::EndsWith( substr );
|
||||||
}
|
}
|
||||||
inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
|
inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
|
||||||
|
@ -16,7 +16,7 @@ namespace Catch {
|
|||||||
class NotImplementedException : public std::exception
|
class NotImplementedException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotImplementedException( const SourceLineInfo& lineInfo );
|
NotImplementedException( SourceLineInfo const& lineInfo );
|
||||||
|
|
||||||
virtual ~NotImplementedException() throw() {}
|
virtual ~NotImplementedException() throw() {}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
NotImplementedException::NotImplementedException( const SourceLineInfo& lineInfo )
|
NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo )
|
||||||
: m_lineInfo( lineInfo ) {
|
: m_lineInfo( lineInfo ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << lineInfo << ": function ";
|
oss << lineInfo << ": function ";
|
||||||
|
@ -56,13 +56,13 @@ namespace Catch {
|
|||||||
|
|
||||||
namespace Detail{
|
namespace Detail{
|
||||||
|
|
||||||
inline bool startsWith( const std::string& str, const std::string& sub ) {
|
inline bool startsWith( std::string const& str, std::string const& sub ) {
|
||||||
return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub;
|
return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string getAnnotation( Class cls,
|
inline std::string getAnnotation( Class cls,
|
||||||
const std::string& annotationName,
|
std::string const& annotationName,
|
||||||
const std::string& testCaseName ) {
|
std::string const& testCaseName ) {
|
||||||
NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
|
NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
|
||||||
SEL sel = NSSelectorFromString( selStr );
|
SEL sel = NSSelectorFromString( selStr );
|
||||||
arcSafeRelease( selStr );
|
arcSafeRelease( selStr );
|
||||||
|
@ -41,7 +41,7 @@ namespace Catch {
|
|||||||
nullableValue = NULL;
|
nullableValue = NULL;
|
||||||
}
|
}
|
||||||
T& operator*() { return *nullableValue; }
|
T& operator*() { return *nullableValue; }
|
||||||
const T& operator*() const { return *nullableValue; }
|
T const& operator*() const { return *nullableValue; }
|
||||||
T* operator->() { return nullableValue; }
|
T* operator->() { return nullableValue; }
|
||||||
const T* operator->() const { return nullableValue; }
|
const T* operator->() const { return nullableValue; }
|
||||||
|
|
||||||
|
@ -20,16 +20,16 @@ namespace Catch {
|
|||||||
|
|
||||||
class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
|
class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
|
||||||
|
|
||||||
RegistryHub( const RegistryHub& );
|
RegistryHub( RegistryHub const& );
|
||||||
void operator=( const RegistryHub& );
|
void operator=( RegistryHub const& );
|
||||||
|
|
||||||
public: // IRegistryHub
|
public: // IRegistryHub
|
||||||
RegistryHub() {
|
RegistryHub() {
|
||||||
}
|
}
|
||||||
virtual const IReporterRegistry& getReporterRegistry() const {
|
virtual IReporterRegistry const& getReporterRegistry() const {
|
||||||
return m_reporterRegistry;
|
return m_reporterRegistry;
|
||||||
}
|
}
|
||||||
virtual const ITestCaseRegistry& getTestCaseRegistry() const {
|
virtual ITestCaseRegistry const& getTestCaseRegistry() const {
|
||||||
return m_testCaseRegistry;
|
return m_testCaseRegistry;
|
||||||
}
|
}
|
||||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
|
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
|
||||||
@ -37,10 +37,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public: // IMutableRegistryHub
|
public: // IMutableRegistryHub
|
||||||
virtual void registerReporter( const std::string& name, IReporterFactory* factory ) {
|
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
||||||
m_reporterRegistry.registerReporter( name, factory );
|
m_reporterRegistry.registerReporter( name, factory );
|
||||||
}
|
}
|
||||||
virtual void registerTest( const TestCase& testInfo ) {
|
virtual void registerTest( TestCase const& testInfo ) {
|
||||||
m_testCaseRegistry.registerTest( testInfo );
|
m_testCaseRegistry.registerTest( testInfo );
|
||||||
}
|
}
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) {
|
virtual void registerTranslator( const IExceptionTranslator* translator ) {
|
||||||
|
@ -18,7 +18,7 @@ namespace Catch {
|
|||||||
|
|
||||||
class ReporterFactory : public IReporterFactory {
|
class ReporterFactory : public IReporterFactory {
|
||||||
|
|
||||||
virtual IStreamingReporter* create( const ReporterConfig& config ) const {
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
return new LegacyReporterAdapter( new T( config ), config );
|
return new LegacyReporterAdapter( new T( config ), config );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LegacyReporterRegistrar( const std::string& name ) {
|
LegacyReporterRegistrar( std::string const& name ) {
|
||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -50,7 +50,7 @@ namespace Catch {
|
|||||||
// In fact, ideally, please contact me anyway to let me know you've hit this - as I have
|
// In fact, ideally, please contact me anyway to let me know you've hit this - as I have
|
||||||
// no idea who is actually using custom reporters at all (possibly no-one!).
|
// no idea who is actually using custom reporters at all (possibly no-one!).
|
||||||
// The new interface is designed to minimise exposure to interface changes in the future.
|
// The new interface is designed to minimise exposure to interface changes in the future.
|
||||||
virtual IStreamingReporter* create( const ReporterConfig& config ) const {
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
return new T( config );
|
return new T( config );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ReporterRegistrar( const std::string& name ) {
|
ReporterRegistrar( std::string const& name ) {
|
||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,18 +22,18 @@ namespace Catch {
|
|||||||
deleteAllValues( m_factories );
|
deleteAllValues( m_factories );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual IStreamingReporter* create( const std::string& name, const ReporterConfig& config ) const {
|
virtual IStreamingReporter* create( std::string const& name, ReporterConfig const& config ) const {
|
||||||
FactoryMap::const_iterator it = m_factories.find( name );
|
FactoryMap::const_iterator it = m_factories.find( name );
|
||||||
if( it == m_factories.end() )
|
if( it == m_factories.end() )
|
||||||
return NULL;
|
return NULL;
|
||||||
return it->second->create( config );
|
return it->second->create( config );
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerReporter( const std::string& name, IReporterFactory* factory ) {
|
void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
||||||
m_factories.insert( std::make_pair( name, factory ) );
|
m_factories.insert( std::make_pair( name, factory ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const FactoryMap& getFactories() const {
|
FactoryMap const& getFactories() const {
|
||||||
return m_factories;
|
return m_factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ namespace Catch {
|
|||||||
|
|
||||||
class Runner : public IResultCapture, public IRunner {
|
class Runner : public IResultCapture, public IRunner {
|
||||||
|
|
||||||
Runner( const Runner& );
|
Runner( Runner const& );
|
||||||
void operator =( const Runner& );
|
void operator =( Runner const& );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Runner( const Config& config, const Ptr<IStreamingReporter>& reporter )
|
explicit Runner( Config const& config, Ptr<IStreamingReporter> const& reporter )
|
||||||
: m_runInfo( config.data().name ),
|
: m_runInfo( config.data().name ),
|
||||||
m_context( getCurrentMutableContext() ),
|
m_context( getCurrentMutableContext() ),
|
||||||
m_runningTest( NULL ),
|
m_runningTest( NULL ),
|
||||||
@ -87,7 +87,7 @@ namespace Catch {
|
|||||||
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
|
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals runMatching( const std::string& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
Totals runMatching( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
||||||
|
|
||||||
std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ namespace Catch {
|
|||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals runTest( const TestCase& testCase ) {
|
Totals runTest( TestCase const& testCase ) {
|
||||||
Totals prevTotals = m_totals;
|
Totals prevTotals = m_totals;
|
||||||
|
|
||||||
std::string redirectedCout;
|
std::string redirectedCout;
|
||||||
@ -149,22 +149,22 @@ namespace Catch {
|
|||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Config& config() const {
|
Config const& config() const {
|
||||||
return m_config;
|
return m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private: // IResultCapture
|
private: // IResultCapture
|
||||||
|
|
||||||
virtual void acceptMessage( const MessageBuilder& messageBuilder ) {
|
virtual void acceptMessage( MessageBuilder const& messageBuilder ) {
|
||||||
m_messages.push_back( messageBuilder.build() );
|
m_messages.push_back( messageBuilder.build() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ResultAction::Value acceptExpression( const ExpressionResultBuilder& assertionResult, const AssertionInfo& assertionInfo ) {
|
virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) {
|
||||||
m_lastAssertionInfo = assertionInfo;
|
m_lastAssertionInfo = assertionInfo;
|
||||||
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
|
return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionEnded( const AssertionResult& result ) {
|
virtual void assertionEnded( AssertionResult const& result ) {
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok ) {
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ namespace Catch {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ResultAction::Value actOnCurrentResult( const AssertionResult& result ) {
|
ResultAction::Value actOnCurrentResult( AssertionResult const& result ) {
|
||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
assertionEnded( m_lastResult );
|
assertionEnded( m_lastResult );
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ namespace Catch {
|
|||||||
RunningTest* m_runningTest;
|
RunningTest* m_runningTest;
|
||||||
AssertionResult m_lastResult;
|
AssertionResult m_lastResult;
|
||||||
|
|
||||||
const Config& m_config;
|
Config const& m_config;
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
Ptr<IStreamingReporter> m_reporter;
|
Ptr<IStreamingReporter> m_reporter;
|
||||||
std::vector<MessageInfo> m_messages;
|
std::vector<MessageInfo> m_messages;
|
||||||
|
@ -24,7 +24,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RunningTest( const TestCase& info )
|
explicit RunningTest( TestCase const& info )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_runStatus( RanAtLeastOneSection ),
|
m_runStatus( RanAtLeastOneSection ),
|
||||||
m_rootSection( info.getTestCaseInfo().name ),
|
m_rootSection( info.getTestCaseInfo().name ),
|
||||||
@ -64,7 +64,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addSection( const std::string& name ) {
|
bool addSection( std::string const& name ) {
|
||||||
if( m_runStatus == NothingRun )
|
if( m_runStatus == NothingRun )
|
||||||
m_runStatus = EncounteredASection;
|
m_runStatus = EncounteredASection;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ namespace Catch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endSection( const std::string&, bool stealth ) {
|
void endSection( std::string const&, bool stealth ) {
|
||||||
if( m_currentSection->ran() ) {
|
if( m_currentSection->ran() ) {
|
||||||
if( !stealth )
|
if( !stealth )
|
||||||
m_runStatus = RanAtLeastOneSection;
|
m_runStatus = RanAtLeastOneSection;
|
||||||
@ -92,7 +92,7 @@ namespace Catch {
|
|||||||
m_currentSection = m_currentSection->getParent();
|
m_currentSection = m_currentSection->getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
const TestCase& getTestCase() const {
|
TestCase const& getTestCase() const {
|
||||||
return m_info;
|
return m_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ namespace Catch {
|
|||||||
RunningTest( RunningTest const& );
|
RunningTest( RunningTest const& );
|
||||||
void operator=( RunningTest const& );
|
void operator=( RunningTest const& );
|
||||||
|
|
||||||
const TestCase& m_info;
|
TestCase const& m_info;
|
||||||
RunStatus m_runStatus;
|
RunStatus m_runStatus;
|
||||||
RunningSection m_rootSection;
|
RunningSection m_rootSection;
|
||||||
RunningSection* m_currentSection;
|
RunningSection* m_currentSection;
|
||||||
|
@ -18,9 +18,9 @@ namespace Catch {
|
|||||||
|
|
||||||
class Section {
|
class Section {
|
||||||
public:
|
public:
|
||||||
Section( const SourceLineInfo& lineInfo,
|
Section( SourceLineInfo const& lineInfo,
|
||||||
const std::string& name,
|
std::string const& name,
|
||||||
const std::string& description = "" )
|
std::string const& description = "" )
|
||||||
: m_info( name, description, lineInfo ),
|
: m_info( name, description, lineInfo ),
|
||||||
m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) )
|
m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) )
|
||||||
{}
|
{}
|
||||||
|
@ -28,13 +28,13 @@ namespace Catch {
|
|||||||
TestedLeaf
|
TestedLeaf
|
||||||
};
|
};
|
||||||
|
|
||||||
RunningSection( RunningSection* parent, const std::string& name )
|
RunningSection( RunningSection* parent, std::string const& name )
|
||||||
: m_state( Unknown ),
|
: m_state( Unknown ),
|
||||||
m_parent( parent ),
|
m_parent( parent ),
|
||||||
m_name( name )
|
m_name( name )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RunningSection( const std::string& name )
|
RunningSection( std::string const& name )
|
||||||
: m_state( Root ),
|
: m_state( Root ),
|
||||||
m_parent( NULL ),
|
m_parent( NULL ),
|
||||||
m_name( name )
|
m_name( name )
|
||||||
@ -77,7 +77,7 @@ namespace Catch {
|
|||||||
return m_parent;
|
return m_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
RunningSection* findOrAddSubSection( const std::string& name, bool& changed ) {
|
RunningSection* findOrAddSubSection( std::string const& name, bool& changed ) {
|
||||||
for( SubSections::const_iterator it = m_subSections.begin();
|
for( SubSections::const_iterator it = m_subSections.begin();
|
||||||
it != m_subSections.end();
|
it != m_subSections.end();
|
||||||
++it)
|
++it)
|
||||||
|
@ -57,7 +57,7 @@ namespace Catch {
|
|||||||
|
|
||||||
struct OutputDebugWriter {
|
struct OutputDebugWriter {
|
||||||
|
|
||||||
void operator()( const std::string &str ) {
|
void operator()( std::string const&str ) {
|
||||||
writeToDebugConsole( str );
|
writeToDebugConsole( str );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
virtual ~TagParser();
|
virtual ~TagParser();
|
||||||
|
|
||||||
void parse( const std::string& str ) {
|
void parse( std::string const& str ) {
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
while( pos < str.size() ) {
|
while( pos < str.size() ) {
|
||||||
char c = str[pos];
|
char c = str[pos];
|
||||||
@ -48,7 +48,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void acceptTag( const std::string& tag ) = 0;
|
virtual void acceptTag( std::string const& tag ) = 0;
|
||||||
virtual void acceptChar( char c ) = 0;
|
virtual void acceptChar( char c ) = 0;
|
||||||
virtual void endParse() {}
|
virtual void endParse() {}
|
||||||
|
|
||||||
@ -69,14 +69,14 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void acceptTag( const std::string& tag ) {
|
virtual void acceptTag( std::string const& tag ) {
|
||||||
m_tags.insert( toLower( tag ) );
|
m_tags.insert( toLower( tag ) );
|
||||||
}
|
}
|
||||||
virtual void acceptChar( char c ) {
|
virtual void acceptChar( char c ) {
|
||||||
m_remainder += c;
|
m_remainder += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagExtracter& operator=(const TagExtracter&);
|
TagExtracter& operator=(TagExtracter const&);
|
||||||
|
|
||||||
std::set<std::string>& m_tags;
|
std::set<std::string>& m_tags;
|
||||||
std::string m_remainder;
|
std::string m_remainder;
|
||||||
@ -88,7 +88,7 @@ namespace Catch {
|
|||||||
: m_isNegated( false )
|
: m_isNegated( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Tag( const std::string& name, bool isNegated )
|
Tag( std::string const& name, bool isNegated )
|
||||||
: m_name( name ),
|
: m_name( name ),
|
||||||
m_isNegated( isNegated )
|
m_isNegated( isNegated )
|
||||||
{}
|
{}
|
||||||
@ -112,7 +112,7 @@ namespace Catch {
|
|||||||
class TagSet {
|
class TagSet {
|
||||||
typedef std::map<std::string, Tag> TagMap;
|
typedef std::map<std::string, Tag> TagMap;
|
||||||
public:
|
public:
|
||||||
void add( const Tag& tag ) {
|
void add( Tag const& tag ) {
|
||||||
m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) );
|
m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ namespace Catch {
|
|||||||
return m_tags.empty();
|
return m_tags.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matches( const std::set<std::string>& tags ) const {
|
bool matches( std::set<std::string> const& tags ) const {
|
||||||
TagMap::const_iterator it = m_tags.begin();
|
TagMap::const_iterator it = m_tags.begin();
|
||||||
TagMap::const_iterator itEnd = m_tags.end();
|
TagMap::const_iterator itEnd = m_tags.end();
|
||||||
for(; it != itEnd; ++it ) {
|
for(; it != itEnd; ++it ) {
|
||||||
@ -137,7 +137,7 @@ namespace Catch {
|
|||||||
|
|
||||||
class TagExpression {
|
class TagExpression {
|
||||||
public:
|
public:
|
||||||
bool matches( const std::set<std::string>& tags ) const {
|
bool matches( std::set<std::string> const& tags ) const {
|
||||||
std::vector<TagSet>::const_iterator it = m_tagSets.begin();
|
std::vector<TagSet>::const_iterator it = m_tagSets.begin();
|
||||||
std::vector<TagSet>::const_iterator itEnd = m_tagSets.end();
|
std::vector<TagSet>::const_iterator itEnd = m_tagSets.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
@ -162,7 +162,7 @@ namespace Catch {
|
|||||||
~TagExpressionParser();
|
~TagExpressionParser();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void acceptTag( const std::string& tag ) {
|
virtual void acceptTag( std::string const& tag ) {
|
||||||
m_currentTagSet.add( Tag( tag, m_isNegated ) );
|
m_currentTagSet.add( Tag( tag, m_isNegated ) );
|
||||||
m_isNegated = false;
|
m_isNegated = false;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ namespace Catch {
|
|||||||
m_exp.m_tagSets.push_back( m_currentTagSet );
|
m_exp.m_tagSets.push_back( m_currentTagSet );
|
||||||
}
|
}
|
||||||
|
|
||||||
TagExpressionParser& operator=(const TagExpressionParser&);
|
TagExpressionParser& operator=(TagExpressionParser const&);
|
||||||
|
|
||||||
bool m_isNegated;
|
bool m_isNegated;
|
||||||
TagSet m_currentTagSet;
|
TagSet m_currentTagSet;
|
||||||
|
@ -24,14 +24,14 @@ namespace Catch {
|
|||||||
struct ITestCase;
|
struct ITestCase;
|
||||||
|
|
||||||
struct TestCaseInfo {
|
struct TestCaseInfo {
|
||||||
TestCaseInfo( const std::string& _name,
|
TestCaseInfo( std::string const& _name,
|
||||||
const std::string& _className,
|
std::string const& _className,
|
||||||
const std::string& _description,
|
std::string const& _description,
|
||||||
const std::set<std::string>& _tags,
|
std::set<std::string> const& _tags,
|
||||||
bool _isHidden,
|
bool _isHidden,
|
||||||
const SourceLineInfo& _lineInfo );
|
SourceLineInfo const& _lineInfo );
|
||||||
|
|
||||||
TestCaseInfo( const TestCaseInfo& other );
|
TestCaseInfo( TestCaseInfo const& other );
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string className;
|
std::string className;
|
||||||
@ -45,34 +45,34 @@ namespace Catch {
|
|||||||
class TestCase : protected TestCaseInfo {
|
class TestCase : protected TestCaseInfo {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestCase( ITestCase* testCase, const TestCaseInfo& info );
|
TestCase( ITestCase* testCase, TestCaseInfo const& info );
|
||||||
TestCase( const TestCase& other );
|
TestCase( TestCase const& other );
|
||||||
|
|
||||||
TestCase withName( const std::string& _newName ) const;
|
TestCase withName( std::string const& _newName ) const;
|
||||||
|
|
||||||
void invoke() const;
|
void invoke() const;
|
||||||
|
|
||||||
const TestCaseInfo& getTestCaseInfo() const;
|
TestCaseInfo const& getTestCaseInfo() const;
|
||||||
|
|
||||||
bool isHidden() const;
|
bool isHidden() const;
|
||||||
bool hasTag( const std::string& tag ) const;
|
bool hasTag( std::string const& tag ) const;
|
||||||
bool matchesTags( const std::string& tagPattern ) const;
|
bool matchesTags( std::string const& tagPattern ) const;
|
||||||
const std::set<std::string>& getTags() const;
|
std::set<std::string> const& getTags() const;
|
||||||
|
|
||||||
void swap( TestCase& other );
|
void swap( TestCase& other );
|
||||||
bool operator == ( const TestCase& other ) const;
|
bool operator == ( TestCase const& other ) const;
|
||||||
bool operator < ( const TestCase& other ) const;
|
bool operator < ( TestCase const& other ) const;
|
||||||
TestCase& operator = ( const TestCase& other );
|
TestCase& operator = ( TestCase const& other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ptr<ITestCase> test;
|
Ptr<ITestCase> test;
|
||||||
};
|
};
|
||||||
|
|
||||||
TestCase makeTestCase( ITestCase* testCase,
|
TestCase makeTestCase( ITestCase* testCase,
|
||||||
const std::string& className,
|
std::string const& className,
|
||||||
const std::string& name,
|
std::string const& name,
|
||||||
const std::string& description,
|
std::string const& description,
|
||||||
const SourceLineInfo& lineInfo );
|
SourceLineInfo const& lineInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
TestCase makeTestCase( ITestCase* _testCase,
|
TestCase makeTestCase( ITestCase* _testCase,
|
||||||
const std::string& _className,
|
std::string const& _className,
|
||||||
const std::string& _name,
|
std::string const& _name,
|
||||||
const std::string& _descOrTags,
|
std::string const& _descOrTags,
|
||||||
const SourceLineInfo& _lineInfo )
|
SourceLineInfo const& _lineInfo )
|
||||||
{
|
{
|
||||||
std::string desc = _descOrTags;
|
std::string desc = _descOrTags;
|
||||||
bool isHidden( startsWith( _name, "./" ) );
|
bool isHidden( startsWith( _name, "./" ) );
|
||||||
@ -32,12 +32,12 @@ namespace Catch {
|
|||||||
return TestCase( _testCase, info );
|
return TestCase( _testCase, info );
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCaseInfo::TestCaseInfo( const std::string& _name,
|
TestCaseInfo::TestCaseInfo( std::string const& _name,
|
||||||
const std::string& _className,
|
std::string const& _className,
|
||||||
const std::string& _description,
|
std::string const& _description,
|
||||||
const std::set<std::string>& _tags,
|
std::set<std::string> const& _tags,
|
||||||
bool _isHidden,
|
bool _isHidden,
|
||||||
const SourceLineInfo& _lineInfo )
|
SourceLineInfo const& _lineInfo )
|
||||||
: name( _name ),
|
: name( _name ),
|
||||||
className( _className ),
|
className( _className ),
|
||||||
description( _description ),
|
description( _description ),
|
||||||
@ -51,7 +51,7 @@ namespace Catch {
|
|||||||
tagsAsString = oss.str();
|
tagsAsString = oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other )
|
TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
|
||||||
: name( other.name ),
|
: name( other.name ),
|
||||||
className( other.className ),
|
className( other.className ),
|
||||||
description( other.description ),
|
description( other.description ),
|
||||||
@ -61,14 +61,14 @@ namespace Catch {
|
|||||||
isHidden( other.isHidden )
|
isHidden( other.isHidden )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TestCase::TestCase( ITestCase* testCase, const TestCaseInfo& info ) : TestCaseInfo( info ), test( testCase ) {}
|
TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
|
||||||
|
|
||||||
TestCase::TestCase( const TestCase& other )
|
TestCase::TestCase( TestCase const& other )
|
||||||
: TestCaseInfo( other ),
|
: TestCaseInfo( other ),
|
||||||
test( other.test )
|
test( other.test )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TestCase TestCase::withName( const std::string& _newName ) const {
|
TestCase TestCase::withName( std::string const& _newName ) const {
|
||||||
TestCase other( *this );
|
TestCase other( *this );
|
||||||
other.name = _newName;
|
other.name = _newName;
|
||||||
return other;
|
return other;
|
||||||
@ -82,15 +82,15 @@ namespace Catch {
|
|||||||
return TestCaseInfo::isHidden;
|
return TestCaseInfo::isHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCase::hasTag( const std::string& tag ) const {
|
bool TestCase::hasTag( std::string const& tag ) const {
|
||||||
return tags.find( toLower( tag ) ) != tags.end();
|
return tags.find( toLower( tag ) ) != tags.end();
|
||||||
}
|
}
|
||||||
bool TestCase::matchesTags( const std::string& tagPattern ) const {
|
bool TestCase::matchesTags( std::string const& tagPattern ) const {
|
||||||
TagExpression exp;
|
TagExpression exp;
|
||||||
TagExpressionParser( exp ).parse( tagPattern );
|
TagExpressionParser( exp ).parse( tagPattern );
|
||||||
return exp.matches( tags );
|
return exp.matches( tags );
|
||||||
}
|
}
|
||||||
const std::set<std::string>& TestCase::getTags() const {
|
std::set<std::string> const& TestCase::getTags() const {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,22 +102,22 @@ namespace Catch {
|
|||||||
std::swap( lineInfo, other.lineInfo );
|
std::swap( lineInfo, other.lineInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCase::operator == ( const TestCase& other ) const {
|
bool TestCase::operator == ( TestCase const& other ) const {
|
||||||
return test.get() == other.test.get() &&
|
return test.get() == other.test.get() &&
|
||||||
name == other.name &&
|
name == other.name &&
|
||||||
className == other.className;
|
className == other.className;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCase::operator < ( const TestCase& other ) const {
|
bool TestCase::operator < ( TestCase const& other ) const {
|
||||||
return name < other.name;
|
return name < other.name;
|
||||||
}
|
}
|
||||||
TestCase& TestCase::operator = ( const TestCase& other ) {
|
TestCase& TestCase::operator = ( TestCase const& other ) {
|
||||||
TestCase temp( other );
|
TestCase temp( other );
|
||||||
swap( temp );
|
swap( temp );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TestCaseInfo& TestCase::getTestCaseInfo() const
|
TestCaseInfo const& TestCase::getTestCaseInfo() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace Catch {
|
|||||||
TestRegistry() : m_unnamedCount( 0 ) {}
|
TestRegistry() : m_unnamedCount( 0 ) {}
|
||||||
virtual ~TestRegistry();
|
virtual ~TestRegistry();
|
||||||
|
|
||||||
virtual void registerTest( const TestCase& testCase ) {
|
virtual void registerTest( TestCase const& testCase ) {
|
||||||
std::string name = testCase.getTestCaseInfo().name;
|
std::string name = testCase.getTestCaseInfo().name;
|
||||||
if( name == "" ) {
|
if( name == "" ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -40,7 +40,7 @@ namespace Catch {
|
|||||||
m_nonHiddenFunctions.push_back( testCase );
|
m_nonHiddenFunctions.push_back( testCase );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const TestCase& prev = *m_functions.find( testCase );
|
TestCase const& prev = *m_functions.find( testCase );
|
||||||
std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n"
|
std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n"
|
||||||
<< "\tFirst seen at " << SourceLineInfo( prev.getTestCaseInfo().lineInfo ) << "\n"
|
<< "\tFirst seen at " << SourceLineInfo( prev.getTestCaseInfo().lineInfo ) << "\n"
|
||||||
<< "\tRedefined at " << SourceLineInfo( testCase.getTestCaseInfo().lineInfo ) << std::endl;
|
<< "\tRedefined at " << SourceLineInfo( testCase.getTestCaseInfo().lineInfo ) << std::endl;
|
||||||
@ -48,23 +48,23 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const std::vector<TestCase>& getAllTests() const {
|
virtual std::vector<TestCase> const& getAllTests() const {
|
||||||
return m_functionsInOrder;
|
return m_functionsInOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const std::vector<TestCase>& getAllNonHiddenTests() const {
|
virtual std::vector<TestCase> const& getAllNonHiddenTests() const {
|
||||||
return m_nonHiddenFunctions;
|
return m_nonHiddenFunctions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !TBD deprecated
|
// !TBD deprecated
|
||||||
virtual std::vector<TestCase> getMatchingTestCases( const std::string& rawTestSpec ) const {
|
virtual std::vector<TestCase> getMatchingTestCases( std::string const& rawTestSpec ) const {
|
||||||
std::vector<TestCase> matchingTests;
|
std::vector<TestCase> matchingTests;
|
||||||
getMatchingTestCases( rawTestSpec, matchingTests );
|
getMatchingTestCases( rawTestSpec, matchingTests );
|
||||||
return matchingTests;
|
return matchingTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !TBD deprecated
|
// !TBD deprecated
|
||||||
virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector<TestCase>& matchingTestsOut ) const {
|
virtual void getMatchingTestCases( std::string const& rawTestSpec, std::vector<TestCase>& matchingTestsOut ) const {
|
||||||
TestCaseFilter filter( rawTestSpec );
|
TestCaseFilter filter( rawTestSpec );
|
||||||
|
|
||||||
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
||||||
@ -75,7 +75,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector<TestCase>& matchingTestsOut ) const {
|
virtual void getMatchingTestCases( TestCaseFilters const& filters, std::vector<TestCase>& matchingTestsOut ) const {
|
||||||
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin();
|
||||||
std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
|
std::vector<TestCase>::const_iterator itEnd = m_functionsInOrder.end();
|
||||||
// !TBD: replace with algorithm
|
// !TBD: replace with algorithm
|
||||||
@ -109,7 +109,7 @@ namespace Catch {
|
|||||||
TestFunction m_fun;
|
TestFunction m_fun;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::string extractClassName( const std::string& classOrQualifiedMethodName ) {
|
inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
|
||||||
std::string className = classOrQualifiedMethodName;
|
std::string className = classOrQualifiedMethodName;
|
||||||
if( className[0] == '&' )
|
if( className[0] == '&' )
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,8 @@ struct AutoReg {
|
|||||||
~AutoReg();
|
~AutoReg();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AutoReg( const AutoReg& );
|
AutoReg( AutoReg const& );
|
||||||
void operator= ( const AutoReg& );
|
void operator= ( AutoReg const& );
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -32,7 +32,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestCaseFilter( const std::string& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour )
|
TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour )
|
||||||
: m_stringToMatch( toLower( testSpec ) ),
|
: m_stringToMatch( toLower( testSpec ) ),
|
||||||
m_filterType( matchBehaviour ),
|
m_filterType( matchBehaviour ),
|
||||||
m_wildcardPosition( NoWildcard )
|
m_wildcardPosition( NoWildcard )
|
||||||
@ -65,7 +65,7 @@ namespace Catch {
|
|||||||
return m_filterType;
|
return m_filterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldInclude( const TestCase& testCase ) const {
|
bool shouldInclude( TestCase const& testCase ) const {
|
||||||
return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests);
|
return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@ -75,7 +75,7 @@ namespace Catch {
|
|||||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isMatch( const TestCase& testCase ) const {
|
bool isMatch( TestCase const& testCase ) const {
|
||||||
std::string name = testCase.getTestCaseInfo().name;
|
std::string name = testCase.getTestCaseInfo().name;
|
||||||
toLowerInPlace( name );
|
toLowerInPlace( name );
|
||||||
|
|
||||||
@ -103,27 +103,27 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestCaseFilters {
|
class TestCaseFilters {
|
||||||
public:
|
public:
|
||||||
TestCaseFilters( const std::string& name ) : m_name( name ) {}
|
TestCaseFilters( std::string const& name ) : m_name( name ) {}
|
||||||
|
|
||||||
std::string getName() const {
|
std::string getName() const {
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFilter( const TestCaseFilter& filter ) {
|
void addFilter( TestCaseFilter const& filter ) {
|
||||||
if( filter.getFilterType() == IfFilterMatches::ExcludeTests )
|
if( filter.getFilterType() == IfFilterMatches::ExcludeTests )
|
||||||
m_exclusionFilters.push_back( filter );
|
m_exclusionFilters.push_back( filter );
|
||||||
else
|
else
|
||||||
m_inclusionFilters.push_back( filter );
|
m_inclusionFilters.push_back( filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTags( const std::string& tagPattern ) {
|
void addTags( std::string const& tagPattern ) {
|
||||||
TagExpression exp;
|
TagExpression exp;
|
||||||
TagExpressionParser( exp ).parse( tagPattern );
|
TagExpressionParser( exp ).parse( tagPattern );
|
||||||
|
|
||||||
m_tagExpressions.push_back( exp );
|
m_tagExpressions.push_back( exp );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldInclude( const TestCase& testCase ) const {
|
bool shouldInclude( TestCase const& testCase ) const {
|
||||||
if( !m_tagExpressions.empty() ) {
|
if( !m_tagExpressions.empty() ) {
|
||||||
std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin();
|
std::vector<TagExpression>::const_iterator it = m_tagExpressions.begin();
|
||||||
std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end();
|
std::vector<TagExpression>::const_iterator itEnd = m_tagExpressions.end();
|
||||||
|
@ -56,7 +56,7 @@ namespace Detail {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct IsStreamInsertable {
|
struct IsStreamInsertable {
|
||||||
static std::ostream &s;
|
static std::ostream &s;
|
||||||
static T const &t;
|
static T const&t;
|
||||||
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
|
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ struct StringMaker<std::vector<T> > {
|
|||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline std::string makeString( const T& value ) {
|
inline std::string makeString( T const& value ) {
|
||||||
return StringMaker<T>::convert( value );
|
return StringMaker<T>::convert( value );
|
||||||
}
|
}
|
||||||
} // end namespace Detail
|
} // end namespace Detail
|
||||||
@ -125,17 +125,17 @@ namespace Detail {
|
|||||||
/// Overload (not specialise) this template for custom typs that you don't want
|
/// Overload (not specialise) this template for custom typs that you don't want
|
||||||
/// to provide an ostream overload for.
|
/// to provide an ostream overload for.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::string toString( const T& value ) {
|
std::string toString( T const& value ) {
|
||||||
return StringMaker<T>::convert( value );
|
return StringMaker<T>::convert( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Built in overloads
|
// Built in overloads
|
||||||
|
|
||||||
inline std::string toString( const std::string& value ) {
|
inline std::string toString( std::string const& value ) {
|
||||||
return "\"" + value + "\"";
|
return "\"" + value + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string toString( const std::wstring& value ) {
|
inline std::string toString( std::wstring const& value ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "\"";
|
oss << "\"";
|
||||||
for(size_t i = 0; i < value.size(); ++i )
|
for(size_t i = 0; i < value.size(); ++i )
|
||||||
|
@ -15,13 +15,13 @@ namespace Catch {
|
|||||||
struct Counts {
|
struct Counts {
|
||||||
Counts() : passed( 0 ), failed( 0 ) {}
|
Counts() : passed( 0 ), failed( 0 ) {}
|
||||||
|
|
||||||
Counts operator - ( const Counts& other ) const {
|
Counts operator - ( Counts const& other ) const {
|
||||||
Counts diff;
|
Counts diff;
|
||||||
diff.passed = passed - other.passed;
|
diff.passed = passed - other.passed;
|
||||||
diff.failed = failed - other.failed;
|
diff.failed = failed - other.failed;
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
Counts& operator += ( const Counts& other ) {
|
Counts& operator += ( Counts const& other ) {
|
||||||
passed += other.passed;
|
passed += other.passed;
|
||||||
failed += other.failed;
|
failed += other.failed;
|
||||||
return *this;
|
return *this;
|
||||||
@ -37,14 +37,14 @@ namespace Catch {
|
|||||||
|
|
||||||
struct Totals {
|
struct Totals {
|
||||||
|
|
||||||
Totals operator - ( const Totals& other ) const {
|
Totals operator - ( Totals const& other ) const {
|
||||||
Totals diff;
|
Totals diff;
|
||||||
diff.assertions = assertions - other.assertions;
|
diff.assertions = assertions - other.assertions;
|
||||||
diff.testCases = testCases - other.testCases;
|
diff.testCases = testCases - other.testCases;
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals delta( const Totals& prevTotals ) const {
|
Totals delta( Totals const& prevTotals ) const {
|
||||||
Totals diff = *this - prevTotals;
|
Totals diff = *this - prevTotals;
|
||||||
if( diff.assertions.failed > 0 )
|
if( diff.assertions.failed > 0 )
|
||||||
++diff.testCases.failed;
|
++diff.testCases.failed;
|
||||||
@ -53,7 +53,7 @@ namespace Catch {
|
|||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals& operator += ( const Totals& other ) {
|
Totals& operator += ( Totals const& other ) {
|
||||||
assertions += other.assertions;
|
assertions += other.assertions;
|
||||||
testCases += other.testCases;
|
testCases += other.testCases;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -24,7 +24,7 @@ namespace Catch {
|
|||||||
: m_writer( writer )
|
: m_writer( writer )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ScopedElement( const ScopedElement& other )
|
ScopedElement( ScopedElement const& other )
|
||||||
: m_writer( other.m_writer ){
|
: m_writer( other.m_writer ){
|
||||||
other.m_writer = NULL;
|
other.m_writer = NULL;
|
||||||
}
|
}
|
||||||
@ -34,13 +34,13 @@ namespace Catch {
|
|||||||
m_writer->endElement();
|
m_writer->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedElement& writeText( const std::string& text, bool indent = true ) {
|
ScopedElement& writeText( std::string const& text, bool indent = true ) {
|
||||||
m_writer->writeText( text, indent );
|
m_writer->writeText( text, indent );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ScopedElement& writeAttribute( const std::string& name, const T& attribute ) {
|
ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
|
||||||
m_writer->writeAttribute( name, attribute );
|
m_writer->writeAttribute( name, attribute );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ namespace Catch {
|
|||||||
endElement();
|
endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& operator = ( const XmlWriter& other ) {
|
XmlWriter& operator = ( XmlWriter const& other ) {
|
||||||
XmlWriter temp( other );
|
XmlWriter temp( other );
|
||||||
swap( temp );
|
swap( temp );
|
||||||
return *this;
|
return *this;
|
||||||
@ -80,7 +80,7 @@ namespace Catch {
|
|||||||
std::swap( m_os, other.m_os );
|
std::swap( m_os, other.m_os );
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& startElement( const std::string& name ) {
|
XmlWriter& startElement( std::string const& name ) {
|
||||||
ensureTagClosed();
|
ensureTagClosed();
|
||||||
newlineIfNecessary();
|
newlineIfNecessary();
|
||||||
stream() << m_indent << "<" << name;
|
stream() << m_indent << "<" << name;
|
||||||
@ -90,7 +90,7 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedElement scopedElement( const std::string& name ) {
|
ScopedElement scopedElement( std::string const& name ) {
|
||||||
ScopedElement scoped( this );
|
ScopedElement scoped( this );
|
||||||
startElement( name );
|
startElement( name );
|
||||||
return scoped;
|
return scoped;
|
||||||
@ -110,7 +110,7 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeAttribute( const std::string& name, const std::string& attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
|
||||||
if( !name.empty() && !attribute.empty() ) {
|
if( !name.empty() && !attribute.empty() ) {
|
||||||
stream() << " " << name << "=\"";
|
stream() << " " << name << "=\"";
|
||||||
writeEncodedText( attribute );
|
writeEncodedText( attribute );
|
||||||
@ -119,19 +119,19 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeAttribute( const std::string& name, bool attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
|
||||||
stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
|
stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
XmlWriter& writeAttribute( const std::string& name, const T& attribute ) {
|
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
|
||||||
if( !name.empty() )
|
if( !name.empty() )
|
||||||
stream() << " " << name << "=\"" << attribute << "\"";
|
stream() << " " << name << "=\"" << attribute << "\"";
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeText( const std::string& text, bool indent = true ) {
|
XmlWriter& writeText( std::string const& text, bool indent = true ) {
|
||||||
if( !text.empty() ){
|
if( !text.empty() ){
|
||||||
bool tagWasOpen = m_tagIsOpen;
|
bool tagWasOpen = m_tagIsOpen;
|
||||||
ensureTagClosed();
|
ensureTagClosed();
|
||||||
@ -143,7 +143,7 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlWriter& writeComment( const std::string& text ) {
|
XmlWriter& writeComment( std::string const& text ) {
|
||||||
ensureTagClosed();
|
ensureTagClosed();
|
||||||
stream() << m_indent << "<!--" << text << "-->";
|
stream() << m_indent << "<!--" << text << "-->";
|
||||||
m_needsNewline = true;
|
m_needsNewline = true;
|
||||||
@ -176,7 +176,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEncodedText( const std::string& text ) {
|
void writeEncodedText( std::string const& text ) {
|
||||||
static const char* charsToEncode = "<&\"";
|
static const char* charsToEncode = "<&\"";
|
||||||
std::string mtext = text;
|
std::string mtext = text;
|
||||||
std::string::size_type pos = mtext.find_first_of( charsToEncode );
|
std::string::size_type pos = mtext.find_first_of( charsToEncode );
|
||||||
|
Loading…
Reference in New Issue
Block a user