Avoid GCC warnings (-Wold-style-casts and -Wshadow)

This commit is contained in:
Matthias Geier 2013-07-12 14:41:41 +02:00
parent 801672b962
commit a3da853fdd
6 changed files with 31 additions and 31 deletions

View File

@ -24,14 +24,14 @@ namespace Catch {
inline void addWarning( ConfigData& config, std::string const& _warning ) { inline void addWarning( ConfigData& config, std::string const& _warning ) {
if( _warning == "NoAssertions" ) if( _warning == "NoAssertions" )
config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions ); config.warnings = static_cast<ConfigData::WarnAbout::What>( config.warnings | ConfigData::WarnAbout::NoAssertions );
else else
throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" ); throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
} }
inline void setVerbosity( ConfigData& config, int level ) { inline void setVerbosity( ConfigData& config, int level ) {
// !TBD: accept strings? // !TBD: accept strings?
config.verbosity = (ConfigData::Verbosity::Level)level; config.verbosity = static_cast<ConfigData::Verbosity::Level>(level);
} }
inline Clara::CommandLine<ConfigData> makeCommandLineParser() { inline Clara::CommandLine<ConfigData> makeCommandLineParser() {

View File

@ -95,15 +95,15 @@ namespace Catch {
groupName += " "; groupName += " ";
groupName += data.testsOrTags[i]; groupName += data.testsOrTags[i];
} }
TestCaseFilters filters( groupName ); TestCaseFilters filterSet( groupName );
for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) { for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) {
std::string filter = data.testsOrTags[i]; std::string filter = data.testsOrTags[i];
if( startsWith( filter, "[" ) || startsWith( filter, "~[" ) ) if( startsWith( filter, "[" ) || startsWith( filter, "~[" ) )
filters.addTags( filter ); filterSet.addTags( filter );
else else
filters.addFilter( TestCaseFilter( filter ) ); filterSet.addFilter( TestCaseFilter( filter ) );
} }
m_filterSets.push_back( filters ); m_filterSets.push_back( filterSet );
} }
} }
@ -137,18 +137,18 @@ namespace Catch {
} }
void useStream( std::string const& streamName ) { void useStream( std::string const& streamName ) {
Stream stream = createStream( streamName ); Stream tempStream = createStream( streamName );
setStreamBuf( stream.streamBuf ); setStreamBuf( tempStream.streamBuf );
m_stream.release(); m_stream.release();
m_stream = stream; m_stream = tempStream;
} }
std::string getReporterName() const { return m_data.reporterName; } std::string getReporterName() const { return m_data.reporterName; }
void addTestSpec( std::string const& testSpec ) { void addTestSpec( std::string const& testSpec ) {
TestCaseFilters filters( testSpec ); TestCaseFilters filterSet( testSpec );
filters.addFilter( TestCaseFilter( testSpec ) ); filterSet.addFilter( TestCaseFilter( testSpec ) );
m_filterSets.push_back( filters ); m_filterSets.push_back( filterSet );
} }
int abortAfter() const { int abortAfter() const {

View File

@ -56,11 +56,11 @@ namespace Catch {
public: public:
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter ) explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( config->name() ), : m_runInfo( _config->name() ),
m_context( getCurrentMutableContext() ), m_context( getCurrentMutableContext() ),
m_activeTestCase( NULL ), m_activeTestCase( NULL ),
m_config( config ), m_config( _config ),
m_reporter( reporter ), m_reporter( reporter ),
m_prevRunner( &m_context.getRunner() ), m_prevRunner( &m_context.getRunner() ),
m_prevResultCapture( &m_context.getResultCapture() ), m_prevResultCapture( &m_context.getResultCapture() ),
@ -256,9 +256,9 @@ namespace Catch {
if( !m_lastResult.isOk() ) { if( !m_lastResult.isOk() ) {
action = ResultAction::Failed; action = ResultAction::Failed;
if( shouldDebugBreak() ) if( shouldDebugBreak() )
action = (ResultAction::Value)( action | ResultAction::Debug ); action = static_cast<ResultAction::Value>( action | ResultAction::Debug );
if( aborting() ) if( aborting() )
action = (ResultAction::Value)( action | ResultAction::Abort ); action = static_cast<ResultAction::Value>( action | ResultAction::Abort );
} }
return action; return action;
} }

View File

@ -88,9 +88,9 @@ namespace Catch {
: m_isNegated( false ) : m_isNegated( false )
{} {}
Tag( std::string const& name, bool isNegated ) Tag( std::string const& name, bool _isNegated )
: m_name( name ), : m_name( name ),
m_isNegated( isNegated ) m_isNegated( _isNegated )
{} {}
std::string getName() const { std::string getName() const {

View File

@ -53,11 +53,11 @@ namespace Catch {
if( startsWith( m_stringToMatch, "*" ) ) { if( startsWith( m_stringToMatch, "*" ) ) {
m_stringToMatch = m_stringToMatch.substr( 1 ); m_stringToMatch = m_stringToMatch.substr( 1 );
m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart ); m_wildcardPosition = static_cast<WildcardPosition>( m_wildcardPosition | WildcardAtStart );
} }
if( endsWith( m_stringToMatch, "*" ) ) { if( endsWith( m_stringToMatch, "*" ) ) {
m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 ); m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 );
m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd ); m_wildcardPosition = static_cast<WildcardPosition>( m_wildcardPosition | WildcardAtEnd );
} }
} }

View File

@ -347,12 +347,12 @@ namespace Clara {
m_arg.description = description; m_arg.description = description;
return *this; return *this;
} }
ArgBinder& argName( std::string const& argName ) { ArgBinder& argName( std::string const& _argName ) {
m_arg.argName = argName; m_arg.argName = _argName;
return *this; return *this;
} }
ArgBinder& position( int position ) { ArgBinder& position( int _position ) {
m_arg.position = position; m_arg.position = _position;
return *this; return *this;
} }
private: private:
@ -393,20 +393,20 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() ); maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) { for( it = itBegin; it != itEnd; ++it ) {
Catch::Text usage( it->commands(), Catch::TextAttributes() Catch::Text usageString( it->commands(), Catch::TextAttributes()
.setWidth( maxWidth+indent ) .setWidth( maxWidth+indent )
.setIndent( indent ) ); .setIndent( indent ) );
// !TBD handle longer usage strings // !TBD handle longer usage strings
Catch::Text desc( it->description, Catch::TextAttributes() Catch::Text descString( it->description, Catch::TextAttributes()
.setWidth( width - maxWidth -3 ) ); .setWidth( width - maxWidth -3 ) );
for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { for( std::size_t i = 0; i < (std::max)( usageString.size(), descString.size() ); ++i ) {
std::string usageCol = i < usage.size() ? usage[i] : ""; std::string usageCol = i < usageString.size() ? usageString[i] : "";
os << usageCol; os << usageCol;
if( i < desc.size() && !desc[i].empty() ) if( i < descString.size() && !descString[i].empty() )
os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' ) os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
<< desc[i]; << descString[i];
os << "\n"; os << "\n";
} }
} }