diff options
| author | Phil Nash | 2013-04-23 18:58:56 +0100 |
|---|---|---|
| committer | Phil Nash | 2013-04-23 18:58:56 +0100 |
| commit | 2a9d8d9e368a8da58733df6746baff4bb76312d2 (patch) | |
| tree | 770cb49fdad90bac9aab4dd12602ea91fd859ccb | |
| parent | d0d4d93a6be52fcb33cfeeb6dc10c26d4599a3ce (diff) | |
| download | catch3-2a9d8d9e368a8da58733df6746baff4bb76312d2.tar.gz | |
Changed "const X ref"s to "X const ref"s
- Brought older code up to current convention (with the help of a Python script)
44 files changed, 297 insertions, 297 deletions
diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 128ef050..2f467a36 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -24,7 +24,7 @@ namespace Detail { m_value( value ) {} - Approx( const Approx& other ) + Approx( Approx const& other ) : m_epsilon( other.m_epsilon ), m_scale( other.m_scale ), m_value( other.m_value ) @@ -41,20 +41,20 @@ namespace Detail { 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 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 ); } - friend bool operator != ( double lhs, const Approx& rhs ) { + friend bool operator != ( double lhs, Approx const& 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 ); } @@ -82,7 +82,7 @@ namespace Detail { } template<> -inline std::string toString<Detail::Approx>( const Detail::Approx& value ) { +inline std::string toString<Detail::Approx>( Detail::Approx const& value ) { return value.toString(); } diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index 37372b67..b3f63e04 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -16,9 +16,9 @@ namespace Catch { struct AssertionInfo { AssertionInfo() {} - AssertionInfo( const std::string& _macroName, - const SourceLineInfo& _lineInfo, - const std::string& _capturedExpression, + AssertionInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + std::string const& _capturedExpression, ResultDisposition::Flags _resultDisposition ); std::string macroName; @@ -39,7 +39,7 @@ namespace Catch { class AssertionResult { public: AssertionResult(); - AssertionResult( const AssertionInfo& info, const AssertionResultData& data ); + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); ~AssertionResult(); bool isOk() const; diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp index 91853307..5ba2f458 100644 --- a/include/internal/catch_assertionresult.hpp +++ b/include/internal/catch_assertionresult.hpp @@ -13,9 +13,9 @@ namespace Catch { - AssertionInfo::AssertionInfo( const std::string& _macroName, - const SourceLineInfo& _lineInfo, - const std::string& _capturedExpression, + AssertionInfo::AssertionInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + std::string const& _capturedExpression, ResultDisposition::Flags _resultDisposition ) : macroName( _macroName ), lineInfo( _lineInfo ), @@ -28,7 +28,7 @@ namespace Catch { AssertionResult::AssertionResult() {} - AssertionResult::AssertionResult( const AssertionInfo& info, const AssertionResultData& data ) + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) : m_info( info ), m_resultData( data ) {} diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 81eb4a0d..a8aa98b1 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -27,8 +27,8 @@ namespace Catch { } template<typename MatcherT> - ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher, - const std::string& matcherCallAsString ) { + ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, + std::string const& matcherCallAsString ) { std::string matcherAsString = matcher.toString(); if( matcherAsString == "{?}" ) matcherAsString = matcherCallAsString; @@ -38,18 +38,18 @@ namespace Catch { } template<typename MatcherT, typename ArgT> - ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher, - const ArgT& arg, - const std::string& matcherCallAsString ) { + ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, + ArgT const& arg, + std::string const& matcherCallAsString ) { return expressionResultBuilderFromMatcher( matcher, matcherCallAsString ) .setLhs( Catch::toString( arg ) ) .setResultType( matcher.match( arg ) ); } template<typename MatcherT, typename ArgT> - ExpressionResultBuilder expressionResultBuilderFromMatcher( const MatcherT& matcher, + ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, ArgT* arg, - const std::string& matcherCallAsString ) { + std::string const& matcherCallAsString ) { return expressionResultBuilderFromMatcher( matcher, matcherCallAsString ) .setLhs( Catch::toString( arg ) ) .setResultType( matcher.match( arg ) ); diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index 4c32d7f3..7657da6b 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -17,20 +17,20 @@ namespace Catch { public: 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 ); 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 ) ); if( m_name.empty() ) m_name = other.m_name; return *this; } - Command operator + ( const Command& other ) { + Command operator + ( Command const& other ) { Command newCommand( *this ); newCommand += other; return newCommand; @@ -45,7 +45,7 @@ namespace Catch { std::size_t argsCount() const { return m_args.size(); } CATCH_ATTRIBUTE_NORETURN - void raiseError( const std::string& message ) const { + void raiseError( std::string const& message ) const { std::ostringstream oss; if( m_name.empty() ) oss << "Error while parsing " << m_name << ". " << message << "."; @@ -76,14 +76,14 @@ namespace Catch { exeName = exeName.substr( pos+1 ); 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 ); } - 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 ); } - Command find( const std::string& arg ) const { + Command find( std::string const& arg ) const { if( arg.empty() ) return getArgs( "", 1 ); else @@ -97,7 +97,7 @@ namespace Catch { } 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 ); for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i ) command += m_argv[i]; @@ -116,7 +116,7 @@ namespace Catch { virtual ~OptionParser() {} - Command find( const CommandParser& parser ) const { + Command find( CommandParser const& parser ) const { Command cmd; for( std::vector<std::string>::const_iterator it = m_optionNames.begin(); it != m_optionNames.end(); @@ -125,7 +125,7 @@ namespace Catch { return cmd; } - void validateArgs( const Command& args ) const { + void validateArgs( Command const& args ) const { if( tooFewArgs( args ) || tooManyArgs( args ) ) { std::ostringstream oss; 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 ) ) { validateArgs( cmd ); 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 optionSummary() const = 0; virtual std::string optionDescription() const { return ""; } @@ -171,10 +171,10 @@ namespace Catch { protected: - bool tooFewArgs( const Command& args ) const { + bool tooFewArgs( Command const& args ) const { 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 ); } std::vector<std::string> m_optionNames; @@ -201,7 +201,7 @@ namespace Catch { return ""; } - virtual void parseIntoConfig( const Command&, ConfigData& ) { + virtual void parseIntoConfig( Command const&, ConfigData& ) { // Does not affect config } }; @@ -254,7 +254,7 @@ namespace Catch { "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; for( std::size_t i = 0; i < cmd.argsCount(); ++i ) { if( i != 0 ) @@ -300,7 +300,7 @@ namespace Catch { "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; for( std::size_t i = 0; i < cmd.argsCount(); ++i ) { if( i != 0 ) @@ -345,7 +345,7 @@ namespace Catch { ;//" -l xml"; } - virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { + virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) { config.listSpec = List::Tests; if( cmd.argsCount() >= 1 ) { if( cmd[0] == "all" ) @@ -404,7 +404,7 @@ namespace Catch { "of the root node."; } - virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { + virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) { config.reporter = cmd[0]; } }; @@ -438,7 +438,7 @@ namespace Catch { " -o %debug \t(The IDE's debug output window - currently only Windows' " "OutputDebugString is supported)."; } - virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { + virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) { if( cmd[0][0] == '%' ) config.stream = cmd[0].substr( 1 ); else @@ -465,7 +465,7 @@ namespace Catch { "added worked first time!). To see successful, as well as failing, test results " "just pass this option."; } - virtual void parseIntoConfig( const Command&, ConfigData& config ) { + virtual void parseIntoConfig( Command const&, ConfigData& config ) { config.includeWhichResults = Include::SuccessfulResults; } }; @@ -491,7 +491,7 @@ namespace Catch { "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; } }; @@ -521,7 +521,7 @@ namespace Catch { " -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]; } }; @@ -550,7 +550,7 @@ namespace Catch { "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; if( cmd.argsCount() == 1 ) { std::stringstream ss; @@ -589,7 +589,7 @@ namespace Catch { "as not to contribute additional noise."; } - virtual void parseIntoConfig( const Command&, ConfigData& config ) { + virtual void parseIntoConfig( Command const&, ConfigData& config ) { config.allowThrows = false; } }; @@ -620,7 +620,7 @@ namespace Catch { " -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 ) { if( cmd[i] == "NoAssertions" ) config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions ); @@ -655,7 +655,7 @@ namespace Catch { 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(); if( endsWith( config.name, ".exe" ) ) config.name = config.name.substr( 0, config.name.size()-4 ); diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index d6627878..954f6170 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -28,8 +28,8 @@ namespace Catch { class NonCopyable { - NonCopyable( const NonCopyable& ); - void operator = ( const NonCopyable& ); + NonCopyable( NonCopyable const& ); + void operator = ( NonCopyable const& ); protected: NonCopyable() {} virtual ~NonCopyable(); @@ -67,17 +67,17 @@ namespace Catch { } 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 ); } - 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; } - 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; } - 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; } inline void toLowerInPlace( std::string& s ) { @@ -90,12 +90,12 @@ namespace Catch { } struct pluralise { - pluralise( std::size_t count, const std::string& label ) + pluralise( std::size_t count, std::string const& label ) : m_count( count ), 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; if( pluraliser.m_count != 1 ) os << "s"; @@ -109,11 +109,11 @@ namespace Catch { struct SourceLineInfo { SourceLineInfo() : line( 0 ){} - SourceLineInfo( const std::string& _file, std::size_t _line ) + SourceLineInfo( std::string const& _file, std::size_t _line ) : file( _file ), line( _line ) {} - SourceLineInfo( const SourceLineInfo& other ) + SourceLineInfo( SourceLineInfo const& other ) : file( other.file ), line( other.line ) {} @@ -125,7 +125,7 @@ namespace Catch { 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__ os << info.file << "(" << info.line << ")"; #else @@ -135,7 +135,7 @@ namespace Catch { } 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; oss << locationInfo << ": Internal Catch error: '" << message << "'"; throw std::logic_error( oss.str() ); diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 0e5de388..87c7d734 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -77,8 +77,8 @@ namespace Catch { class Config : public IConfig { private: - Config( const Config& other ); - Config& operator = ( const Config& other ); + Config( Config const& other ); + Config& operator = ( Config const& other ); virtual void dummy(); public: @@ -86,7 +86,7 @@ namespace Catch { : m_os( std::cout.rdbuf() ) {} - Config( const ConfigData& data ) + Config( ConfigData const& data ) : m_data( data ), m_os( std::cout.rdbuf() ) {} @@ -96,7 +96,7 @@ namespace Catch { m_stream.release(); } - void setFilename( const std::string& filename ) { + void setFilename( std::string const& filename ) { m_data.outputFilename = filename; } @@ -104,7 +104,7 @@ namespace Catch { return m_data.listSpec; } - const std::string& getFilename() const { + std::string const& getFilename() const { return m_data.outputFilename ; } @@ -132,14 +132,14 @@ namespace Catch { m_os.rdbuf( buf ? buf : std::cout.rdbuf() ); } - void useStream( const std::string& streamName ) { + void useStream( std::string const& streamName ) { Stream stream = createStream( streamNa |