Some bits of tidy up

This commit is contained in:
Phil Nash 2017-12-07 00:02:19 +00:00
parent 584e04d480
commit 3035120dc7
7 changed files with 24 additions and 23 deletions

View File

@ -47,7 +47,7 @@
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( 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 &&. // 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 ) \ #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 // Although this is matcher-based, it can be used with just a string

View File

@ -59,7 +59,7 @@ namespace Catch {
class ScopedMessage { class ScopedMessage {
public: public:
ScopedMessage( MessageBuilder const& builder ); explicit ScopedMessage( MessageBuilder const& builder );
~ScopedMessage(); ~ScopedMessage();
MessageInfo m_info; MessageInfo m_info;

View File

@ -29,7 +29,7 @@ namespace Catch {
public: public:
ReporterRegistrar( std::string const& name ) { explicit ReporterRegistrar( std::string const& name ) {
getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() ); getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
} }
}; };

View File

@ -210,7 +210,7 @@ class Duration {
Unit m_units; Unit m_units;
public: public:
Duration(uint64_t inNanoseconds, Unit units = Unit::Auto) explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)
: m_inNanoseconds(inNanoseconds), : m_inNanoseconds(inNanoseconds),
m_units(units) { m_units(units) {
if (m_units == Unit::Auto) { if (m_units == Unit::Auto) {
@ -273,9 +273,9 @@ class TablePrinter {
bool m_isOpen = false; bool m_isOpen = false;
public: public:
TablePrinter(std::ostream& os, std::vector<ColumnInfo> const& columnInfos) TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
: m_os(os), : m_os( os ),
m_columnInfos(columnInfos) {} m_columnInfos( std::move( columnInfos ) ) {}
auto columnInfos() const -> std::vector<ColumnInfo> const& { auto columnInfos() const -> std::vector<ColumnInfo> const& {
return m_columnInfos; return m_columnInfos;
@ -346,7 +346,8 @@ ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
{ "elapsed ns", 14, ColumnInfo::Right }, { "elapsed ns", 14, ColumnInfo::Right },
{ "average", 14, ColumnInfo::Right } { "average", 14, ColumnInfo::Right }
})) {} })) {}
ConsoleReporter::~ConsoleReporter() {} ConsoleReporter::~ConsoleReporter() = default;
std::string ConsoleReporter::getDescription() { std::string ConsoleReporter::getDescription() {
return "Reports test results as plain lines of text"; 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) { void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) {
lazyPrintWithoutClosingBenchmarkTable(); 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; bool firstLine = true;
for (auto line : nameCol) { for (auto line : nameCol) {
@ -528,10 +529,10 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t
struct SummaryColumn { struct SummaryColumn {
SummaryColumn(std::string const& _label, Colour::Code _colour) SummaryColumn( std::string _label, Colour::Code _colour )
: label(_label), : label( std::move( _label ) ),
colour(_colour) {} colour( _colour ) {}
SummaryColumn addRow(std::size_t count) { SummaryColumn addRow( std::size_t count ) {
ReusableStringStream rss; ReusableStringStream rss;
rss << count; rss << count;
std::string row = rss.str(); 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) { if (totals.testCases.total() == 0) {
stream << Colour(Colour::Warning) << "No tests ran\n"; stream << Colour(Colour::Warning) << "No tests ran\n";
} else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) {

View File

@ -26,7 +26,7 @@ namespace Catch {
m_reporterPrefs.shouldRedirectStdOut = true; m_reporterPrefs.shouldRedirectStdOut = true;
} }
XmlReporter::~XmlReporter() {}; XmlReporter::~XmlReporter() = default;
std::string XmlReporter::getDescription() { std::string XmlReporter::getDescription() {
return "Reports test results as an XML document"; return "Reports test results as an XML document";

View File

@ -36,8 +36,8 @@ int thisDoesntThrow() {
class CustomException { class CustomException {
public: public:
CustomException( const std::string& msg ) explicit CustomException( const std::string& msg )
: m_msg( msg ) : m_msg( msg )
{} {}
std::string getMessage() const { std::string getMessage() const {
@ -50,10 +50,10 @@ private:
class CustomStdException : public std::exception { class CustomStdException : public std::exception {
public: public:
CustomStdException( const std::string& msg ) explicit CustomStdException( const std::string& msg )
: m_msg( msg ) : m_msg( msg )
{} {}
~CustomStdException() noexcept {} ~CustomStdException() noexcept override {}
std::string getMessage() const { std::string getMessage() const {
return m_msg; return m_msg;

View File

@ -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]" ) { 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 ); std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" ); CHECK( result == "\"wide load\"" );
} }
TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) { 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 ); std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" ); CHECK( result == "\"wide load\"" );
} }