diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 406c7ef1..66576428 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -27,12 +27,7 @@ namespace Detail { 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 c729e8d0..24ab4f62 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -53,11 +53,6 @@ namespace Catch { struct AssertionResultData { - AssertionResultData() : decomposedExpression( nullptr ) - , resultType( ResultWas::Unknown ) - , negated( false ) - , parenthesized( false ) {} - void negate( bool parenthesize ) { negated = !negated; parenthesized = parenthesize; @@ -82,12 +77,12 @@ namespace Catch { 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 64141e7f..24afda6e 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 84f1ca1c..b9488c6e 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 @@ namespace Catch { private: Ptr m_config; - IRunner* m_runner; - IResultCapture* m_resultCapture; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; std::map m_generatorsByTestName; }; diff --git a/include/internal/catch_expression_lhs.hpp b/include/internal/catch_expression_lhs.hpp index 8cf41409..756a07f6 100644 --- a/include/internal/catch_expression_lhs.hpp +++ b/include/internal/catch_expression_lhs.hpp @@ -25,7 +25,7 @@ class MatchExpression; template 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: private: ResultBuilder& m_rb; T m_lhs; - bool m_truthy; + bool m_truthy = false; }; template diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index fc1cc91a..f90767d1 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -71,7 +71,6 @@ namespace Catch { } struct TagInfo { - TagInfo() : count ( 0 ) {} void add( std::string const& spelling ) { ++count; spellings.insert( spelling ); @@ -83,7 +82,7 @@ namespace Catch { return out; } std::set 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 a2cf596d..65483198 100644 --- a/include/internal/catch_result_builder.h +++ b/include/internal/catch_result_builder.h @@ -20,7 +20,7 @@ namespace Catch { template class ExpressionLhs; struct CopyableStream { - CopyableStream() {} + CopyableStream() = default; CopyableStream( CopyableStream const& other ) { oss << other.oss.str(); } @@ -82,9 +82,9 @@ namespace Catch { 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 2874c568..4eea95fe 100644 --- a/include/internal/catch_result_builder.hpp +++ b/include/internal/catch_result_builder.hpp @@ -28,10 +28,7 @@ namespace Catch { 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 12435cdc..23c4654a 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -62,10 +62,8 @@ namespace Catch { explicit RunContext( Ptr const& _config, Ptr 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 @@ namespace Catch { 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 @@ namespace Catch { std::vector m_unfinishedSections; std::vector 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 2667b74e..e3b14564 100644 --- a/include/internal/catch_section.h +++ b/include/internal/catch_section.h @@ -22,7 +22,7 @@ namespace Catch { ~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 ad405922..65ed6a62 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 5900d6f0..e5b1f281 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -91,10 +91,6 @@ namespace Catch { 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 @@ namespace Catch { private: std::vector m_functions; - mutable RunTests::InWhatOrder m_currentSortOrder; + mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder; mutable std::vector 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 6654734f..6da8ff53 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -69,8 +69,8 @@ namespace TestCaseTracking { }; Ptr m_rootTracker; - ITracker* m_currentTracker; - RunState m_runState; + ITracker* m_currentTracker = nullptr; + RunState m_runState = NotStarted; public: @@ -79,12 +79,6 @@ namespace TestCaseTracking { return s_instance; } - TrackerContext() - : m_currentTracker( nullptr ), - m_runState( NotStarted ) - {} - - ITracker& startRun(); void endRun() { @@ -137,13 +131,12 @@ namespace TestCaseTracking { 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 @@ namespace TestCaseTracking { 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 81b9fdb7..60115c80 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 551e2947..8c26263c 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 @@ namespace Catch { 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 a922912d..b9827b96 100644 --- a/include/internal/catch_wildcard_pattern.hpp +++ b/include/internal/catch_wildcard_pattern.hpp @@ -27,7 +27,6 @@ namespace Catch 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 @@ namespace Catch 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 b39a2fd7..0b951c71 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -112,18 +112,7 @@ namespace Catch { 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 @@ namespace Catch { } } - bool m_tagIsOpen; - bool m_needsNewline; + bool m_tagIsOpen = false; + bool m_needsNewline = false; std::vector 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 3987d37c..1579a608 100644 --- a/include/reporters/catch_reporter_compact.hpp +++ b/include/reporters/catch_reporter_compact.hpp @@ -17,9 +17,7 @@ namespace Catch { 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 29951fcf..bbe38a87 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -20,10 +20,7 @@ namespace Catch { 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 @@ namespace Catch { } 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 acc5664c..f5cbc47d 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -51,8 +51,7 @@ namespace Catch { public: JunitReporter( ReporterConfig const& _config ) : CumulativeReporterBase( _config ), - xml( _config.stream() ), - m_okToFail( false ) + xml( _config.stream() ) { m_reporterPrefs.shouldRedirectStdOut = true; } @@ -233,7 +232,7 @@ namespace Catch { 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 8f8896a6..b34acac3 100644 --- a/include/reporters/catch_reporter_tap.hpp +++ b/include/reporters/catch_reporter_tap.hpp @@ -21,10 +21,7 @@ namespace Catch { struct TAPReporter : StreamingReporterBase { - TAPReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - counter(0) - {} + using StreamingReporterBase::StreamingReporterBase; virtual ~TAPReporter(); @@ -62,7 +59,7 @@ namespace Catch { } 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 ae2efd88..79f40f92 100644 --- a/include/reporters/catch_reporter_teamcity.hpp +++ b/include/reporters/catch_reporter_teamcity.hpp @@ -25,8 +25,7 @@ namespace Catch { struct TeamCityReporter : StreamingReporterBase { TeamCityReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_headerPrintedForThisSection( false ) + : StreamingReporterBase( _config ) { m_reporterPrefs.shouldRedirectStdOut = true; } @@ -198,7 +197,7 @@ namespace Catch { .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 cf26834f..b99ec11f 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -20,8 +20,7 @@ namespace Catch { 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 @@ namespace Catch { private: Timer m_testCaseTimer; XmlWriter m_xml; - int m_sectionDepth; + int m_sectionDepth = 0; }; INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )