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 \
} 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

View File

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

View File

@ -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>() );
}
};

View File

@ -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()) {

View File

@ -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";

View File

@ -36,7 +36,7 @@ int thisDoesntThrow() {
class CustomException {
public:
CustomException( const std::string& msg )
explicit CustomException( const std::string& msg )
: m_msg( msg )
{}
@ -50,10 +50,10 @@ private:
class CustomStdException : public std::exception {
public:
CustomStdException( const std::string& msg )
explicit CustomStdException( const std::string& msg )
: m_msg( msg )
{}
~CustomStdException() noexcept {}
~CustomStdException() noexcept override {}
std::string getMessage() const {
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]" ) {
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\"" );
}