mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Address results of PVS-Studio static analysis
Couple are left un-addressed, see #958 for details.
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Catch {
|
||||
char const * macroName = nullptr;
|
||||
SourceLineInfo lineInfo;
|
||||
char const * capturedExpression = nullptr;
|
||||
ResultDisposition::Flags resultDisposition;
|
||||
ResultDisposition::Flags resultDisposition = ResultDisposition::Normal;
|
||||
};
|
||||
|
||||
struct AssertionResultData
|
||||
|
@@ -17,7 +17,7 @@ namespace Catch {
|
||||
namespace {
|
||||
|
||||
struct IColourImpl {
|
||||
virtual ~IColourImpl() {}
|
||||
virtual ~IColourImpl() = default;
|
||||
virtual void use( Colour::Code _colourCode ) = 0;
|
||||
};
|
||||
|
||||
@@ -178,8 +178,14 @@ namespace Catch {
|
||||
|
||||
namespace Catch {
|
||||
|
||||
Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); }
|
||||
Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast<Colour&>( _other ).m_moved = true; }
|
||||
Colour::Colour( Code _colourCode ) { use( _colourCode ); }
|
||||
Colour::Colour( Colour&& _other ) { const_cast<Colour&>( _other ).m_moved = true; }
|
||||
Colour& Colour::operator=( Colour&& _other ) {
|
||||
m_moved = false;
|
||||
const_cast<Colour&>( _other ).m_moved = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Colour::~Colour(){ if( !m_moved ) use( None ); }
|
||||
|
||||
void Colour::use( Code _colourCode ) {
|
||||
|
@@ -50,14 +50,15 @@ namespace Catch {
|
||||
|
||||
// Use constructed object for RAII guard
|
||||
Colour( Code _colourCode );
|
||||
Colour( Colour const& other );
|
||||
Colour( Colour&& other );
|
||||
Colour& operator=( Colour&& other );
|
||||
~Colour();
|
||||
|
||||
// Use static method for one-shot changes
|
||||
static void use( Code _colourCode );
|
||||
|
||||
private:
|
||||
bool m_moved;
|
||||
bool m_moved = false;
|
||||
};
|
||||
|
||||
std::ostream& operator << ( std::ostream& os, Colour const& );
|
||||
|
@@ -27,7 +27,8 @@ class ExpressionLhs : public DecomposedExpression {
|
||||
public:
|
||||
ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
|
||||
|
||||
ExpressionLhs& operator = ( const ExpressionLhs& );
|
||||
ExpressionLhs( ExpressionLhs const& ) = default;
|
||||
ExpressionLhs& operator = ( const ExpressionLhs& ) = delete;
|
||||
|
||||
template<typename RhsT>
|
||||
BinaryExpression<T, Internal::IsEqualTo, RhsT const&>
|
||||
@@ -107,7 +108,8 @@ public:
|
||||
BinaryExpression( ResultBuilder& rb, LhsT lhs, RhsT rhs )
|
||||
: m_rb( rb ), m_lhs( lhs ), m_rhs( rhs ) {}
|
||||
|
||||
BinaryExpression& operator = ( BinaryExpression& );
|
||||
BinaryExpression( BinaryExpression const& ) = default;
|
||||
BinaryExpression& operator = ( BinaryExpression const& ) = delete;
|
||||
|
||||
void endExpression() const {
|
||||
m_rb
|
||||
|
@@ -58,7 +58,6 @@ namespace Catch {
|
||||
IRunner::~IRunner() {}
|
||||
IMutableContext::~IMutableContext() {}
|
||||
IConfig::~IConfig() {}
|
||||
Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {}
|
||||
|
||||
void Config::dummy() {}
|
||||
}
|
||||
|
26
include/internal/catch_matchers.cpp
Normal file
26
include/internal/catch_matchers.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Created by Phil Nash on 19/07/2017.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include "catch_matchers.hpp"
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
namespace Impl {
|
||||
|
||||
std::string MatcherUntypedBase::toString() const {
|
||||
if( m_cachedToString.empty() )
|
||||
m_cachedToString = describe();
|
||||
return m_cachedToString;
|
||||
}
|
||||
|
||||
} // namespace Impl
|
||||
} // namespace Matchers
|
||||
|
||||
using namespace Matchers;
|
||||
using Matchers::Impl::MatcherBase;
|
||||
|
||||
} // namespace Catch
|
@@ -22,18 +22,15 @@ namespace Matchers {
|
||||
|
||||
class MatcherUntypedBase {
|
||||
public:
|
||||
std::string toString() const {
|
||||
if( m_cachedToString.empty() )
|
||||
m_cachedToString = describe();
|
||||
return m_cachedToString;
|
||||
}
|
||||
MatcherUntypedBase() = default;
|
||||
MatcherUntypedBase ( MatcherUntypedBase const& ) = default;
|
||||
MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete;
|
||||
std::string toString() const;
|
||||
|
||||
protected:
|
||||
virtual ~MatcherUntypedBase();
|
||||
virtual ~MatcherUntypedBase() = default;
|
||||
virtual std::string describe() const = 0;
|
||||
mutable std::string m_cachedToString;
|
||||
private:
|
||||
MatcherUntypedBase& operator = ( MatcherUntypedBase const& );
|
||||
};
|
||||
|
||||
template<typename ObjectT>
|
||||
|
@@ -48,9 +48,6 @@ namespace Catch {
|
||||
m_info.message = builder.m_stream.str();
|
||||
getResultCapture().pushScopedMessage( m_info );
|
||||
}
|
||||
ScopedMessage::ScopedMessage( ScopedMessage const& other )
|
||||
: m_info( other.m_info )
|
||||
{}
|
||||
|
||||
ScopedMessage::~ScopedMessage() {
|
||||
if ( !std::uncaught_exception() ){
|
||||
|
@@ -49,7 +49,6 @@ namespace Catch {
|
||||
class ScopedMessage {
|
||||
public:
|
||||
ScopedMessage( MessageBuilder const& builder );
|
||||
ScopedMessage( ScopedMessage const& other );
|
||||
~ScopedMessage();
|
||||
|
||||
MessageInfo m_info;
|
||||
|
@@ -16,9 +16,8 @@ namespace Catch {
|
||||
{
|
||||
public:
|
||||
NotImplementedException( SourceLineInfo const& lineInfo );
|
||||
NotImplementedException( NotImplementedException const& ) {}
|
||||
|
||||
virtual ~NotImplementedException() noexcept {}
|
||||
virtual ~NotImplementedException() noexcept = default;
|
||||
|
||||
virtual const char* what() const noexcept;
|
||||
|
||||
|
@@ -20,14 +20,14 @@ namespace Catch {
|
||||
|
||||
class TestSpecParser {
|
||||
enum Mode{ None, Name, QuotedName, Tag, EscapedName };
|
||||
Mode m_mode;
|
||||
bool m_exclusion;
|
||||
std::size_t m_start, m_pos;
|
||||
Mode m_mode = None;
|
||||
bool m_exclusion = false;
|
||||
std::size_t m_start = std::string::npos, m_pos = 0;
|
||||
std::string m_arg;
|
||||
std::vector<std::size_t> m_escapeChars;
|
||||
TestSpec::Filter m_currentFilter;
|
||||
TestSpec m_testSpec;
|
||||
ITagAliasRegistry const* m_tagAliases;
|
||||
ITagAliasRegistry const* m_tagAliases = nullptr;
|
||||
|
||||
public:
|
||||
TestSpecParser( ITagAliasRegistry const& tagAliases );
|
||||
|
@@ -36,7 +36,7 @@ namespace Catch {
|
||||
return os;
|
||||
}
|
||||
|
||||
Version libraryVersion() {
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 0, 0, "develop", 1 );
|
||||
return version;
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ namespace Catch {
|
||||
|
||||
// Versioning information
|
||||
struct Version {
|
||||
Version( Version const& ) = delete;
|
||||
Version& operator=( Version const& ) = delete;
|
||||
Version( unsigned int _majorVersion,
|
||||
unsigned int _minorVersion,
|
||||
unsigned int _patchNumber,
|
||||
@@ -29,12 +31,9 @@ namespace Catch {
|
||||
unsigned int const buildNumber;
|
||||
|
||||
friend std::ostream& operator << ( std::ostream& os, Version const& version );
|
||||
|
||||
private:
|
||||
void operator=( Version const& );
|
||||
};
|
||||
|
||||
Version libraryVersion();
|
||||
Version const& libraryVersion();
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
||||
|
@@ -65,10 +65,19 @@ namespace Catch {
|
||||
: m_writer( writer )
|
||||
{}
|
||||
|
||||
XmlWriter::ScopedElement::ScopedElement( ScopedElement const& other )
|
||||
XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other )
|
||||
: m_writer( other.m_writer ){
|
||||
other.m_writer = nullptr;
|
||||
}
|
||||
XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) {
|
||||
if ( m_writer ) {
|
||||
m_writer->endElement();
|
||||
}
|
||||
m_writer = other.m_writer;
|
||||
other.m_writer = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
XmlWriter::ScopedElement::~ScopedElement() {
|
||||
if( m_writer )
|
||||
|
@@ -38,7 +38,8 @@ namespace Catch {
|
||||
public:
|
||||
ScopedElement( XmlWriter* writer );
|
||||
|
||||
ScopedElement( ScopedElement const& other );
|
||||
ScopedElement( ScopedElement&& other );
|
||||
ScopedElement& operator=( ScopedElement&& other );
|
||||
|
||||
~ScopedElement();
|
||||
|
||||
@@ -51,7 +52,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
private:
|
||||
mutable XmlWriter* m_writer;
|
||||
mutable XmlWriter* m_writer = nullptr;
|
||||
};
|
||||
|
||||
XmlWriter( std::ostream& os = Catch::cout() );
|
||||
|
@@ -68,8 +68,9 @@ namespace Catch {
|
||||
|
||||
private:
|
||||
class AssertionPrinter {
|
||||
void operator= ( AssertionPrinter const& );
|
||||
public:
|
||||
AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
|
||||
: stream( _stream )
|
||||
, stats( _stats )
|
||||
|
@@ -97,8 +97,9 @@ namespace Catch {
|
||||
private:
|
||||
|
||||
class AssertionPrinter {
|
||||
void operator= ( AssertionPrinter const& );
|
||||
public:
|
||||
AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
|
||||
: stream( _stream ),
|
||||
stats( _stats ),
|
||||
|
@@ -61,8 +61,9 @@ namespace Catch {
|
||||
private:
|
||||
size_t counter = 0;
|
||||
class AssertionPrinter {
|
||||
void operator= ( AssertionPrinter const& );
|
||||
public:
|
||||
AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( AssertionPrinter const& ) = delete;
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, size_t counter )
|
||||
: stream( _stream )
|
||||
, stats( _stats )
|
||||
|
Reference in New Issue
Block a user