A load more C++11 tweaks - mostly moving initialisations from constructors to inline
diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp
index 406c7ef..6657642 100644
--- a/include/internal/catch_approx.hpp
+++ b/include/internal/catch_approx.hpp
@@ -27,12 +27,7 @@
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 )
- {}
+ Approx( Approx const& other ) = default;
static Approx custom() {
return Approx( 0 );
diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h
index c729e8d..24ab4f6 100644
--- a/include/internal/catch_assertionresult.h
+++ b/include/internal/catch_assertionresult.h
@@ -53,11 +53,6 @@
struct AssertionResultData
{
- AssertionResultData() : decomposedExpression( nullptr )
- , resultType( ResultWas::Unknown )
- , negated( false )
- , parenthesized( false ) {}
-
void negate( bool parenthesize ) {
negated = !negated;
parenthesized = parenthesize;
@@ -82,12 +77,12 @@
return reconstructedExpression;
}
- mutable DecomposedExpression const* decomposedExpression;
+ mutable DecomposedExpression const* decomposedExpression = nullptr;
mutable std::string reconstructedExpression;
std::string message;
- ResultWas::OfType resultType;
- bool negated;
- bool parenthesized;
+ ResultWas::OfType resultType = ResultWas::Unknown;
+ bool negated = false;
+ bool parenthesized = false;
};
class AssertionResult {
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index 64141e7..24afda6 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -25,47 +25,26 @@
namespace Catch {
struct ConfigData {
+ bool listTests = false;
+ bool listTags = false;
+ bool listReporters = false;
+ bool listTestNamesOnly = false;
- ConfigData()
- : listTests( false ),
- listTags( false ),
- listReporters( false ),
- listTestNamesOnly( false ),
- showSuccessfulTests( false ),
- shouldDebugBreak( false ),
- noThrow( false ),
- showHelp( false ),
- showInvisibles( false ),
- filenamesAsTags( false ),
- abortAfter( -1 ),
- rngSeed( 0 ),
- verbosity( Verbosity::Normal ),
- warnings( WarnAbout::Nothing ),
- showDurations( ShowDurations::DefaultForReporter ),
- runOrder( RunTests::InDeclarationOrder ),
- useColour( UseColour::Auto )
- {}
+ bool showSuccessfulTests = false;
+ bool shouldDebugBreak = false;
+ bool noThrow = false;
+ bool showHelp = false;
+ bool showInvisibles = false;
+ bool filenamesAsTags = false;
- bool listTests;
- bool listTags;
- bool listReporters;
- bool listTestNamesOnly;
+ int abortAfter = -1;
+ unsigned int rngSeed = 0;
- bool showSuccessfulTests;
- bool shouldDebugBreak;
- bool noThrow;
- bool showHelp;
- bool showInvisibles;
- bool filenamesAsTags;
-
- int abortAfter;
- unsigned int rngSeed;
-
- Verbosity::Level verbosity;
- WarnAbout::What warnings;
- ShowDurations::OrNot showDurations;
- RunTests::InWhatOrder runOrder;
- UseColour::YesOrNo useColour;
+ Verbosity::Level verbosity = Verbosity::Normal;
+ WarnAbout::What warnings = WarnAbout::Nothing;
+ ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
+ RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
+ UseColour::YesOrNo useColour = UseColour::Auto;
std::string outputFilename;
std::string name;
diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context_impl.hpp
index 84f1ca1..b9488c6 100644
--- a/include/internal/catch_context_impl.hpp
+++ b/include/internal/catch_context_impl.hpp
@@ -16,11 +16,7 @@
namespace Catch {
- class Context : public IMutableContext {
-
- Context() : m_config( nullptr ), m_runner( nullptr ), m_resultCapture( nullptr ) {}
- Context( Context const& );
- void operator=( Context const& );
+ class Context : public IMutableContext, NonCopyable {
public:
virtual ~Context() {
@@ -84,8 +80,8 @@
private:
Ptr<IConfig const> m_config;
- IRunner* m_runner;
- IResultCapture* m_resultCapture;
+ IRunner* m_runner = nullptr;
+ IResultCapture* m_resultCapture = nullptr;
std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
};
diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp
index 8cf4140..756a07f 100644
--- a/include/internal/catch_expression_lhs.hpp
+++ b/include/internal/catch_expression_lhs.hpp
@@ -25,7 +25,7 @@
template<typename T>
class ExpressionLhs : public DecomposedExpression {
public:
- ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ), m_truthy(false) {}
+ ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
ExpressionLhs& operator = ( const ExpressionLhs& );
@@ -98,7 +98,7 @@
private:
ResultBuilder& m_rb;
T m_lhs;
- bool m_truthy;
+ bool m_truthy = false;
};
template<typename LhsT, Internal::Operator Op, typename RhsT>
diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp
index fc1cc91..f90767d 100644
--- a/include/internal/catch_list.hpp
+++ b/include/internal/catch_list.hpp
@@ -71,7 +71,6 @@
}
struct TagInfo {
- TagInfo() : count ( 0 ) {}
void add( std::string const& spelling ) {
++count;
spellings.insert( spelling );
@@ -83,7 +82,7 @@
return out;
}
std::set<std::string> spellings;
- std::size_t count;
+ std::size_t count = 0;
};
inline std::size_t listTags( Config const& config ) {
diff --git a/include/internal/catch_result_builder.h b/include/internal/catch_result_builder.h
index a2cf596..6548319 100644
--- a/include/internal/catch_result_builder.h
+++ b/include/internal/catch_result_builder.h
@@ -20,7 +20,7 @@
template<typename T> class ExpressionLhs;
struct CopyableStream {
- CopyableStream() {}
+ CopyableStream() = default;
CopyableStream( CopyableStream const& other ) {
oss << other.oss.str();
}
@@ -82,9 +82,9 @@
AssertionResultData m_data;
CopyableStream m_stream;
- bool m_shouldDebugBreak;
- bool m_shouldThrow;
- bool m_guardException;
+ bool m_shouldDebugBreak = false;
+ bool m_shouldThrow = false;
+ bool m_guardException = false;
};
} // namespace Catch
diff --git a/include/internal/catch_result_builder.hpp b/include/internal/catch_result_builder.hpp
index 2874c56..4eea95f 100644
--- a/include/internal/catch_result_builder.hpp
+++ b/include/internal/catch_result_builder.hpp
@@ -28,10 +28,7 @@
char const* capturedExpression,
ResultDisposition::Flags resultDisposition,
char const* secondArg )
- : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
- m_shouldDebugBreak( false ),
- m_shouldThrow( false ),
- m_guardException( false )
+ : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition )
{}
ResultBuilder::~ResultBuilder() {
diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp
index 12435cd..23c4654 100644
--- a/include/internal/catch_run_context.hpp
+++ b/include/internal/catch_run_context.hpp
@@ -62,10 +62,8 @@
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( _config->name() ),
m_context( getCurrentMutableContext() ),
- m_activeTestCase( nullptr ),
m_config( _config ),
- m_reporter( reporter ),
- m_shouldReportUnexpected ( true )
+ m_reporter( reporter )
{
m_context.setRunner( this );
m_context.setConfig( m_config );
@@ -350,7 +348,7 @@
TestRunInfo m_runInfo;
IMutableContext& m_context;
- TestCase const* m_activeTestCase;
+ TestCase const* m_activeTestCase = nullptr;
ITracker* m_testCaseTracker;
ITracker* m_currentSectionTracker;
AssertionResult m_lastResult;
@@ -363,7 +361,7 @@
std::vector<SectionEndInfo> m_unfinishedSections;
std::vector<ITracker*> m_activeSections;
TrackerContext m_trackerContext;
- bool m_shouldReportUnexpected;
+ bool m_shouldReportUnexpected = true;
};
IResultCapture& getResultCapture() {
diff --git a/include/internal/catch_section.h b/include/internal/catch_section.h
index 2667b74..e3b1456 100644
--- a/include/internal/catch_section.h
+++ b/include/internal/catch_section.h
@@ -22,7 +22,7 @@
~Section();
// This indicates whether the section should be executed or not
- operator bool() const;
+ explicit operator bool() const;
private:
SectionInfo m_info;
diff --git a/include/internal/catch_suppress_warnings.h b/include/internal/catch_suppress_warnings.h
index ad40592..65ed6a6 100644
--- a/include/internal/catch_suppress_warnings.h
+++ b/include/internal/catch_suppress_warnings.h
@@ -16,8 +16,6 @@
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
-# pragma clang diagnostic ignored "-Wc++98-compat"
-# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
# pragma clang diagnostic ignored "-Wswitch-enum"
# pragma clang diagnostic ignored "-Wcovered-switch-default"
# endif
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index 5900d6f..e5b1f28 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -91,10 +91,6 @@
class TestRegistry : public ITestCaseRegistry {
public:
- TestRegistry()
- : m_currentSortOrder( RunTests::InDeclarationOrder ),
- m_unnamedCount( 0 )
- {}
virtual ~TestRegistry();
virtual void registerTest( TestCase const& testCase ) {
@@ -123,9 +119,9 @@
private:
std::vector<TestCase> m_functions;
- mutable RunTests::InWhatOrder m_currentSortOrder;
+ mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
mutable std::vector<TestCase> m_sortedFunctions;
- size_t m_unnamedCount;
+ size_t m_unnamedCount = 0;
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
};
diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp
index 6654734..6da8ff5 100644
--- a/include/internal/catch_test_case_tracker.hpp
+++ b/include/internal/catch_test_case_tracker.hpp
@@ -69,8 +69,8 @@
};
Ptr<ITracker> m_rootTracker;
- ITracker* m_currentTracker;
- RunState m_runState;
+ ITracker* m_currentTracker = nullptr;
+ RunState m_runState = NotStarted;
public:
@@ -79,12 +79,6 @@
return s_instance;
}
- TrackerContext()
- : m_currentTracker( nullptr ),
- m_runState( NotStarted )
- {}
-
-
ITracker& startRun();
void endRun() {
@@ -137,13 +131,12 @@
TrackerContext& m_ctx;
ITracker* m_parent;
Children m_children;
- CycleState m_runState;
+ CycleState m_runState = NotStarted;
public:
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )
: m_nameAndLocation( nameAndLocation ),
m_ctx( ctx ),
- m_parent( parent ),
- m_runState( NotStarted )
+ m_parent( parent )
{}
virtual ~TrackerBase();
@@ -302,12 +295,11 @@
class IndexTracker : public TrackerBase {
int m_size;
- int m_index;
+ int m_index = -1;
public:
IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size )
: TrackerBase( nameAndLocation, ctx, parent ),
- m_size( size ),
- m_index( -1 )
+ m_size( size )
{}
virtual ~IndexTracker();
diff --git a/include/internal/catch_timer.h b/include/internal/catch_timer.h
index 81b9fdb..60115c8 100644
--- a/include/internal/catch_timer.h
+++ b/include/internal/catch_timer.h
@@ -13,14 +13,13 @@
namespace Catch {
class Timer {
public:
- Timer() : m_microSeconds( 0 ) {}
void start();
unsigned int getElapsedMicroseconds() const;
unsigned int getElapsedMilliseconds() const;
double getElapsedSeconds() const;
private:
- uint64_t m_microSeconds;
+ uint64_t m_microSeconds = 0;
};
} // namespace Catch
diff --git a/include/internal/catch_totals.hpp b/include/internal/catch_totals.hpp
index 551e294..8c26263 100644
--- a/include/internal/catch_totals.hpp
+++ b/include/internal/catch_totals.hpp
@@ -13,8 +13,6 @@
namespace Catch {
struct Counts {
- Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
-
Counts operator - ( Counts const& other ) const {
Counts diff;
diff.passed = passed - other.passed;
@@ -39,9 +37,9 @@
return failed == 0;
}
- std::size_t passed;
- std::size_t failed;
- std::size_t failedButOk;
+ std::size_t passed = 0;
+ std::size_t failed = 0;
+ std::size_t failedButOk = 0;
};
struct Totals {
diff --git a/include/internal/catch_wildcard_pattern.hpp b/include/internal/catch_wildcard_pattern.hpp
index a922912..b9827b9 100644
--- a/include/internal/catch_wildcard_pattern.hpp
+++ b/include/internal/catch_wildcard_pattern.hpp
@@ -27,7 +27,6 @@
WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
: m_caseSensitivity( caseSensitivity ),
- m_wildcard( NoWildcard ),
m_pattern( adjustCase( pattern ) )
{
if( startsWith( m_pattern, '*' ) ) {
@@ -66,7 +65,7 @@
return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;
}
CaseSensitive::Choice m_caseSensitivity;
- WildcardPosition m_wildcard;
+ WildcardPosition m_wildcard = NoWildcard;
std::string m_pattern;
};
}
diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp
index b39a2fd..0b951c7 100644
--- a/include/internal/catch_xmlwriter.hpp
+++ b/include/internal/catch_xmlwriter.hpp
@@ -112,18 +112,7 @@
mutable XmlWriter* m_writer;
};
- XmlWriter()
- : m_tagIsOpen( false ),
- m_needsNewline( false ),
- m_os( Catch::cout() )
- {
- writeDeclaration();
- }
-
- XmlWriter( std::ostream& os )
- : m_tagIsOpen( false ),
- m_needsNewline( false ),
- m_os( os )
+ XmlWriter( std::ostream& os = Catch::cout() ) : m_os( os )
{
writeDeclaration();
}
@@ -233,8 +222,8 @@
}
}
- bool m_tagIsOpen;
- bool m_needsNewline;
+ bool m_tagIsOpen = false;
+ bool m_needsNewline = false;
std::vector<std::string> m_tags;
std::string m_indent;
std::ostream& m_os;
diff --git a/include/reporters/catch_reporter_compact.hpp b/include/reporters/catch_reporter_compact.hpp
index 3987d37..1579a60 100644
--- a/include/reporters/catch_reporter_compact.hpp
+++ b/include/reporters/catch_reporter_compact.hpp
@@ -17,9 +17,7 @@
struct CompactReporter : StreamingReporterBase {
- CompactReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config )
- {}
+ using StreamingReporterBase::StreamingReporterBase;
virtual ~CompactReporter();
diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index 29951fc..bbe38a8 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -20,10 +20,7 @@
struct ConsoleReporter : StreamingReporterBase {
- ConsoleReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config ),
- m_headerPrinted( false )
- {}
+ using StreamingReporterBase::StreamingReporterBase;
virtual ~ConsoleReporter() override;
static std::string getDescription() {
@@ -435,7 +432,7 @@
}
private:
- bool m_headerPrinted;
+ bool m_headerPrinted = false;
};
INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp
index acc5664..f5cbc47 100644
--- a/include/reporters/catch_reporter_junit.hpp
+++ b/include/reporters/catch_reporter_junit.hpp
@@ -51,8 +51,7 @@
public:
JunitReporter( ReporterConfig const& _config )
: CumulativeReporterBase( _config ),
- xml( _config.stream() ),
- m_okToFail( false )
+ xml( _config.stream() )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
@@ -233,7 +232,7 @@
std::ostringstream stdOutForSuite;
std::ostringstream stdErrForSuite;
unsigned int unexpectedExceptions;
- bool m_okToFail;
+ bool m_okToFail = false;
};
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
diff --git a/include/reporters/catch_reporter_tap.hpp b/include/reporters/catch_reporter_tap.hpp
index 8f8896a..b34acac 100644
--- a/include/reporters/catch_reporter_tap.hpp
+++ b/include/reporters/catch_reporter_tap.hpp
@@ -21,10 +21,7 @@
struct TAPReporter : StreamingReporterBase {
- TAPReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config ),
- counter(0)
- {}
+ using StreamingReporterBase::StreamingReporterBase;
virtual ~TAPReporter();
@@ -62,7 +59,7 @@
}
private:
- size_t counter;
+ size_t counter = 0;
class AssertionPrinter {
void operator= ( AssertionPrinter const& );
public:
diff --git a/include/reporters/catch_reporter_teamcity.hpp b/include/reporters/catch_reporter_teamcity.hpp
index ae2efd8..79f40f9 100644
--- a/include/reporters/catch_reporter_teamcity.hpp
+++ b/include/reporters/catch_reporter_teamcity.hpp
@@ -25,8 +25,7 @@
struct TeamCityReporter : StreamingReporterBase {
TeamCityReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config ),
- m_headerPrintedForThisSection( false )
+ : StreamingReporterBase( _config )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
@@ -198,7 +197,7 @@
.setInitialIndent( indent ) ) << "\n";
}
private:
- bool m_headerPrintedForThisSection;
+ bool m_headerPrintedForThisSection = false;
};
#ifdef CATCH_IMPL
diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp
index cf26834..b99ec11 100644
--- a/include/reporters/catch_reporter_xml.hpp
+++ b/include/reporters/catch_reporter_xml.hpp
@@ -20,8 +20,7 @@
public:
XmlReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config ),
- m_xml(_config.stream()),
- m_sectionDepth( 0 )
+ m_xml(_config.stream())
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
@@ -219,7 +218,7 @@
private:
Timer m_testCaseTimer;
XmlWriter m_xml;
- int m_sectionDepth;
+ int m_sectionDepth = 0;
};
INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )