From c390c4cb9f9ae384451a5b8cda08aebf34407207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 26 Jan 2017 23:13:12 +0100 Subject: [PATCH] Fixed inconsistent and trailing whitespace This means that all tabs used in indentation are now 4 spaces and that there should be no more trailing whitespace. Ill also look into creating a pre-commit hook that will prevent this from happening in the future. Fixes #105 --- include/internal/catch_commandline.hpp | 4 +-- include/internal/catch_fatal_condition.hpp | 10 +++--- include/internal/catch_interfaces_config.h | 2 +- include/internal/catch_interfaces_reporter.h | 2 +- include/internal/catch_test_case_tracker.hpp | 8 ++--- include/internal/catch_tostring.hpp | 4 +-- include/reporters/catch_reporter_bases.hpp | 4 +-- include/reporters/catch_reporter_multi.hpp | 4 +-- include/reporters/catch_reporter_xml.hpp | 2 +- projects/SelfTest/ApproxTests.cpp | 6 ++-- projects/SelfTest/BDDTests.cpp | 6 ++-- projects/SelfTest/ConditionTests.cpp | 34 +++++++++---------- projects/SelfTest/ExceptionTests.cpp | 30 ++++++++-------- projects/SelfTest/TestMain.cpp | 10 +++--- ...TrailingWhitespace.py => fixWhitespace.py} | 1 + 15 files changed, 64 insertions(+), 63 deletions(-) rename scripts/{fixTrailingWhitespace.py => fixWhitespace.py} (96%) diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index da189676..f1feb266 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -65,7 +65,7 @@ namespace Catch { } inline void setUseColour( ConfigData& config, std::string const& value ) { std::string mode = toLower( value ); - + if( mode == "yes" ) config.useColour = UseColour::Yes; else if( mode == "no" ) @@ -201,7 +201,7 @@ namespace Catch { cli["--force-colour"] .describe( "force colourised output (deprecated)" ) .bind( &forceColour ); - + cli["--use-colour"] .describe( "should output be colourised" ) .bind( &setUseColour, "yes|no" ); diff --git a/include/internal/catch_fatal_condition.hpp b/include/internal/catch_fatal_condition.hpp index f99c8f26..4910242e 100644 --- a/include/internal/catch_fatal_condition.hpp +++ b/include/internal/catch_fatal_condition.hpp @@ -111,7 +111,7 @@ namespace Catch { static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; static stack_t oldSigStack; static char altStackMem[SIGSTKSZ]; - + static void handleSignal( int sig ) { std::string name = ""; for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { @@ -141,8 +141,8 @@ namespace Catch { sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); } } - - + + ~FatalConditionHandler() { reset(); } @@ -158,12 +158,12 @@ namespace Catch { } } }; - + bool FatalConditionHandler::isSet = false; struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; stack_t FatalConditionHandler::oldSigStack = {}; char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; - + } // namespace Catch diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h index 768550b9..08226c88 100644 --- a/include/internal/catch_interfaces_config.h +++ b/include/internal/catch_interfaces_config.h @@ -41,7 +41,7 @@ namespace Catch { Auto, Yes, No - }; }; + }; }; class TestSpec; diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 98e2cd6a..3aebab98 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -248,7 +248,7 @@ namespace Catch virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - + virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; } }; diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index cda64291..5a866336 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -52,7 +52,7 @@ namespace TestCaseTracking { virtual void addChild( Ptr const& child ) = 0; virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) = 0; virtual void openChild() = 0; - + // Debug/ checking virtual bool isSectionTracker() const = 0; virtual bool isIndexTracker() const = 0; @@ -187,7 +187,7 @@ namespace TestCaseTracking { virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; } virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; } - + void open() { m_runState = Executing; moveToThis(); @@ -261,7 +261,7 @@ namespace TestCaseTracking { virtual ~SectionTracker(); virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; } - + static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { SectionTracker* section = CATCH_NULL; @@ -310,7 +310,7 @@ namespace TestCaseTracking { virtual ~IndexTracker(); virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; } - + static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { IndexTracker* tracker = CATCH_NULL; diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index 0c4ed62f..fe488eda 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -90,12 +90,12 @@ std::string toString( char* const value ) { std::string toString( const wchar_t* const value ) { - return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); + return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); } std::string toString( wchar_t* const value ) { - return Catch::toString( static_cast( value ) ); + return Catch::toString( static_cast( value ) ); } std::string toString( int value ) { diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index 0c13a16b..1469a9e1 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -108,12 +108,12 @@ namespace Catch { struct BySectionInfo { BySectionInfo( SectionInfo const& other ) : m_other( other ) {} - BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} + BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} bool operator() ( Ptr const& node ) const { return node->stats.sectionInfo.lineInfo == m_other.lineInfo; } private: - void operator=( BySectionInfo const& ); + void operator=( BySectionInfo const& ); SectionInfo const& m_other; }; diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp index 7fc08f69..0e06892f 100644 --- a/include/reporters/catch_reporter_multi.hpp +++ b/include/reporters/catch_reporter_multi.hpp @@ -118,11 +118,11 @@ public: // IStreamingReporter ++it ) (*it)->skipTest( testInfo ); } - + virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE { return this; } - + }; Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index 40465f33..c470ceb0 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -96,7 +96,7 @@ namespace Catch { if( assertionResult.hasExpression() ) { m_xml.startElement( "Expression" ) .writeAttribute( "success", assertionResult.succeeded() ) - .writeAttribute( "type", assertionResult.getTestMacroName() ) + .writeAttribute( "type", assertionResult.getTestMacroName() ) .writeAttribute( "filename", assertionResult.getSourceInfo().file ) .writeAttribute( "line", assertionResult.getSourceInfo().line ); diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp index 8a12858c..6b7cf44a 100644 --- a/projects/SelfTest/ApproxTests.cpp +++ b/projects/SelfTest/ApproxTests.cpp @@ -170,17 +170,17 @@ TEST_CASE REQUIRE(td != Approx(11.0)); REQUIRE(Approx(11.0) != td); - + REQUIRE(td <= Approx(10.0)); REQUIRE(td <= Approx(11.0)); REQUIRE(Approx(10.0) <= td); REQUIRE(Approx(9.0) <= td); - + REQUIRE(td >= Approx(9.0)); REQUIRE(td >= Approx(10.0)); REQUIRE(Approx(10.0) >= td); REQUIRE(Approx(11.0) >= td); - + } #endif diff --git a/projects/SelfTest/BDDTests.cpp b/projects/SelfTest/BDDTests.cpp index 2c8bc249..ed89bfbc 100644 --- a/projects/SelfTest/BDDTests.cpp +++ b/projects/SelfTest/BDDTests.cpp @@ -88,10 +88,10 @@ struct Fixture } SCENARIO_METHOD(Fixture, - "BDD tests requiring Fixtures to provide commonly-accessed data or methods", - "[bdd][fixtures]") { + "BDD tests requiring Fixtures to provide commonly-accessed data or methods", + "[bdd][fixtures]") { const int before(counter()); - GIVEN("No operations precede me") { + GIVEN("No operations precede me") { REQUIRE(before == 0); WHEN("We get the count") { const int after(counter()); diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp index b1d29106..f135198d 100644 --- a/projects/SelfTest/ConditionTests.cpp +++ b/projects/SelfTest/ConditionTests.cpp @@ -210,29 +210,29 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne TEST_CASE( "comparisons between int variables", "" ) { - long long_var = 1L; - unsigned char unsigned_char_var = 1; - unsigned short unsigned_short_var = 1; - unsigned int unsigned_int_var = 1; - unsigned long unsigned_long_var = 1L; + long long_var = 1L; + unsigned char unsigned_char_var = 1; + unsigned short unsigned_short_var = 1; + unsigned int unsigned_int_var = 1; + unsigned long unsigned_long_var = 1L; - REQUIRE( long_var == unsigned_char_var ); - REQUIRE( long_var == unsigned_short_var ); - REQUIRE( long_var == unsigned_int_var ); - REQUIRE( long_var == unsigned_long_var ); + REQUIRE( long_var == unsigned_char_var ); + REQUIRE( long_var == unsigned_short_var ); + REQUIRE( long_var == unsigned_int_var ); + REQUIRE( long_var == unsigned_long_var ); } TEST_CASE( "comparisons between const int variables", "" ) { - const unsigned char unsigned_char_var = 1; - const unsigned short unsigned_short_var = 1; - const unsigned int unsigned_int_var = 1; - const unsigned long unsigned_long_var = 1L; + const unsigned char unsigned_char_var = 1; + const unsigned short unsigned_short_var = 1; + const unsigned int unsigned_int_var = 1; + const unsigned long unsigned_long_var = 1L; - REQUIRE( unsigned_char_var == 1 ); - REQUIRE( unsigned_short_var == 1 ); - REQUIRE( unsigned_int_var == 1 ); - REQUIRE( unsigned_long_var == 1 ); + REQUIRE( unsigned_char_var == 1 ); + REQUIRE( unsigned_short_var == 1 ); + REQUIRE( unsigned_int_var == 1 ); + REQUIRE( unsigned_long_var == 1 ); } TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour", "" ) diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 4bcfb7ac..de8f6fa3 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -15,9 +15,9 @@ namespace { inline int thisThrows() { - if( Catch::alwaysTrue() ) - throw std::domain_error( "expected exception" ); - return 1; + if( Catch::alwaysTrue() ) + throw std::domain_error( "expected exception" ); + return 1; } int thisDoesntThrow() @@ -42,23 +42,23 @@ TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail t TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing][!throws]" ) { - if( Catch::alwaysTrue() ) - throw std::domain_error( "unexpected exception" ); + if( Catch::alwaysTrue() ) + throw std::domain_error( "unexpected exception" ); } TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing][!throws]" ) { CHECK( 1 == 1 ); - if( Catch::alwaysTrue() ) - throw std::domain_error( "unexpected exception" ); + if( Catch::alwaysTrue() ) + throw std::domain_error( "unexpected exception" ); } TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing][!throws]" ) { SECTION( "section name", "" ) { - if( Catch::alwaysTrue() ) - throw std::domain_error( "unexpected exception" ); + if( Catch::alwaysTrue() ) + throw std::domain_error( "unexpected exception" ); } } @@ -145,8 +145,8 @@ CATCH_TRANSLATE_EXCEPTION( double& ex ) TEST_CASE("Non-std exceptions can be translated", "[.][failing][!throws]" ) { - if( Catch::alwaysTrue() ) - throw CustomException( "custom exception" ); + if( Catch::alwaysTrue() ) + throw CustomException( "custom exception" ); } TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing][!throws]" ) @@ -156,8 +156,8 @@ TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing][!throw } inline void throwCustom() { - if( Catch::alwaysTrue() ) - throw CustomException( "custom exception - not std" ); + if( Catch::alwaysTrue() ) + throw CustomException( "custom exception - not std" ); } TEST_CASE( "Custom exceptions can be translated when testing for nothrow", "[.][failing][!throws]" ) @@ -173,8 +173,8 @@ TEST_CASE( "Custom exceptions can be translated when testing for throwing as som TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]" ) { - if( Catch::alwaysTrue() ) - throw double( 3.14 ); + if( Catch::alwaysTrue() ) + throw double( 3.14 ); } inline int thisFunctionNotImplemented( int ) { diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index db506688..2a1769c3 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -196,13 +196,13 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" } SECTION( "use-colour", "") { - + using Catch::UseColour; - + SECTION( "without option", "" ) { const char* argv[] = { "test" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.useColour == UseColour::Auto ); } @@ -216,14 +216,14 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION( "yes", "" ) { const char* argv[] = { "test", "--use-colour", "yes" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.useColour == UseColour::Yes ); } SECTION( "no", "" ) { const char* argv[] = { "test", "--use-colour", "no" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.useColour == UseColour::No ); } diff --git a/scripts/fixTrailingWhitespace.py b/scripts/fixWhitespace.py similarity index 96% rename from scripts/fixTrailingWhitespace.py rename to scripts/fixWhitespace.py index 6d8391bd..6f37c539 100644 --- a/scripts/fixTrailingWhitespace.py +++ b/scripts/fixWhitespace.py @@ -24,6 +24,7 @@ def fixFile( path ): changed = 0 for line in f: trimmed = line.rstrip() + "\n" + trimmed = trimmed.replace('\t', ' ') if trimmed != line: changed = changed +1 lines.append( trimmed )