Addressed Resharper-C++ warnings

See #958
This commit is contained in:
Martin Hořeňovský
2017-07-25 17:16:28 +02:00
parent b6f62af7d1
commit 1e59ccee41
25 changed files with 97 additions and 93 deletions

View File

@@ -17,6 +17,12 @@
#include <memory>
namespace Catch {
void prepareExpandedExpression(AssertionResult& result) {
if (result.isOk())
result.discardDecomposedExpression();
else
result.expandDecomposedExpression();
}
// Because formatting using c++ streams is stateful, drop down to C is required
// Alternatively we could use stringstream, but its performance is... not good.

View File

@@ -17,6 +17,7 @@
#include <memory>
namespace Catch {
void prepareExpandedExpression(AssertionResult& result);
// Returns double formatted as %.3f (format expected on output)
std::string getFormattedDuration( double duration );
@@ -230,13 +231,6 @@ namespace Catch {
void skipTest(TestCaseInfo const&) override {}
void prepareExpandedExpression(AssertionResult& result) const {
if (result.isOk())
result.discardDecomposedExpression();
else
result.expandDecomposedExpression();
}
IConfigPtr m_config;
std::ostream& stream;
std::vector<AssertionStats> m_assertions;

View File

@@ -11,6 +11,25 @@
#include "../internal/catch_reporter_registrars.hpp"
#include "../internal/catch_console_colour.hpp"
namespace {
#ifdef CATCH_PLATFORM_MAC
const char* failedString() { return "FAILED"; }
const char* passedString() { return "PASSED"; }
#else
const char* failedString() { return "failed"; }
const char* passedString() { return "passed"; }
#endif
// Colour::LightGrey
Catch::Colour::Code dimColour() { return Catch::Colour::FileName; }
std::string bothOrAll( std::size_t count ) {
return count == 1 ? std::string() :
count == 2 ? "both " : "all " ;
}
}
namespace Catch {
struct CompactReporter : StreamingReporterBase<CompactReporter> {
@@ -148,18 +167,6 @@ namespace Catch {
}
private:
// Colour::LightGrey
static Colour::Code dimColour() { return Colour::FileName; }
#ifdef CATCH_PLATFORM_MAC
static const char* failedString() { return "FAILED"; }
static const char* passedString() { return "PASSED"; }
#else
static const char* failedString() { return "failed"; }
static const char* passedString() { return "passed"; }
#endif
void printSourceInfo() const {
Colour colourGuard( Colour::FileName );
stream << result.getSourceInfo() << ':';
@@ -253,10 +260,6 @@ namespace Catch {
// - red: Failed N tests cases, failed M assertions.
// - green: Passed [both/all] N tests cases with M assertions.
std::string bothOrAll( std::size_t count ) const {
return count == 1 ? std::string() : count == 2 ? "both " : "all " ;
}
void printTotals( const Totals& totals ) const {
if( totals.testCases.total() == 0 ) {
stream << "No tests ran.";

View File

@@ -16,6 +16,22 @@
#include <cfloat>
#include <cstdio>
namespace {
std::size_t makeRatio( std::size_t number, std::size_t total ) {
std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
return ( ratio == 0 && number > 0 ) ? 1 : ratio;
}
std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
if( i > j && i > k )
return i;
else if( j > k )
return j;
else
return k;
}
}
namespace Catch {
struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
@@ -390,19 +406,6 @@ namespace Catch {
stream << '\n';
}
static std::size_t makeRatio( std::size_t number, std::size_t total ) {
std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
return ( ratio == 0 && number > 0 ) ? 1 : ratio;
}
static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
if( i > j && i > k )
return i;
else if( j > k )
return j;
else
return k;
}
void printTotalsDivider( Totals const& totals ) {
if( totals.testCases.total() > 0 ) {
std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() );

View File

@@ -187,7 +187,7 @@ namespace Catch {
// if string has a : in first line will set indent to follow it on
// subsequent lines
void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
std::size_t i = _string.find( ": " );
if( i != std::string::npos )
i+=2;