Removed C-style casts

This commit is contained in:
Phil Nash 2014-07-09 07:35:34 +01:00
parent 08e5296720
commit a31f05fe83
5 changed files with 8 additions and 8 deletions

View File

@ -26,14 +26,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 = (WarnAbout::What)( config.warnings | WarnAbout::NoAssertions ); config.warnings = static_cast<WarnAbout::What>( config.warnings | 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 = (Verbosity::Level)level; config.verbosity = static_cast<Verbosity::Level>( level );
} }
inline void setShowDurations( ConfigData& config, bool _showDurations ) { inline void setShowDurations( ConfigData& config, bool _showDurations ) {
config.showDurations = _showDurations config.showDurations = _showDurations

View File

@ -108,7 +108,7 @@ namespace Catch {
for( std::set<std::string>::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) { for( std::set<std::string>::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) {
oss << "[" << *it << "]"; oss << "[" << *it << "]";
std::string lcaseTag = toLower( *it ); std::string lcaseTag = toLower( *it );
properties = (SpecialProperties)( properties | parseSpecialTag( lcaseTag ) ); properties = static_cast<SpecialProperties>( properties | parseSpecialTag( lcaseTag ) );
lcaseTags.insert( lcaseTag ); lcaseTags.insert( lcaseTag );
} }
tagsAsString = oss.str(); tagsAsString = oss.str();

View File

@ -41,7 +41,7 @@ namespace Catch {
} }
if( endsWith( m_name, "*" ) ) { if( endsWith( m_name, "*" ) ) {
m_name = m_name.substr( 0, m_name.size()-1 ); m_name = m_name.substr( 0, m_name.size()-1 );
m_wildcard = (WildcardPosition)( m_wildcard | WildcardAtEnd ); m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
} }
} }
virtual ~NamePattern(); virtual ~NamePattern();

View File

@ -38,7 +38,7 @@ namespace Catch {
uint64_t getCurrentTicks() { uint64_t getCurrentTicks() {
timeval t; timeval t;
gettimeofday(&t,NULL); gettimeofday(&t,NULL);
return (uint64_t)t.tv_sec * 1000000ull + (uint64_t)t.tv_usec; return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
} }
#endif #endif
} }
@ -47,10 +47,10 @@ namespace Catch {
m_ticks = getCurrentTicks(); m_ticks = getCurrentTicks();
} }
unsigned int Timer::getElapsedNanoseconds() const { unsigned int Timer::getElapsedNanoseconds() const {
return (unsigned int)(getCurrentTicks() - m_ticks); return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
} }
unsigned int Timer::getElapsedMilliseconds() const { unsigned int Timer::getElapsedMilliseconds() const {
return (unsigned int)((getCurrentTicks() - m_ticks)/1000); return static_cast<unsigned int>((getCurrentTicks() - m_ticks)/1000);
} }
double Timer::getElapsedSeconds() const { double Timer::getElapsedSeconds() const {
return (getCurrentTicks() - m_ticks)/1000000.0; return (getCurrentTicks() - m_ticks)/1000000.0;

View File

@ -324,7 +324,7 @@ namespace Catch {
} }
void printTotals( Totals const& totals ) { void printTotals( Totals const& totals ) {
int cols = 1+(int)log10( (float)std::max( totals.testCases.total(), totals.assertions.total() ) ); int cols = 1+static_cast<int>( log10( static_cast<float>( (std::max)( totals.testCases.total(), totals.assertions.total() ) ) ) );
if( totals.testCases.total() == 0 ) { if( totals.testCases.total() == 0 ) {
stream << Colour( Colour::Warning ) << "No tests ran\n"; stream << Colour( Colour::Warning ) << "No tests ran\n";
} }