Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Some bits of tidy up

Commit
3035120dc7163f2b93cbcf645246ae7c833947ad
Author
Phil Nash ·
Parents
584e04d48076

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp               |  4 ++--
 include/internal/catch_message.h                 |  2 +-
 include/internal/catch_reporter_registrars.hpp   |  2 +-
 include/reporters/catch_reporter_console.cpp     | 23 ++++++++++++-----------
 include/reporters/catch_reporter_xml.cpp         |  2 +-
 projects/SelfTest/UsageTests/Exception.tests.cpp | 10 +++++-----
 projects/SelfTest/UsageTests/Misc.tests.cpp      |  4 ++--
 7 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index ce812ada..e4600f7c 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -47,7 +47,7 @@
             CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
         } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
         INTERNAL_CATCH_REACT( catchAssertionHandler ) \
-    } while( (void)0, 0 && static_cast<bool>( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look
+    } while( (void)0, false && static_cast<bool>( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look
     // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -122,7 +122,7 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CATCH_INFO( macroName, log ) \
-    Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
+    Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log );
 
 ///////////////////////////////////////////////////////////////////////////////
 // Although this is matcher-based, it can be used with just a string
diff --git a/include/internal/catch_message.h b/include/internal/catch_message.h
index 9000fbd9..0a512ed5 100644
--- a/include/internal/catch_message.h
+++ b/include/internal/catch_message.h
@@ -59,7 +59,7 @@ namespace Catch {
 
     class ScopedMessage {
     public:
-        ScopedMessage( MessageBuilder const& builder );
+        explicit ScopedMessage( MessageBuilder const& builder );
         ~ScopedMessage();
 
         MessageInfo m_info;
diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp
index ce88fa34..943fba65 100644
--- a/include/internal/catch_reporter_registrars.hpp
+++ b/include/internal/catch_reporter_registrars.hpp
@@ -29,7 +29,7 @@ namespace Catch {
 
     public:
 
-        ReporterRegistrar( std::string const& name ) {
+        explicit ReporterRegistrar( std::string const& name ) {
             getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
         }
     };
diff --git a/include/reporters/catch_reporter_console.cpp b/include/reporters/catch_reporter_console.cpp
index 74d2f19d..54b62cd8 100644
--- a/include/reporters/catch_reporter_console.cpp
+++ b/include/reporters/catch_reporter_console.cpp
@@ -210,7 +210,7 @@ class Duration {
     Unit m_units;
 
 public:
-    Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)
+    explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)
         : m_inNanoseconds(inNanoseconds),
         m_units(units) {
         if (m_units == Unit::Auto) {
@@ -273,9 +273,9 @@ class TablePrinter {
     bool m_isOpen = false;
 
 public:
-    TablePrinter(std::ostream& os, std::vector<ColumnInfo> const& columnInfos)
-        : m_os(os),
-        m_columnInfos(columnInfos) {}
+    TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
+    :   m_os( os ),
+        m_columnInfos( std::move( columnInfos ) ) {}
 
     auto columnInfos() const -> std::vector<ColumnInfo> const& {
         return m_columnInfos;
@@ -346,7 +346,8 @@ ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
         { "elapsed ns", 14, ColumnInfo::Right },
         { "average", 14, ColumnInfo::Right }
     })) {}
-ConsoleReporter::~ConsoleReporter() {}
+ConsoleReporter::~ConsoleReporter() = default;
+
 std::string ConsoleReporter::getDescription() {
     return "Reports test results as plain lines of text";
 }
@@ -402,7 +403,7 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
 void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) {
     lazyPrintWithoutClosingBenchmarkTable();
 
-    auto nameCol = Column(info.name).width(m_tablePrinter->columnInfos()[0].width - 2);
+    auto nameCol = Column( info.name ).width( static_cast<std::size_t>( m_tablePrinter->columnInfos()[0].width - 2 ) );
 
     bool firstLine = true;
     for (auto line : nameCol) {
@@ -528,10 +529,10 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t
 
 struct SummaryColumn {
 
-    SummaryColumn(std::string const& _label, Colour::Code _colour)
-        : label(_label),
-        colour(_colour) {}
-    SummaryColumn addRow(std::size_t count) {
+    SummaryColumn( std::string _label, Colour::Code _colour )
+    :   label( std::move( _label ) ),
+        colour( _colour ) {}
+    SummaryColumn addRow( std::size_t count ) {
         ReusableStringStream rss;
         rss << count;
         std::string row = rss.str();
@@ -551,7 +552,7 @@ struct SummaryColumn {
 
 };
 
-void ConsoleReporter::printTotals(Totals const& totals) {
+void ConsoleReporter::printTotals( Totals const& totals ) {
     if (totals.testCases.total() == 0) {
         stream << Colour(Colour::Warning) << "No tests ran\n";
     } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) {
diff --git a/include/reporters/catch_reporter_xml.cpp b/include/reporters/catch_reporter_xml.cpp
index 18da6b66..b721d449 100644
--- a/include/reporters/catch_reporter_xml.cpp
+++ b/include/reporters/catch_reporter_xml.cpp
@@ -26,7 +26,7 @@ namespace Catch {
         m_reporterPrefs.shouldRedirectStdOut = true;
     }
 
-    XmlReporter::~XmlReporter() {};
+    XmlReporter::~XmlReporter() = default;
 
     std::string XmlReporter::getDescription() {
         return "Reports test results as an XML document";
diff --git a/projects/SelfTest/UsageTests/Exception.tests.cpp b/projects/SelfTest/UsageTests/Exception.tests.cpp
index b9a9ef36..d67ef34c 100644
--- a/projects/SelfTest/UsageTests/Exception.tests.cpp
+++ b/projects/SelfTest/UsageTests/Exception.tests.cpp
@@ -36,8 +36,8 @@ int thisDoesntThrow() {
 
 class CustomException {
 public:
-    CustomException( const std::string& msg )
-            : m_msg( msg )
+    explicit CustomException( const std::string& msg )
+    : m_msg( msg )
     {}
 
     std::string getMessage() const {
@@ -50,10 +50,10 @@ private:
 
 class CustomStdException : public std::exception {
 public:
-    CustomStdException( const std::string& msg )
-            : m_msg( msg )
+    explicit CustomStdException( const std::string& msg )
+    : m_msg( msg )
     {}
-    ~CustomStdException() noexcept {}
+    ~CustomStdException() noexcept override {}
 
     std::string getMessage() const {
         return m_msg;
diff --git a/projects/SelfTest/UsageTests/Misc.tests.cpp b/projects/SelfTest/UsageTests/Misc.tests.cpp
index c2c08536..757a99b5 100644
--- a/projects/SelfTest/UsageTests/Misc.tests.cpp
+++ b/projects/SelfTest/UsageTests/Misc.tests.cpp
@@ -303,13 +303,13 @@ TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[to
 }
 
 TEST_CASE( "toString on wchar_t const pointer returns the string contents", "[toString]" ) {
-        wchar_t * const s = const_cast<wchar_t* const>( L"wide load" );
+        auto const s = const_cast<wchar_t* const>( L"wide load" );
         std::string result = ::Catch::Detail::stringify( s );
         CHECK( result == "\"wide load\"" );
 }
 
 TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
-        wchar_t * s = const_cast<wchar_t*>( L"wide load" );
+        auto s = const_cast<wchar_t*>( L"wide load" );
         std::string result = ::Catch::Detail::stringify( s );
         CHECK( result == "\"wide load\"" );
 }