Addressed some static analysis warnings

Based on findings in #957
This commit is contained in:
Martin Hořeňovský 2017-07-19 09:50:08 +02:00
parent 8ebe94ca2e
commit 7a22bad763
9 changed files with 15 additions and 23 deletions

View File

@ -95,11 +95,11 @@ namespace Catch {
if( lastSlash != std::string::npos ) if( lastSlash != std::string::npos )
filename = filename.substr( lastSlash+1 ); filename = filename.substr( lastSlash+1 );
std::string::size_type lastDot = filename.find_last_of( "." ); std::string::size_type lastDot = filename.find_last_of( '.' );
if( lastDot != std::string::npos ) if( lastDot != std::string::npos )
filename = filename.substr( 0, lastDot ); filename = filename.substr( 0, lastDot );
tags.insert( "#" + filename ); tags.insert( '#' + filename );
setTags( test, tags ); setTags( test, tags );
} }
} }

View File

@ -151,7 +151,7 @@ namespace Tbc {
return oss.str(); return oss.str();
} }
inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
it != itEnd; ++it ) { it != itEnd; ++it ) {
if( it != _text.begin() ) if( it != _text.begin() )

View File

@ -29,13 +29,6 @@ namespace Detail {
m_value( value ) m_value( value )
{} {}
Approx( Approx const& other )
: m_epsilon( other.m_epsilon ),
m_margin( other.m_margin ),
m_scale( other.m_scale ),
m_value( other.m_value )
{}
static Approx custom() { static Approx custom() {
return Approx( 0 ); return Approx( 0 );
} }

View File

@ -61,14 +61,14 @@ namespace Catch {
}; };
template<typename ContainerT> template<typename ContainerT>
inline void deleteAll( ContainerT& container ) { void deleteAll( ContainerT& container ) {
typename ContainerT::const_iterator it = container.begin(); typename ContainerT::const_iterator it = container.begin();
typename ContainerT::const_iterator itEnd = container.end(); typename ContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )
delete *it; delete *it;
} }
template<typename AssociativeContainerT> template<typename AssociativeContainerT>
inline void deleteAllValues( AssociativeContainerT& container ) { void deleteAllValues( AssociativeContainerT& container ) {
typename AssociativeContainerT::const_iterator it = container.begin(); typename AssociativeContainerT::const_iterator it = container.begin();
typename AssociativeContainerT::const_iterator itEnd = container.end(); typename AssociativeContainerT::const_iterator itEnd = container.end();
for(; it != itEnd; ++it ) for(; it != itEnd; ++it )

View File

@ -37,7 +37,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(T const& t) { return const_cast<T&>(t); } 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
@ -48,7 +48,7 @@ namespace Internal {
// So the compare overloads can be operator agnostic we convey the operator as a template // So the compare overloads can be operator agnostic we convey the operator as a template
// enum, which is used to specialise an Evaluator for doing the comparison. // enum, which is used to specialise an Evaluator for doing the comparison.
template<typename T1, typename T2, Operator Op> template<typename T1, typename T2, Operator Op>
class Evaluator{}; struct Evaluator{};
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsEqualTo> { struct Evaluator<T1, T2, IsEqualTo> {

View File

@ -147,23 +147,23 @@ namespace Matchers {
// This allows the types to be inferred // This allows the types to be inferred
// - deprecated: prefer ||, && and ! // - deprecated: prefer ||, && and !
template<typename T> template<typename T>
inline Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) { Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
return Impl::MatchNotOf<T>( underlyingMatcher ); return Impl::MatchNotOf<T>( underlyingMatcher );
} }
template<typename T> template<typename T>
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) { Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
return Impl::MatchAllOf<T>() && m1 && m2; return Impl::MatchAllOf<T>() && m1 && m2;
} }
template<typename T> template<typename T>
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) { Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
return Impl::MatchAllOf<T>() && m1 && m2 && m3; return Impl::MatchAllOf<T>() && m1 && m2 && m3;
} }
template<typename T> template<typename T>
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) { Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
return Impl::MatchAnyOf<T>() || m1 || m2; return Impl::MatchAnyOf<T>() || m1 || m2;
} }
template<typename T> template<typename T>
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) { Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
return Impl::MatchAnyOf<T>() || m1 || m2 || m3; return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
} }

View File

@ -16,7 +16,6 @@ namespace Catch {
{ {
public: public:
NotImplementedException( SourceLineInfo const& lineInfo ); NotImplementedException( SourceLineInfo const& lineInfo );
NotImplementedException( NotImplementedException const& ) {}
virtual ~NotImplementedException() CATCH_NOEXCEPT {} virtual ~NotImplementedException() CATCH_NOEXCEPT {}

View File

@ -111,7 +111,7 @@ namespace Catch {
namespace Catch { namespace Catch {
template<typename T> template<typename T>
inline ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) { ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
return ExpressionLhs<T const&>( *this, operand ); return ExpressionLhs<T const&>( *this, operand );
} }
@ -120,7 +120,7 @@ namespace Catch {
} }
template<typename ArgT, typename MatcherT> template<typename ArgT, typename MatcherT>
inline void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher, void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
char const* matcherString ) { char const* matcherString ) {
MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString ); MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
setResultType( matcher.match( arg ) ); setResultType( matcher.match( arg ) );

View File

@ -153,7 +153,7 @@ namespace Detail {
std::string rawMemoryToString( const void *object, std::size_t size ); std::string rawMemoryToString( const void *object, std::size_t size );
template<typename T> template<typename T>
inline std::string rawMemoryToString( const T& object ) { std::string rawMemoryToString( const T& object ) {
return rawMemoryToString( &object, sizeof(object) ); return rawMemoryToString( &object, sizeof(object) );
} }