From e91738103ce8dc6c0ca6c096c66b79d25f3c18d6 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 4 Nov 2015 18:01:28 +0000 Subject: [PATCH] Stripped trailing whitespace from all source code lines (replaces need for PRs #310 and #504) --- include/catch_session.hpp | 22 ++-- include/internal/catch_commandline.hpp | 4 +- include/internal/catch_common.h | 6 +- include/internal/catch_common.hpp | 4 +- include/internal/catch_config.hpp | 2 +- include/internal/catch_evaluate.hpp | 6 +- include/internal/catch_impl.hpp | 2 +- include/internal/catch_interfaces_reporter.h | 6 +- include/internal/catch_interfaces_testcase.h | 2 +- include/internal/catch_matchers.hpp | 6 +- .../internal/catch_reporter_registrars.hpp | 10 +- include/internal/catch_result_builder.h | 2 +- include/internal/catch_result_builder.hpp | 6 +- include/internal/catch_result_type.h | 2 +- include/internal/catch_run_context.hpp | 18 +-- include/internal/catch_section_info.h | 6 +- include/internal/catch_stream.h | 6 +- include/internal/catch_stream.hpp | 16 +-- include/internal/catch_test_case_info.h | 4 +- include/internal/catch_test_case_info.hpp | 6 +- .../catch_test_case_registry_impl.hpp | 10 +- include/internal/catch_test_case_tracker.hpp | 86 +++++++------- include/internal/catch_test_spec.hpp | 6 +- include/internal/catch_tostring.h | 4 +- include/internal/catch_tostring.hpp | 4 +- include/internal/catch_version.h | 2 +- include/internal/catch_wildcard_pattern.hpp | 6 +- include/internal/catch_xmlwriter.hpp | 16 +-- include/reporters/catch_reporter_bases.hpp | 6 +- include/reporters/catch_reporter_junit.hpp | 8 +- include/reporters/catch_reporter_multi.hpp | 26 ++--- include/reporters/catch_reporter_teamcity.hpp | 40 +++---- include/reporters/catch_reporter_xml.hpp | 10 +- projects/SelfTest/ApproxTests.cpp | 12 +- projects/SelfTest/BDDTests.cpp | 14 +-- projects/SelfTest/ClassTests.cpp | 18 +-- projects/SelfTest/ConditionTests.cpp | 52 ++++----- projects/SelfTest/ExceptionTests.cpp | 4 +- projects/SelfTest/GeneratorTests.cpp | 12 +- projects/SelfTest/MessageTests.cpp | 4 +- projects/SelfTest/MiscTests.cpp | 44 ++++---- projects/SelfTest/PartTrackerTests.cpp | 106 +++++++++--------- projects/SelfTest/TestMain.cpp | 62 +++++----- projects/SelfTest/TrickyTests.cpp | 50 ++++----- .../internal/iTchRunnerAppDelegate.h | 26 ++--- .../iTchRunner/internal/iTchRunnerMainView.h | 10 +- .../iTchRunner/internal/iTchRunnerReporter.h | 22 ++-- 47 files changed, 398 insertions(+), 398 deletions(-) diff --git a/include/catch_session.hpp b/include/catch_session.hpp index c63f517b..1b1cba54 100644 --- a/include/catch_session.hpp +++ b/include/catch_session.hpp @@ -30,7 +30,7 @@ namespace Catch { } return reporter; } - + Ptr makeReporter( Ptr const& config ) { std::vector reporters = config->getReporterNames(); if( reporters.empty() ) @@ -40,7 +40,7 @@ namespace Catch { for( std::vector::const_iterator it = reporters.begin(), itEnd = reporters.end(); it != itEnd; ++it ) - reporter = addReporter( reporter, createReporter( *it, config ) ); + reporter = addReporter( reporter, createReporter( *it, config ) ); return reporter; } Ptr addListeners( Ptr const& config, Ptr reporters ) { @@ -51,15 +51,15 @@ namespace Catch { reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) ); return reporters; } - - + + Totals runTests( Ptr const& config ) { Ptr iconfig = config.get(); - + Ptr reporter = makeReporter( config ); reporter = addListeners( iconfig, reporter ); - + RunContext context( iconfig, reporter ); Totals totals; @@ -83,13 +83,13 @@ namespace Catch { context.testGroupEnded( iconfig->name(), totals, 1, 1 ); return totals; } - + void applyFilenamesAsTags( IConfig const& config ) { std::vector const& tests = getAllTestCasesSorted( config ); for(std::size_t i = 0; i < tests.size(); ++i ) { TestCase& test = const_cast( tests[i] ); std::set tags = test.tags; - + std::string filename = test.lineInfo.file; std::string::size_type lastSlash = filename.find_last_of( "\\/" ); if( lastSlash != std::string::npos ) @@ -98,7 +98,7 @@ namespace Catch { std::string::size_type lastDot = filename.find_last_of( "." ); if( lastDot != std::string::npos ) filename = filename.substr( 0, lastDot ); - + tags.insert( "#" + filename ); setTags( test, tags ); } @@ -173,12 +173,12 @@ namespace Catch { try { config(); // Force config to be constructed - + seedRng( *m_config ); if( m_configData.filenamesAsTags ) applyFilenamesAsTags( *m_config ); - + // Handle list request if( Option listed = list( config() ) ) return static_cast( *listed ); diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index f2fce31b..640b304d 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -163,7 +163,7 @@ namespace Catch { .describe( "list all/matching test cases names only" ) .bind( &ConfigData::listTestNamesOnly ); - cli["--list-reporters"] + cli["--list-reporters"] .describe( "list all reporters" ) .bind( &ConfigData::listReporters ); @@ -178,7 +178,7 @@ namespace Catch { cli["--force-colour"] .describe( "force colourised output" ) .bind( &ConfigData::forceColour ); - + return cli; } diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 2ae79b18..7f9cfc44 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -22,14 +22,14 @@ #include "catch_compiler_capabilities.h" namespace Catch { - + struct IConfig; struct CaseSensitive { enum Choice { Yes, No }; }; - + class NonCopyable { #ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS NonCopyable( NonCopyable const& ) = delete; @@ -118,7 +118,7 @@ namespace Catch { void seedRng( IConfig const& config ); unsigned int rngSeed(); - + // Use this in variadic streaming macros to allow // >> +StreamEndStop // as well as diff --git a/include/internal/catch_common.hpp b/include/internal/catch_common.hpp index 69a64ad1..2342ae61 100644 --- a/include/internal/catch_common.hpp +++ b/include/internal/catch_common.hpp @@ -36,7 +36,7 @@ namespace Catch { return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; } - + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { bool replaced = false; std::size_t i = str.find( replaceThis ); @@ -50,7 +50,7 @@ namespace Catch { } return replaced; } - + pluralise::pluralise( std::size_t count, std::string const& label ) : m_count( count ), m_label( label ) diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index c0d0948e..a09210cb 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -136,7 +136,7 @@ namespace Catch { virtual bool forceColour() const { return m_data.forceColour; } private: - + IStream const* openStream() { if( m_data.outputFilename.empty() ) return new CoutStream(); diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index 76f19e2a..1d8ca93e 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -174,7 +174,7 @@ namespace Internal { template bool compare( long long lhs, unsigned char rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - + // unsigned long long to X template bool compare( unsigned long long lhs, int rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); @@ -188,7 +188,7 @@ namespace Internal { template bool compare( unsigned long long lhs, char rhs ) { return applyEvaluator( static_cast( lhs ), rhs ); } - + // pointer to long long (when comparing against NULL) template bool compare( long long lhs, T* rhs ) { return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); @@ -197,7 +197,7 @@ namespace Internal { return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); } #endif // CATCH_CONFIG_CPP11_LONG_LONG - + #ifdef CATCH_CONFIG_CPP11_NULLPTR // pointer to nullptr_t (when comparing against nullptr) template bool compare( std::nullptr_t, T* rhs ) { diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 74ac775e..53c89574 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -97,7 +97,7 @@ namespace Catch { Matchers::Impl::StdString::EndsWith::~EndsWith() {} void Config::dummy() {} - + namespace TestCaseTracking { ITracker::~ITracker() {} TrackerBase::~TrackerBase() {} diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index e40119df..d1c6e704 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -240,12 +240,12 @@ namespace Catch // The return value indicates if the messages buffer should be cleared: virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; }; @@ -267,7 +267,7 @@ namespace Catch }; Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ); - + } #endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h index 3ae412c5..a1052b71 100644 --- a/include/internal/catch_interfaces_testcase.h +++ b/include/internal/catch_interfaces_testcase.h @@ -34,7 +34,7 @@ namespace Catch { bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); std::vector const& getAllTestCasesSorted( IConfig const& config ); - + } #endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index 8b0783cc..fd9dfd2b 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -132,7 +132,7 @@ namespace Matchers { return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; - + } std::string toStringSuffix() const { @@ -143,7 +143,7 @@ namespace Matchers { CaseSensitive::Choice m_caseSensitivity; std::string m_str; }; - + struct Equals : MatcherImpl { Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) : m_data( str, caseSensitivity ) @@ -182,7 +182,7 @@ namespace Matchers { struct StartsWith : MatcherImpl { StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) : m_data( substr, caseSensitivity ){} - + StartsWith( StartsWith const& other ) : m_data( other.m_data ){} virtual ~StartsWith(); diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp index 0aed0823..7bd7b610 100644 --- a/include/internal/catch_reporter_registrars.hpp +++ b/include/internal/catch_reporter_registrars.hpp @@ -64,12 +64,12 @@ namespace Catch { getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); } }; - + template class ListenerRegistrar { - + class ListenerFactory : public SharedImpl { - + virtual IStreamingReporter* create( ReporterConfig const& config ) const { return new T( config ); } @@ -77,9 +77,9 @@ namespace Catch { return ""; } }; - + public: - + ListenerRegistrar() { getMutableRegistryHub().registerListener( new ListenerFactory() ); } diff --git a/include/internal/catch_result_builder.h b/include/internal/catch_result_builder.h index c27fe5c2..89002660 100644 --- a/include/internal/catch_result_builder.h +++ b/include/internal/catch_result_builder.h @@ -85,7 +85,7 @@ namespace Catch { std::string lhs, rhs, op; } m_exprComponents; CopyableStream m_stream; - + bool m_shouldDebugBreak; bool m_shouldThrow; }; diff --git a/include/internal/catch_result_builder.hpp b/include/internal/catch_result_builder.hpp index 5e2ba32b..d453fecf 100644 --- a/include/internal/catch_result_builder.hpp +++ b/include/internal/catch_result_builder.hpp @@ -77,12 +77,12 @@ namespace Catch { } void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher const& matcher ) { - + assert( m_exprComponents.testFalse == false ); AssertionResultData data = m_data; data.resultType = ResultWas::Ok; data.reconstructedExpression = m_assertionInfo.capturedExpression; - + std::string actualMessage = Catch::translateActiveException(); if( !matcher.match( actualMessage ) ) { data.resultType = ResultWas::ExpressionFailed; @@ -99,7 +99,7 @@ namespace Catch { void ResultBuilder::handleResult( AssertionResult const& result ) { getResultCapture().assertionEnded( result ); - + if( !result.isOk() ) { if( getCurrentContext().getConfig()->shouldDebugBreak() ) m_shouldDebugBreak = true; diff --git a/include/internal/catch_result_type.h b/include/internal/catch_result_type.h index beaff369..4c3d77dc 100644 --- a/include/internal/catch_result_type.h +++ b/include/internal/catch_result_type.h @@ -55,7 +55,7 @@ namespace Catch { inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED diff --git a/include/internal/catch_run_context.hpp b/include/internal/catch_run_context.hpp index 6ae67568..da5990ad 100644 --- a/include/internal/catch_run_context.hpp +++ b/include/internal/catch_run_context.hpp @@ -94,7 +94,7 @@ namespace Catch { m_reporter->testCaseStarting( testInfo ); m_activeTestCase = &testCase; - + do { m_trackerContext.startRun(); @@ -157,7 +157,7 @@ namespace Catch { if( !sectionTracker.isOpen() ) return false; m_activeSections.push_back( §ionTracker ); - + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; m_reporter->sectionStarting( sectionInfo ); @@ -177,16 +177,16 @@ namespace Catch { assertions.failed++; return true; } - + virtual void sectionEnded( SectionEndInfo const& endInfo ) { Counts assertions = m_totals.assertions - endInfo.prevAssertions; bool missingAssertions = testForMissingAssertions( assertions ); - + if( !m_activeSections.empty() ) { m_activeSections.back()->close(); m_activeSections.pop_back(); } - + m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) ); m_messages.clear(); } @@ -197,10 +197,10 @@ namespace Catch { else m_activeSections.back()->close(); m_activeSections.pop_back(); - + m_unfinishedSections.push_back( endInfo ); } - + virtual void pushScopedMessage( MessageInfo const& message ) { m_messages.push_back( message ); } @@ -268,7 +268,7 @@ namespace Catch { m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); seedRng( *m_config ); - + Timer timer; timer.start(); if( m_reporter->getPreferences().shouldRedirectStdOut ) { @@ -318,7 +318,7 @@ namespace Catch { m_lastAssertionInfo.capturedExpression.c_str(), m_lastAssertionInfo.resultDisposition ); } - + void handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. diff --git a/include/internal/catch_section_info.h b/include/internal/catch_section_info.h index e49ef638..00b65600 100644 --- a/include/internal/catch_section_info.h +++ b/include/internal/catch_section_info.h @@ -23,17 +23,17 @@ namespace Catch { std::string description; SourceLineInfo lineInfo; }; - + struct SectionEndInfo { SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ) : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) {} - + SectionInfo sectionInfo; Counts prevAssertions; double durationInSeconds; }; - + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED diff --git a/include/internal/catch_stream.h b/include/internal/catch_stream.h index 20acaff6..5f22ad67 100644 --- a/include/internal/catch_stream.h +++ b/include/internal/catch_stream.h @@ -21,7 +21,7 @@ namespace Catch { std::ostream& cout(); std::ostream& cerr(); - + struct IStream { virtual ~IStream() CATCH_NOEXCEPT; virtual std::ostream& stream() const = 0; @@ -35,7 +35,7 @@ namespace Catch { public: // IStream virtual std::ostream& stream() const CATCH_OVERRIDE; }; - + class CoutStream : public IStream { mutable std::ostream m_os; @@ -47,7 +47,7 @@ namespace Catch { virtual std::ostream& stream() const CATCH_OVERRIDE; }; - + class DebugOutStream : public IStream { std::auto_ptr m_streamBuf; mutable std::ostream m_os; diff --git a/include/internal/catch_stream.hpp b/include/internal/catch_stream.hpp index e6bf7b0c..afd52f39 100644 --- a/include/internal/catch_stream.hpp +++ b/include/internal/catch_stream.hpp @@ -65,27 +65,27 @@ namespace Catch { throw std::domain_error( oss.str() ); } } - + std::ostream& FileStream::stream() const { return m_ofs; } - + struct OutputDebugWriter { - + void operator()( std::string const&str ) { writeToDebugConsole( str ); } }; - + DebugOutStream::DebugOutStream() : m_streamBuf( new StreamBufImpl() ), m_os( m_streamBuf.get() ) {} - + std::ostream& DebugOutStream::stream() const { return m_os; } - + // Store the streambuf from cout up-front because // cout may get redirected when running tests CoutStream::CoutStream() @@ -95,8 +95,8 @@ namespace Catch { std::ostream& CoutStream::stream() const { return m_os; } - - + + #ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement this functions std::ostream& cout() { return std::cout; diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h index 685825e1..6ab1f375 100644 --- a/include/internal/catch_test_case_info.h +++ b/include/internal/catch_test_case_info.h @@ -31,7 +31,7 @@ namespace Catch { MayFail = 1 << 3, Throws = 1 << 4 }; - + TestCaseInfo( std::string const& _name, std::string const& _className, std::string const& _description, @@ -41,7 +41,7 @@ namespace Catch { TestCaseInfo( TestCaseInfo const& other ); friend void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ); - + bool isHidden() const; bool throws() const; bool okToFail() const; diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index 2101c985..90f53411 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -88,7 +88,7 @@ namespace Catch { tags.insert( "hide" ); tags.insert( "." ); } - + TestCaseInfo info( _name, _className, desc, tags, _lineInfo ); return TestCase( _testCase, info ); } @@ -97,7 +97,7 @@ namespace Catch { { testCaseInfo.tags = tags; testCaseInfo.lcaseTags.clear(); - + std::ostringstream oss; for( std::set::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) { oss << "[" << *it << "]"; @@ -107,7 +107,7 @@ namespace Catch { } testCaseInfo.tagsAsString = oss.str(); } - + TestCaseInfo::TestCaseInfo( std::string const& _name, std::string const& _className, std::string const& _description, diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index fda70aae..7f63dc54 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -27,11 +27,11 @@ namespace Catch { struct RandomNumberGenerator { int operator()( int n ) const { return std::rand() % n; } }; - + inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { - + std::vector sorted = unsortedTestCases; - + switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: std::sort( sorted.begin(), sorted.end(), LexSort() ); @@ -39,7 +39,7 @@ namespace Catch { case RunTests::InRandomOrder: { seedRng( config ); - + RandomNumberGenerator rng; std::random_shuffle( sorted.begin(), sorted.end(), rng ); } @@ -70,7 +70,7 @@ namespace Catch { } } } - + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { std::vector filtered; filtered.reserve( testCases.size() ); diff --git a/include/internal/catch_test_case_tracker.hpp b/include/internal/catch_test_case_tracker.hpp index 713ec96c..505c3ab8 100644 --- a/include/internal/catch_test_case_tracker.hpp +++ b/include/internal/catch_test_case_tracker.hpp @@ -21,61 +21,61 @@ namespace TestCaseTracking { struct ITracker : SharedImpl<> { virtual ~ITracker(); - + // static queries virtual std::string name() const = 0; - + // dynamic queries virtual bool isComplete() const = 0; // Successfully completed or failed virtual bool isSuccessfullyCompleted() const = 0; virtual bool isOpen() const = 0; // Started but not complete virtual bool hasChildren() const = 0; - + virtual ITracker& parent() = 0; - + // actions virtual void close() = 0; // Successfully complete virtual void fail() = 0; virtual void markAsNeedingAnotherRun() = 0; - + virtual void addChild( Ptr const& child ) = 0; virtual ITracker* findChild( std::string const& name ) = 0; virtual void openChild() = 0; }; - + class TrackerContext { - + enum RunState { NotStarted, Executing, CompletedCycle }; - + Ptr m_rootTracker; ITracker* m_currentTracker; RunState m_runState; - + public: - + static TrackerContext& instance() { static TrackerContext s_instance; return s_instance; } - + TrackerContext() : m_currentTracker( CATCH_NULL ), m_runState( NotStarted ) {} - - + + ITracker& startRun(); - + void endRun() { m_rootTracker.reset(); m_currentTracker = CATCH_NULL; m_runState = NotStarted; } - + void startCycle() { m_currentTracker = m_rootTracker.get(); m_runState = Executing; @@ -83,7 +83,7 @@ namespace TestCaseTracking { void completeCycle() { m_runState = CompletedCycle; } - + bool completedCycle() const { return m_runState == CompletedCycle; } @@ -94,7 +94,7 @@ namespace TestCaseTracking { m_currentTracker = tracker; } }; - + class TrackerBase : public ITracker { protected: enum CycleState { @@ -127,7 +127,7 @@ namespace TestCaseTracking { m_runState( NotStarted ) {} virtual ~TrackerBase(); - + virtual std::string name() const CATCH_OVERRIDE { return m_name; } @@ -143,12 +143,12 @@ namespace TestCaseTracking { virtual bool hasChildren() const CATCH_OVERRIDE { return !m_children.empty(); } - - + + virtual void addChild( Ptr const& child ) CATCH_OVERRIDE { m_children.push_back( child ); } - + virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE { Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) ); return( it != m_children.end() ) @@ -159,7 +159,7 @@ namespace TestCaseTracking { assert( m_parent ); // Should always be non-null except for root return *m_parent; } - + virtual void openChild() CATCH_OVERRIDE { if( m_runState != ExecutingChildren ) { m_runState = ExecutingChildren; @@ -173,22 +173,22 @@ namespace TestCaseTracking { if( m_parent ) m_parent->openChild(); } - + virtual void close() CATCH_OVERRIDE { - + // Close any still open children (e.g. generators) while( &m_ctx.currentTracker() != this ) m_ctx.currentTracker().close(); - + switch( m_runState ) { case NotStarted: case CompletedSuccessfully: case Failed: throw std::logic_error( "Illogical state" ); - + case NeedsAnotherRun: break;; - + case Executing: m_runState = CompletedSuccessfully; break; @@ -196,7 +196,7 @@ namespace TestCaseTracking { if( m_children.empty() || m_children.back()->isComplete() ) m_runState = CompletedSuccessfully; break; - + default: throw std::logic_error( "Unexpected state" ); } @@ -222,17 +222,17 @@ namespace TestCaseTracking { m_ctx.setCurrentTracker( this ); } }; - + class SectionTracker : public TrackerBase { public: SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent ) : TrackerBase( name, ctx, parent ) {} virtual ~SectionTracker(); - + static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) { SectionTracker* section = CATCH_NULL; - + ITracker& currentTracker = ctx.currentTracker(); if( ITracker* childTracker = currentTracker.findChild( name ) ) { section = dynamic_cast( childTracker ); @@ -243,13 +243,13 @@ namespace TestCaseTracking { currentTracker.addChild( section ); } if( !ctx.completedCycle() && !section->isComplete() ) { - + section->open(); } return *section; } }; - + class IndexTracker : public TrackerBase { int m_size; int m_index; @@ -260,10 +260,10 @@ namespace TestCaseTracking { m_index( -1 ) {} virtual ~IndexTracker(); - + static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) { IndexTracker* tracker = CATCH_NULL; - + ITracker& currentTracker = ctx.currentTracker(); if( ITracker* childTracker = currentTracker.findChild( name ) ) { tracker = dynamic_cast( childTracker ); @@ -273,39 +273,39 @@ namespace TestCaseTracking { tracker = new IndexTracker( name, ctx, ¤tTracker, size ); currentTracker.addChild( tracker ); } - + if( !ctx.completedCycle() && !tracker->isComplete() ) { if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) tracker->moveNext(); tracker->open(); } - + return *tracker; } - + int index() const { return m_index; } - + void moveNext() { m_index++; m_children.clear(); } - + virtual void close() CATCH_OVERRIDE { TrackerBase::close(); if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) m_runState = Executing; } }; - + inline ITracker& TrackerContext::startRun() { m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL ); m_currentTracker = CATCH_NULL; m_runState = Executing; return *m_rootTracker; } - + } // namespace TestCaseTracking - + using TestCaseTracking::ITracker; using TestCaseTracking::TrackerContext; using TestCaseTracking::SectionTracker; diff --git a/include/internal/catch_test_spec.hpp b/include/internal/catch_test_spec.hpp index 8428b09d..7e4ea9d1 100644 --- a/include/internal/catch_test_spec.hpp +++ b/include/internal/catch_test_spec.hpp @@ -20,7 +20,7 @@ #include namespace Catch { - + class TestSpec { struct Pattern : SharedImpl<> { virtual ~Pattern(); @@ -38,7 +38,7 @@ namespace Catch { private: WildcardPattern m_wildcardPattern; }; - + class TagPattern : public Pattern { public: TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} @@ -49,7 +49,7 @@ namespace Catch { private: std::string m_tag; }; - + class ExcludedPattern : public Pattern { public: ExcludedPattern( Ptr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 91bc106a..e6f7ec9d 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -67,7 +67,7 @@ std::string toString( std::nullptr_t ); std::string toString( NSObject* const& nsObject ); #endif - + namespace Detail { extern const std::string unprintableString; @@ -78,7 +78,7 @@ namespace Detail { struct TrueType { char sizer[1]; }; struct FalseType { char sizer[2]; }; - + TrueType& testStreamable( std::ostream& ); FalseType testStreamable( FalseType ); diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index 50b587d1..0a20ee2d 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -16,7 +16,7 @@ namespace Catch { namespace Detail { const std::string unprintableString = "{?}"; - + namespace { const int hexThreshold = 255; @@ -175,7 +175,7 @@ std::string toString( unsigned long long value ) { return oss.str(); } #endif - + #ifdef CATCH_CONFIG_CPP11_NULLPTR std::string toString( std::nullptr_t ) { return "nullptr"; diff --git a/include/internal/catch_version.h b/include/internal/catch_version.h index b6a97077..1a79c5c5 100644 --- a/include/internal/catch_version.h +++ b/include/internal/catch_version.h @@ -27,7 +27,7 @@ namespace Catch { unsigned int const buildNumber; friend std::ostream& operator << ( std::ostream& os, Version const& version ); - + private: void operator=( Version const& ); }; diff --git a/include/internal/catch_wildcard_pattern.hpp b/include/internal/catch_wildcard_pattern.hpp index a5e89b6e..cd8b07e1 100644 --- a/include/internal/catch_wildcard_pattern.hpp +++ b/include/internal/catch_wildcard_pattern.hpp @@ -19,9 +19,9 @@ namespace Catch WildcardAtEnd = 2, WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd }; - + public: - + WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ) : m_caseSensitivity( caseSensitivity ), m_wildcard( NoWildcard ), @@ -48,7 +48,7 @@ namespace Catch case WildcardAtBothEnds: return contains( adjustCase( str ), m_pattern ); } - + #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunreachable-code" diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp index 738415c3..c59725b0 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -22,23 +22,23 @@ namespace Catch { class XmlEncode { public: enum ForWhat { ForTextNodes, ForAttributes }; - + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ) : m_str( str ), m_forWhat( forWhat ) {} - + void encodeTo( std::ostream& os ) const { // Apostrophe escaping not necessary if we always use " to write attributes // (see: http://www.w3.org/TR/xml/#syntax) - + for( std::size_t i = 0; i < m_str.size(); ++ i ) { char c = m_str[i]; switch( c ) { case '<': os << "<"; break; case '&': os << "&"; break; - + case '>': // See: http://www.w3.org/TR/xml/#syntax if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) @@ -46,14 +46,14 @@ namespace Catch { else os << c; break; - + case '\"': if( m_forWhat == ForAttributes ) os << """; else os << c; break; - + default: // Escape control chars - based on contribution by @espenalb in PR #465 if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) @@ -68,12 +68,12 @@ namespace Catch { xmlEncode.encodeTo( os ); return os; } - + private: std::string m_str; ForWhat m_forWhat; }; - + class XmlWriter { public: diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index e37cac00..936bc6d7 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -230,18 +230,18 @@ namespace Catch { return line; } - + struct TestEventListenerBase : StreamingReporterBase { TestEventListenerBase( ReporterConfig const& _config ) : StreamingReporterBase( _config ) {} - + virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE { return false; } }; - + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index ae27f698..e656882f 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -104,7 +104,7 @@ namespace Catch { SectionNode const& rootSection = *testCaseNode.children.front(); std::string className = stats.testInfo.className; - + if( className.empty() ) { if( rootSection.childSections.empty() ) className = "global"; @@ -118,7 +118,7 @@ namespace Catch { std::string name = trim( sectionNode.stats.sectionInfo.name ); if( !rootName.empty() ) name = rootName + "/" + name; - + if( !sectionNode.assertions.empty() || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty() ) { @@ -187,7 +187,7 @@ namespace Catch { elementName = "internalError"; break; } - + XmlWriter::ScopedElement e = xml.scopedElement( elementName ); xml.writeAttribute( "message", result.getExpandedExpression() ); @@ -216,7 +216,7 @@ namespace Catch { unsigned int unexpectedExceptions; }; - INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) + INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) } // end namespace Catch diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp index 63d86c38..d3282666 100644 --- a/include/reporters/catch_reporter_multi.hpp +++ b/include/reporters/catch_reporter_multi.hpp @@ -15,18 +15,18 @@ namespace Catch { class MultipleReporters : public SharedImpl { typedef std::vector > Reporters; Reporters m_reporters; - + public: void add( Ptr const& reporter ) { m_reporters.push_back( reporter ); } - + public: // IStreamingReporter - + virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { return m_reporters[0]->getPreferences(); } - + virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); it != itEnd; @@ -34,7 +34,7 @@ public: // IStreamingReporter (*it)->noMatchingTestCases( spec ); } - + virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE { for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); it != itEnd; @@ -49,7 +49,7 @@ public: // IStreamingReporter (*it)->testGroupStarting( groupInfo ); } - + virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); it != itEnd; @@ -64,7 +64,7 @@ public: // IStreamingReporter (*it)->sectionStarting( sectionInfo ); } - + virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE { for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); it != itEnd; @@ -72,7 +72,7 @@ public: // IStreamingReporter (*it)->assertionStarting( assertionInfo ); } - + // The return value indicates if the messages buffer should be cleared: virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { bool clearBuffer = false; @@ -111,7 +111,7 @@ public: // IStreamingReporter (*it)->testRunEnded( testRunStats ); } - + virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); it != itEnd; @@ -122,7 +122,7 @@ public: // IStreamingReporter Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { Ptr resultingReporter; - + if( existingReporter ) { MultipleReporters* multi = dynamic_cast( existingReporter.get() ); if( !multi ) { @@ -137,11 +137,11 @@ Ptr addReporter( Ptr const& existingRepo } else resultingReporter = additionalReporter; - + return resultingReporter; } - - + + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED diff --git a/include/reporters/catch_reporter_teamcity.hpp b/include/reporters/catch_reporter_teamcity.hpp index 2e1b008b..1e633f1d 100644 --- a/include/reporters/catch_reporter_teamcity.hpp +++ b/include/reporters/catch_reporter_teamcity.hpp @@ -24,7 +24,7 @@ #endif namespace Catch { - + struct TeamCityReporter : StreamingReporterBase { TeamCityReporter( ReporterConfig const& _config ) : StreamingReporterBase( _config ), @@ -32,7 +32,7 @@ namespace Catch { { m_reporterPrefs.shouldRedirectStdOut = true; } - + static std::string escape( std::string const& str ) { std::string escaped = str; replaceInPlace( escaped, "|", "||" ); @@ -58,9 +58,9 @@ namespace Catch { stream << " message='test skipped because it didn|'t match the test spec'"; stream << "]\n"; } - + virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {} - + virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { StreamingReporterBase::testGroupStarting( groupInfo ); stream << "##teamcity[testSuiteStarted name='" @@ -72,21 +72,21 @@ namespace Catch { << escape( testGroupStats.groupInfo.name ) << "']\n"; } - + virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { } - + virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { AssertionResult const& result = assertionStats.assertionResult; if( !result.isOk() ) { - + std::ostringstream msg; if( !m_headerPrintedForThisSection ) printSectionHeader( msg ); m_headerPrintedForThisSection = true; - + msg << result.getSourceInfo() << "\n"; - + switch( result.getResultType() ) { case ResultWas::ExpressionFailed: msg << "expression failed"; @@ -125,15 +125,15 @@ namespace Catch { it != itEnd; ++it ) msg << "\n \"" << it->message << "\""; - - + + if( result.hasExpression() ) { msg << "\n " << result.getExpressionInMacro() << "\n" "with expansion:\n" << " " << result.getExpandedExpression() << "\n"; } - + stream << "##teamcity[testFailed" << " name='" << escape( currentTestCaseInfo->name )<< "'" << " message='" << escape( msg.str() ) << "'" @@ -141,7 +141,7 @@ namespace Catch { } return true; } - + virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { m_headerPrintedForThisSection = false; StreamingReporterBase::sectionStarting( sectionInfo ); @@ -152,7 +152,7 @@ namespace Catch { stream << "##teamcity[testStarted name='" << escape( testInfo.name ) << "']\n"; } - + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { StreamingReporterBase::testCaseEnded( testCaseStats ); if( !testCaseStats.stdOut.empty() ) @@ -181,9 +181,9 @@ namespace Catch { printHeaderString( os, it->name ); os << getLineOfChars<'-'>() << "\n"; } - + SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; - + if( !lineInfo.empty() ) os << lineInfo << "\n"; os << getLineOfChars<'.'>() << "\n\n"; @@ -203,15 +203,15 @@ namespace Catch { } private: bool m_headerPrintedForThisSection; - + }; - + #ifdef CATCH_IMPL TeamCityReporter::~TeamCityReporter() {} #endif - + INTERNAL_CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter ) - + } // end namespace Catch #ifdef __clang__ diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index 4268473b..bbe8780b 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -26,7 +26,7 @@ namespace Catch { } virtual ~XmlReporter() CATCH_OVERRIDE; - + static std::string getDescription() { return "Reports test results as an XML document"; } @@ -72,7 +72,7 @@ namespace Catch { virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { const AssertionResult& assertionResult = assertionStats.assertionResult; - + // Print any info messages in tags. if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); @@ -134,10 +134,10 @@ namespace Catch { default: break; } - + if( assertionResult.hasExpression() ) m_xml.endElement(); - + return true; } @@ -176,7 +176,7 @@ namespace Catch { .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); m_xml.endElement(); } - + virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { StreamingReporterBase::testRunEnded( testRunStats ); m_xml.scopedElement( "OverallResults" ) diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp index 1df76155..53656596 100644 --- a/projects/SelfTest/ApproxTests.cpp +++ b/projects/SelfTest/ApproxTests.cpp @@ -16,7 +16,7 @@ TEST_CASE ) { double d = 1.23; - + REQUIRE( d == Approx( 1.23 ) ); REQUIRE( d != Approx( 1.22 ) ); REQUIRE( d != Approx( 1.24 ) ); @@ -34,7 +34,7 @@ TEST_CASE ) { double d = 1.23; - + REQUIRE( d != Approx( 1.231 ) ); REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ); } @@ -71,7 +71,7 @@ TEST_CASE const double dZero = 0; const double dSmall = 0.00001; const double dMedium = 1.234; - + REQUIRE( 1.0f == Approx( 1 ) ); REQUIRE( 0 == Approx( dZero) ); REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) ); @@ -87,14 +87,14 @@ TEST_CASE ) { double d = 1.23; - + Approx approx = Approx::custom().epsilon( 0.005 ); - + REQUIRE( d == approx( 1.23 ) ); REQUIRE( d == approx( 1.22 ) ); REQUIRE( d == approx( 1.24 ) ); REQUIRE( d != approx( 1.25 ) ); - + REQUIRE( approx( d ) == 1.23 ); REQUIRE( approx( d ) == 1.22 ); REQUIRE( approx( d ) == 1.24 ); diff --git a/projects/SelfTest/BDDTests.cpp b/projects/SelfTest/BDDTests.cpp index 3b5c959d..2c8bc249 100644 --- a/projects/SelfTest/BDDTests.cpp +++ b/projects/SelfTest/BDDTests.cpp @@ -30,13 +30,13 @@ SCENARIO( "Vector resizing affects size and capacity", "[vector][bdd][size][capa GIVEN( "an empty vector" ) { std::vector v; REQUIRE( v.size() == 0 ); - + WHEN( "it is made larger" ) { v.resize( 10 ); THEN( "the size and capacity go up" ) { REQUIRE( v.size() == 10 ); REQUIRE( v.capacity() >= 10 ); - + AND_WHEN( "it is made smaller again" ) { v.resize( 5 ); THEN( "the size goes down but the capacity stays the same" ) { @@ -46,7 +46,7 @@ SCENARIO( "Vector resizing affects size and capacity", "[vector][bdd][size][capa } } } - + WHEN( "we reserve more space" ) { v.reserve( 10 ); THEN( "The capacity is increased but the size remains the same" ) { @@ -76,19 +76,19 @@ struct Fixture : d_counter(0) { } - + int counter() { return d_counter++; } - + int d_counter; }; - + } SCENARIO_METHOD(Fixture, - "BDD tests requiring Fixtures to provide commonly-accessed data or methods", + "BDD tests requiring Fixtures to provide commonly-accessed data or methods", "[bdd][fixtures]") { const int before(counter()); GIVEN("No operations precede me") { diff --git a/projects/SelfTest/ClassTests.cpp b/projects/SelfTest/ClassTests.cpp index e22f3d24..a4707849 100644 --- a/projects/SelfTest/ClassTests.cpp +++ b/projects/SelfTest/ClassTests.cpp @@ -13,18 +13,18 @@ namespace class TestClass { std::string s; - + public: TestClass() : s( "hello" ) {} - + void succeedingCase() - { + { REQUIRE( s == "hello" ); } void failingCase() - { + { REQUIRE( s == "world" ); } }; @@ -38,20 +38,20 @@ METHOD_AS_TEST_CASE( TestClass::failingCase, "A METHOD_AS_TEST_CASE based test r struct Fixture { Fixture() : m_a( 1 ) {} - + int m_a; }; TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" ) -{ - REQUIRE( m_a == 1 ); +{ + REQUIRE( m_a == 1 ); } // We should be able to write our tests within a different namespace namespace Inner { TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" ) - { - REQUIRE( m_a == 2 ); + { + REQUIRE( m_a == 2 ); } } diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp index 195188ac..d1b7ed24 100644 --- a/projects/SelfTest/ConditionTests.cpp +++ b/projects/SelfTest/ConditionTests.cpp @@ -22,7 +22,7 @@ struct TestData { float_nine_point_one( 9.1f ), double_pi( 3.1415926535 ) {} - + int int_seven; std::string str_hello; float float_nine_point_one; @@ -37,7 +37,7 @@ struct TestDef { TestDef& operator[]( const std::string& ) { return *this; } - + }; // The "failing" tests all use the CHECK macro, which continues if the specific test fails. @@ -49,14 +49,14 @@ TEST_CASE( "Equality checks that should succeed", "" ) TestDef td; td + "hello" + "hello"; - + TestData data; - + REQUIRE( data.int_seven == 7 ); REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ); REQUIRE( data.double_pi == Approx( 3.1415926535 ) ); REQUIRE( data.str_hello == "hello" ); - REQUIRE( "hello" == data.str_hello ); + REQUIRE( "hello" == data.str_hello ); REQUIRE( data.str_hello.size() == 5 ); double x = 1.1 + 0.1 + 0.1; @@ -66,7 +66,7 @@ TEST_CASE( "Equality checks that should succeed", "" ) TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" ) { TestData data; - + CHECK( data.int_seven == 6 ); CHECK( data.int_seven == 8 ); CHECK( data.int_seven == 0 ); @@ -87,7 +87,7 @@ TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" ) TEST_CASE( "Inequality checks that should succeed", "" ) { TestData data; - + REQUIRE( data.int_seven != 6 ); REQUIRE( data.int_seven != 8 ); REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ); @@ -104,7 +104,7 @@ TEST_CASE( "Inequality checks that should succeed", "" ) TEST_CASE( "Inequality checks that should fail", "[.][failing]" ) { TestData data; - + CHECK( data.int_seven != 7 ); CHECK( data.float_nine_point_one != Approx( 9.1f ) ); CHECK( data.double_pi != Approx( 3.1415926535 ) ); @@ -116,7 +116,7 @@ TEST_CASE( "Inequality checks that should fail", "[.][failing]" ) TEST_CASE( "Ordering comparison checks that should succeed", "" ) { TestData data; - + REQUIRE( data.int_seven < 8 ); REQUIRE( data.int_seven > 6 ); REQUIRE( data.int_seven > 0 ); @@ -126,14 +126,14 @@ TEST_CASE( "Ordering comparison checks that should succeed", "" ) REQUIRE( data.int_seven >= 6 ); REQUIRE( data.int_seven <= 7 ); REQUIRE( data.int_seven <= 8 ); - + REQUIRE( data.float_nine_point_one > 9 ); REQUIRE( data.float_nine_point_one < 10 ); REQUIRE( data.float_nine_point_one < 9.2 ); - + REQUIRE( data.str_hello <= "hello" ); REQUIRE( data.str_hello >= "hello" ); - + REQUIRE( data.str_hello < "hellp" ); REQUIRE( data.str_hello < "zebra" ); REQUIRE( data.str_hello > "hellm" ); @@ -143,7 +143,7 @@ TEST_CASE( "Ordering comparison checks that should succeed", "" ) TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) { TestData data; - + CHECK( data.int_seven > 7 ); CHECK( data.int_seven < 7 ); CHECK( data.int_seven > 8 ); @@ -153,11 +153,11 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) CHECK( data.int_seven >= 8 ); CHECK( data.int_seven <= 6 ); - + CHECK( data.float_nine_point_one < 9 ); CHECK( data.float_nine_point_one > 10 ); CHECK( data.float_nine_point_one > 9.2 ); - + CHECK( data.str_hello > "hello" ); CHECK( data.str_hello < "hello" ); CHECK( data.str_hello > "hellp" ); @@ -178,7 +178,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne unsigned long ul = 4; char c = 5; unsigned char uc = 6; - + REQUIRE( i == 1 ); REQUIRE( ui == 2 ); REQUIRE( l == 3 ); @@ -215,7 +215,7 @@ TEST_CASE( "comparisons between int variables", "" ) 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 ); @@ -252,7 +252,7 @@ template struct Ex { Ex( T ){} - + bool operator == ( const T& ) const { return true; } T operator * ( const T& ) const { return T(); } }; @@ -273,13 +273,13 @@ TEST_CASE( "Pointers can be compared to null", "" ) { TestData* p = CATCH_NULL; TestData* pNULL = CATCH_NULL; - + REQUIRE( p == CATCH_NULL ); REQUIRE( p == pNULL ); - + TestData data; p = &data; - + REQUIRE( p != CATCH_NULL ); const TestData* cp = p; @@ -290,7 +290,7 @@ TEST_CASE( "Pointers can be compared to null", "" ) REQUIRE( returnsNull() == CATCH_NULL ); REQUIRE( returnsConstNull() == CATCH_NULL ); - + REQUIRE( CATCH_NULL != p ); } @@ -304,7 +304,7 @@ TEST_CASE( "Pointers can be compared to null", "" ) TEST_CASE( "'Not' checks that should succeed", "" ) { bool falseValue = false; - + REQUIRE( false == false ); REQUIRE( true == true ); REQUIRE( !false ); @@ -320,15 +320,15 @@ TEST_CASE( "'Not' checks that should succeed", "" ) TEST_CASE( "'Not' checks that should fail", "[.][failing]" ) { bool trueValue = true; - + CHECK( false != false ); CHECK( true != true ); CHECK( !true ); CHECK_FALSE( true ); - + CHECK( !trueValue ); CHECK_FALSE( trueValue ); - + CHECK( !(1 == 1) ); CHECK_FALSE( 1 == 1 ); } diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 3826c58b..eb8b7d8f 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -96,12 +96,12 @@ public: CustomException( const std::string& msg ) : m_msg( msg ) {} - + std::string getMessage() const { return m_msg; } - + private: std::string m_msg; }; diff --git a/projects/SelfTest/GeneratorTests.cpp b/projects/SelfTest/GeneratorTests.cpp index a961b698..af08b1d3 100644 --- a/projects/SelfTest/GeneratorTests.cpp +++ b/projects/SelfTest/GeneratorTests.cpp @@ -19,10 +19,10 @@ inline int multiply( int a, int b ) CATCH_TEST_CASE( "Generators over two ranges", "[generators]" ) { using namespace Catch::Generators; - + int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) ); int j = CATCH_GENERATE( between( 100, 107 ) ); - + CATCH_REQUIRE( multiply( i, 2 ) == i*2 ); CATCH_REQUIRE( multiply( j, 2 ) == j*2 ); } @@ -32,11 +32,11 @@ struct IntPair { int first, second; }; CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" ) { using namespace Catch::Generators; - + IntPair p[] = { { 0, 1 }, { 2, 3 } }; - + IntPair* i = CATCH_GENERATE( between( p, &p[1] ) ); - + CATCH_REQUIRE( i->first == i->second-1 ); - + } diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp index 69ef03dd..87a85a82 100644 --- a/projects/SelfTest/MessageTests.cpp +++ b/projects/SelfTest/MessageTests.cpp @@ -38,7 +38,7 @@ TEST_CASE( "INFO gets logged on failure, even if captured before successful asse CHECK( a == 2 ); INFO( "this message should be logged" ); - + CHECK( a == 1 ); INFO( "and this, but later" ); @@ -85,7 +85,7 @@ TEST_CASE( "Standard output from all sections is reported", "[messages][.]" ) { std::cout << "Message from section one" << std::endl; } - + SECTION( "two", "" ) { std::cout << "Message from section two" << std::endl; diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index e791cb10..70a6cee1 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -21,7 +21,7 @@ TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) { int a = 1; int b = 2; - + SECTION( "s1", "doesn't equal" ) { REQUIRE( a != b ); @@ -38,7 +38,7 @@ TEST_CASE( "nested SECTION tests", "[.][sections][failing]" ) { int a = 1; int b = 2; - + SECTION( "s1", "doesn't equal" ) { REQUIRE( a != b ); @@ -55,7 +55,7 @@ TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" ) { int a = 1; int b = 2; - + SECTION( "s1", "doesn't equal" ) { SECTION( "s2", "equal" ) @@ -82,7 +82,7 @@ TEST_CASE( "even more nested SECTION tests", "[sections]" ) { SUCCEED(""); // avoid failing due to no tests } - + SECTION( "e (leaf)", "" ) { SUCCEED(""); // avoid failing due to no tests @@ -98,14 +98,14 @@ TEST_CASE( "even more nested SECTION tests", "[sections]" ) TEST_CASE( "looped SECTION tests", "[.][failing][sections]" ) { int a = 1; - + for( int b = 0; b < 10; ++b ) { std::ostringstream oss; oss << "b is currently: " << b; SECTION( "s1", oss.str() ) { - CHECK( b > a ); + CHECK( b > a ); } } } @@ -113,18 +113,18 @@ TEST_CASE( "looped SECTION tests", "[.][failing][sections]" ) TEST_CASE( "looped tests", "[.][failing]" ) { static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 }; - + for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i ) { INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" ); - CHECK( ( fib[i] % 2 ) == 0 ); + CHECK( ( fib[i] % 2 ) == 0 ); } } TEST_CASE( "Sends stuff to stdout and stderr", "[.]" ) { std::cout << "A string sent directly to stdout" << std::endl; - + std::cerr << "A string sent directly to stderr" << std::endl; } @@ -162,7 +162,7 @@ inline bool testCheckedElse( bool flag ) { CHECKED_ELSE( flag ) return false; - + return true; } @@ -191,13 +191,13 @@ TEST_CASE( "xmlentitycheck", "" ) TEST_CASE( "send a single char to INFO", "[failing][.]" ) { INFO(3); - REQUIRE(false); + REQUIRE(false); } TEST_CASE( "atomic if", "[failing][0]") { size_t x = 0; - + if( x ) REQUIRE(x > 0); else @@ -211,7 +211,7 @@ inline const char* testStringForMatching() TEST_CASE("String matchers", "[matchers]" ) { - REQUIRE_THAT( testStringForMatching(), Contains( "string" ) ); + REQUIRE_THAT( testStringForMatching(), Contains( "string" ) ); CHECK_THAT( testStringForMatching(), Contains( "abc" ) ); CHECK_THAT( testStringForMatching(), StartsWith( "this" ) ); @@ -297,38 +297,38 @@ TEST_CASE( "second tag", "[tag2]" ) TEST_CASE( "vectors can be sized and resized", "[vector]" ) { std::vector v( 5 ); - + REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 5 ); - + SECTION( "resizing bigger changes size and capacity", "" ) { v.resize( 10 ); - + REQUIRE( v.size() == 10 ); REQUIRE( v.capacity() >= 10 ); } SECTION( "resizing smaller changes size but not capacity", "" ) { v.resize( 0 ); - + REQUIRE( v.size() == 0 ); REQUIRE( v.capacity() >= 5 ); - + SECTION( "We can use the 'swap trick' to reset the capacity", "" ) { std::vector empty; empty.swap( v ); - + REQUIRE( v.capacity() == 0 ); } } SECTION( "reserving bigger changes capacity but not size", "" ) { v.reserve( 10 ); - + REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 10 ); } SECTION( "reserving smaller does not change size or capacity", "" ) { v.reserve( 0 ); - + REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 5 ); } @@ -426,7 +426,7 @@ TEST_CASE( "XmlEncode" ) { #ifdef CATCH_CONFIG_CPP11_LONG_LONG TEST_CASE( "long long" ) { long long l = std::numeric_limits::max(); - + REQUIRE( l == std::numeric_limits::max() ); } #endif diff --git a/projects/SelfTest/PartTrackerTests.cpp b/projects/SelfTest/PartTrackerTests.cpp index c576d53c..29256351 100644 --- a/projects/SelfTest/PartTrackerTests.cpp +++ b/projects/SelfTest/PartTrackerTests.cpp @@ -12,13 +12,13 @@ namespace Catch { class LocalContext { - + public: TrackerContext& operator()() const { return TrackerContext::instance(); } }; - + } // namespace Catch inline Catch::TrackerContext& C_A_T_C_H_Context() { @@ -37,11 +37,11 @@ using namespace Catch; //} TEST_CASE( "Tracker", "" ) { - + TrackerContext ctx; ctx.startRun(); ctx.startCycle(); - + ITracker& testCase = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase.isOpen() ); @@ -57,13 +57,13 @@ TEST_CASE( "Tracker", "" ) { REQUIRE( ctx.completedCycle() ); REQUIRE( testCase.isSuccessfullyCompleted() ); } - + SECTION( "fail one section", "" ) { s1.fail(); REQUIRE( s1.isComplete() ); REQUIRE( s1.isSuccessfullyCompleted() == false ); REQUIRE( testCase.isComplete() == false ); - + testCase.close(); REQUIRE( ctx.completedCycle() ); REQUIRE( testCase.isSuccessfullyCompleted() == false ); @@ -72,10 +72,10 @@ TEST_CASE( "Tracker", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() == false ); - + testCase2.close(); REQUIRE( ctx.completedCycle() ); REQUIRE( testCase.isComplete() ); @@ -85,7 +85,7 @@ TEST_CASE( "Tracker", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() == false ); @@ -94,19 +94,19 @@ TEST_CASE( "Tracker", "" ) { s2.close(); REQUIRE( ctx.completedCycle() ); - + testCase2.close(); REQUIRE( testCase.isComplete() ); REQUIRE( testCase.isSuccessfullyCompleted() ); } } - + SECTION( "successfully close one section, then find another", "" ) { s1.close(); - + ITracker& s2 = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2.isOpen() == false ); - + testCase.close(); REQUIRE( testCase.isComplete() == false ); @@ -114,7 +114,7 @@ TEST_CASE( "Tracker", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() == false ); @@ -122,14 +122,14 @@ TEST_CASE( "Tracker", "" ) { REQUIRE( s2b.isOpen() ); REQUIRE( ctx.completedCycle() == false ); - + SECTION ("Successfully close S2") { s2b.close(); REQUIRE( ctx.completedCycle() ); REQUIRE( s2b.isSuccessfullyCompleted() ); REQUIRE( testCase2.isComplete() == false ); - + testCase2.close(); REQUIRE( testCase2.isSuccessfullyCompleted() ); } @@ -139,7 +139,7 @@ TEST_CASE( "Tracker", "" ) { REQUIRE( s2b.isComplete() ); REQUIRE( s2b.isSuccessfullyCompleted() == false ); - + testCase2.close(); REQUIRE( testCase2.isSuccessfullyCompleted() == false ); @@ -147,19 +147,19 @@ TEST_CASE( "Tracker", "" ) { ctx.startCycle(); ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase3.isOpen() ); - + ITracker& s1c = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1c.isOpen() == false ); - + ITracker& s2c = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2c.isOpen() == false ); - + testCase3.close(); REQUIRE( testCase3.isSuccessfullyCompleted() ); } } } - + SECTION( "open a nested section", "" ) { ITracker& s2 = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2.isOpen() ); @@ -167,15 +167,15 @@ TEST_CASE( "Tracker", "" ) { s2.close(); REQUIRE( s2.isComplete() ); REQUIRE( s1.isComplete() == false ); - + s1.close(); REQUIRE( s1.isComplete() ); REQUIRE( testCase.isComplete() == false ); - + testCase.close(); REQUIRE( testCase.isComplete() ); } - + SECTION( "start a generator", "" ) { IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 ); REQUIRE( g1.isOpen() ); @@ -195,17 +195,17 @@ TEST_CASE( "Tracker", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() ); - - + + IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 ); REQUIRE( g1b.isOpen() ); REQUIRE( g1b.index() == 1 ); - + REQUIRE( s1.isComplete() == false ); - + s1b.close(); REQUIRE( s1b.isComplete() ); REQUIRE( g1b.isComplete() ); @@ -225,98 +225,98 @@ TEST_CASE( "Tracker", "" ) { testCase.close(); REQUIRE( testCase.isComplete() == false ); - + SECTION( "Re-enter for second generation", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() ); - + // generator - next value IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 ); REQUIRE( g1b.isOpen() ); REQUIRE( g1b.index() == 1 ); - + // inner section again ITracker& s2b = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2b.isOpen() ); - + s2b.close(); REQUIRE( s2b.isComplete() ); - + s1b.close(); REQUIRE( g1b.isComplete() ); REQUIRE( s1b.isComplete() ); - + testCase2.close(); REQUIRE( testCase2.isComplete() ); } } - + SECTION( "Fail an inner section", "" ) { ITracker& s2 = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2.isOpen() ); - + s2.fail(); REQUIRE( s2.isComplete() ); REQUIRE( s2.isSuccessfullyCompleted() == false ); - + s1.close(); REQUIRE( s1.isComplete() == false ); - + testCase.close(); REQUIRE( testCase.isComplete() == false ); - + SECTION( "Re-enter for second generation", "" ) { ctx.startCycle(); ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase2.isOpen() ); - + ITracker& s1b = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1b.isOpen() ); - + // generator - still same value IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 ); REQUIRE( g1b.isOpen() ); REQUIRE( g1b.index() == 0 ); - + // inner section again - this time won't open ITracker& s2b = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2b.isOpen() == false ); - + s1b.close(); REQUIRE( g1b.isComplete() == false ); REQUIRE( s1b.isComplete() == false ); - + testCase2.close(); REQUIRE( testCase2.isComplete() == false ); - + // Another cycle - now should complete ctx.startCycle(); ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" ); REQUIRE( testCase3.isOpen() ); - + ITracker& s1c = SectionTracker::acquire( ctx, "S1" ); REQUIRE( s1c.isOpen() ); - + // generator - now next value IndexTracker& g1c = IndexTracker::acquire( ctx, "G1", 2 ); REQUIRE( g1c.isOpen() ); REQUIRE( g1c.index() == 1 ); - + // inner section - now should open again ITracker& s2c = SectionTracker::acquire( ctx, "S2" ); REQUIRE( s2c.isOpen() ); - + s2c.close(); REQUIRE( s2c.isComplete() ); - + s1c.close(); REQUIRE( g1c.isComplete() ); REQUIRE( s1c.isComplete() ); - + testCase3.close(); REQUIRE( testCase3.isComplete() ); } diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index f4c660d6..f8d17fdd 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -49,13 +49,13 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION( "default - no arguments", "" ) { const char* argv[] = { "test" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + CHECK( config.shouldDebugBreak == false ); CHECK( config.abortAfter == -1 ); CHECK( config.noThrow == false ); CHECK( config.reporterNames.empty() ); } - + SECTION( "test lists", "" ) { SECTION( "1 test", "Specify one test case using" ) { const char* argv[] = { "test", "test1" }; @@ -84,24 +84,24 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" } } - + SECTION( "reporter", "" ) { SECTION( "-r/console", "" ) { const char* argv[] = { "test", "-r", "console" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.reporterNames[0] == "console" ); } SECTION( "-r/xml", "" ) { const char* argv[] = { "test", "-r", "xml" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.reporterNames[0] == "xml" ); } SECTION( "-r xml and junit", "" ) { const char* argv[] = { "test", "-r", "xml", "-r", "junit" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.reporterNames.size() == 2 ); REQUIRE( config.reporterNames[0] == "xml" ); REQUIRE( config.reporterNames[1] == "junit" ); @@ -109,26 +109,26 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION( "--reporter/junit", "" ) { const char* argv[] = { "test", "--reporter", "junit" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.reporterNames[0] == "junit" ); } } - + SECTION( "debugger", "" ) { SECTION( "-b", "" ) { const char* argv[] = { "test", "-b" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.shouldDebugBreak == true ); } SECTION( "--break", "" ) { const char* argv[] = { "test", "--break" }; CHECK_NOTHROW( parseIntoConfig( argv, config ) ); - + REQUIRE( config.shouldDebugBreak ); } } - + SECTION( "abort", "" ) { SECTION( "-a aborts after first failure", "" ) { const char* argv[] = { "test", "-a" }; @@ -151,7 +151,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) ); } } - + SECTION( "nothrow", "" ) { SECTION( "-e", "" ) { const char* argv[] = { "test", "-e" }; @@ -217,7 +217,7 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) { SECTION( "plain string", "" ) { // guide: 123456789012345678 std::string testString = "one two three four"; - + SECTION( "No wrapping", "" ) { CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ); CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ); @@ -261,14 +261,14 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) { .setInitialIndent( 1 ) ); CHECK( text.toString() == " one two\n three\n four" ); } - + } - + SECTION( "With newlines", "" ) { - + // guide: 1234567890123456789 std::string testString = "one two\nthree four"; - + SECTION( "No wrapping" , "" ) { CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString ); CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString ); @@ -288,17 +288,17 @@ TEST_CASE( "Long strings can be wrapped", "[wrap]" ) { CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" ); } } - + SECTION( "With tabs", "" ) { // guide: 1234567890123456789 std::string testString = "one two \tthree four five six"; - + CHECK( Text( testString, TextAttributes().setWidth( 15 ) ).toString() == "one two three\n four\n five\n six" ); } - - + + } using namespace Catch; @@ -324,7 +324,7 @@ public: ColourString( std::string const& _string, std::vector const& _colours ) : string( _string ), colours( _colours ) {} - + ColourString& addColour( Colour::Code colour, int _index ) { colours.push_back( ColourIndex( colour, resolveRelativeIndex( _index ), @@ -337,7 +337,7 @@ public: resolveLastRelativeIndex( _toIndex ) ) ); return *this; } - + void writeToStream( std::ostream& _stream ) const { std::size_t last = 0; for( std::size_t i = 0; i < colours.size(); ++i ) { @@ -351,7 +351,7 @@ public: last = index.toIndex; } if( last < string.size() ) - _stream << string.substr( last ); + _stream << string.substr( last ); } friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) { _colourString.writeToStream( _stream ); @@ -408,7 +408,7 @@ TEST_CASE( "replaceInPlace", "" ) { // !TBD: This will be folded into Text class TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) { - + { ColourString cs( "hello" ); cs .addColour( Colour::Red, 0 ) @@ -420,19 +420,19 @@ TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) { { ColourString cs( "hello" ); cs .addColour( Colour::Blue, 1, -2 ); - + Catch::cout() << cs << std::endl; } - + } TEST_CASE( "Text can be formatted using the Text class", "" ) { - + CHECK( Text( "hi there" ).toString() == "hi there" ); - + TextAttributes narrow; narrow.setWidth( 6 ); - + CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" ); } @@ -445,5 +445,5 @@ TEST_CASE( "Long text is truncted", "[Text][Truncated]" ) { oss << longLine << longLine << "\n"; Text t( oss.str() ); CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) ); - + } diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index 95612022..eb53e420 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -25,7 +25,7 @@ namespace Catch std::ostringstream oss; oss << "std::pair( " << value.first << ", " << value.second << " )"; return oss.str(); - + } } @@ -38,7 +38,7 @@ TEST_CASE { std::pair aNicePair( 1, 2 ); - REQUIRE( (std::pair( 1, 2 )) == aNicePair ); + REQUIRE( (std::pair( 1, 2 )) == aNicePair ); } /////////////////////////////////////////////////////////////////////////////// @@ -62,7 +62,7 @@ TEST_CASE /* int a = 1; int b = 2; - + // This only captures part of the expression, but issues a warning about the rest REQUIRE( a+1 == b-1 ); */ @@ -85,38 +85,38 @@ TEST_CASE "[Tricky][failing][.]" ) { - + Opaque o1, o2; o1.val = 7; o2.val = 8; - + CHECK( &o1 == &o2 ); CHECK( o1 == o2 ); } /////////////////////////////////////////////////////////////////////////////// TEST_CASE -( +( "string literals of different sizes can be compared", "[Tricky][failing][.]" ) { REQUIRE( std::string( "first" ) == "second" ); - + } /////////////////////////////////////////////////////////////////////////////// TEST_CASE -( +( "An expression with side-effects should only be evaluated once", "[Tricky]" ) { int i = 7; - + REQUIRE( i++ == 7 ); REQUIRE( i++ == 8 ); - + } namespace A { @@ -167,8 +167,8 @@ TEST_CASE */ namespace ObjectWithConversions -{ - struct Object +{ + struct Object { operator unsigned int() {return 0xc0000000;} }; @@ -179,31 +179,31 @@ namespace ObjectWithConversions "Operators at different namespace levels not hijacked by Koenig lookup", "[Tricky]" ) - { + { Object o; REQUIRE(0xc0000000 == o ); } } -namespace ObjectWithNonConstEqualityOperator +namespace ObjectWithNonConstEqualityOperator { struct Test { Test( unsigned int v ) - : m_value(v) + : m_value(v) {} - + bool operator==( const Test&rhs ) - { + { return (m_value == rhs.m_value); } bool operator==( const Test&rhs ) const - { + { return (m_value != rhs.m_value); } unsigned int m_value; }; - + TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" ) { Test t( 1 ); @@ -226,7 +226,7 @@ namespace EnumBitFieldTests struct Obj { Obj():prop(&p){} - + int p; int* prop; }; @@ -284,11 +284,11 @@ TEST_CASE( "(unimplemented) static bools can be evaluated", "[Tricky]" ) /* TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) { - + } TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) { - + } */ @@ -317,13 +317,13 @@ TEST_CASE( "Assertions then sections", "[Tricky]" ) { // This was causing a failure due to the way the console reporter was handling // the current section - + REQUIRE( Catch::alwaysTrue() ); - + SECTION( "A section", "" ) { REQUIRE( Catch::alwaysTrue() ); - + SECTION( "Another section", "" ) { REQUIRE( Catch::alwaysTrue() ); diff --git a/projects/runners/iTchRunner/internal/iTchRunnerAppDelegate.h b/projects/runners/iTchRunner/internal/iTchRunnerAppDelegate.h index a98b45d5..522291a9 100644 --- a/projects/runners/iTchRunner/internal/iTchRunnerAppDelegate.h +++ b/projects/runners/iTchRunner/internal/iTchRunnerAppDelegate.h @@ -13,7 +13,7 @@ -@interface iTchRunnerAppDelegate : NSObject +@interface iTchRunnerAppDelegate : NSObject { UIWindow *window; } @@ -25,15 +25,15 @@ /////////////////////////////////////////////////////////////////////////////// -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [window setUserInteractionEnabled:YES]; [window setMultipleTouchEnabled:YES]; - + CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; iTchRunnerMainView* view = [[iTchRunnerMainView alloc] initWithFrame:screenRect]; - + [window addSubview:view]; [window makeKeyAndVisible]; arcSafeRelease( view ); @@ -42,7 +42,7 @@ } /////////////////////////////////////////////////////////////////////////////// -- (void)dealloc +- (void)dealloc { #if !CATCH_ARC_ENABLED [window release]; @@ -52,7 +52,7 @@ /////////////////////////////////////////////////////////////////////////////// -- (void)applicationWillResignActive:(UIApplication *)application +- (void)applicationWillResignActive:(UIApplication *)application { /* Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. @@ -62,17 +62,17 @@ /////////////////////////////////////////////////////////////////////////////// -- (void)applicationDidEnterBackground:(UIApplication *)application +- (void)applicationDidEnterBackground:(UIApplication *)application { /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. If your application supports background execution, called instead of applicationWillTerminate: when the user quits. */ } /////////////////////////////////////////////////////////////////////////////// -- (void)applicationWillEnterForeground:(UIApplication *)application +- (void)applicationWillEnterForeground:(UIApplication *)application { /* Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. @@ -81,7 +81,7 @@ /////////////////////////////////////////////////////////////////////////////// -- (void)applicationDidBecomeActive:(UIApplication *)application +- (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. @@ -90,7 +90,7 @@ /////////////////////////////////////////////////////////////////////////////// -- (void)applicationWillTerminate:(UIApplication *)application +- (void)applicationWillTerminate:(UIApplication *)application { /* Called when the application is about to terminate. @@ -100,7 +100,7 @@ /////////////////////////////////////////////////////////////////////////////// -- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { /* Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. diff --git a/projects/runners/iTchRunner/internal/iTchRunnerMainView.h b/projects/runners/iTchRunner/internal/iTchRunnerMainView.h index ee78004c..c6a6394e 100644 --- a/projects/runners/iTchRunner/internal/iTchRunnerMainView.h +++ b/projects/runners/iTchRunner/internal/iTchRunnerMainView.h @@ -33,7 +33,7 @@ /////////////////////////////////////////////////////////////////////////////// -(id) initWithFrame:(CGRect)frame { - if ((self = [super initWithFrame:frame])) + if ((self = [super initWithFrame:frame])) { // Initialization code self.backgroundColor = [UIColor blackColor]; @@ -64,7 +64,7 @@ /////////////////////////////////////////////////////////////////////////////// -(void) showAlert -{ +{ UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:@"Options" delegate:self cancelButtonTitle:nil @@ -72,7 +72,7 @@ otherButtonTitles:@"Run all tests", nil]; [menu showInView: self]; arcSafeRelease( menu ); - + } // This is a copy & paste from Catch::Runner2 to get us bootstrapped (this is due to all be @@ -144,7 +144,7 @@ inline Catch::Totals runTestsForGroup( Catch::RunContext& context, const Catch:: { const Catch::AssertionResult& resultInfo = *pResultInfo; std::ostringstream oss; - + if( resultInfo.hasExpression() ) { oss << resultInfo.getExpression(); @@ -174,7 +174,7 @@ inline Catch::Totals runTestsForGroup( Catch::RunContext& context, const Catch:: default: break; } - + if( resultInfo.hasExpression() ) { oss << " for: " << resultInfo.getExpandedExpression(); diff --git a/projects/runners/iTchRunner/internal/iTchRunnerReporter.h b/projects/runners/iTchRunner/internal/iTchRunnerReporter.h index a7adf866..d2628861 100644 --- a/projects/runners/iTchRunner/internal/iTchRunnerReporter.h +++ b/projects/runners/iTchRunner/internal/iTchRunnerReporter.h @@ -13,7 +13,7 @@ @protocol iTchRunnerDelegate --(void) testWasRun: (const Catch::AssertionResult*) result; +-(void) testWasRun: (const Catch::AssertionResult*) result; @end @@ -38,14 +38,14 @@ namespace Catch { return true; } - + /////////////////////////////////////////////////////////////////////////// static std::string getDescription () { return "Captures results for iOS runner"; } - + /////////////////////////////////////////////////////////////////////////// size_t getSucceeded () @@ -53,7 +53,7 @@ namespace Catch { return m_totals.assertions.passed; } - + /////////////////////////////////////////////////////////////////////////// size_t getFailed () @@ -61,20 +61,20 @@ namespace Catch { return m_totals.assertions.failed; } - + /////////////////////////////////////////////////////////////////////////// void reset() { m_totals = Totals(); } - + private: // IReporter - + /////////////////////////////////////////////////////////////////////////// virtual void StartTesting () {} - + /////////////////////////////////////////////////////////////////////////// virtual void EndTesting ( @@ -83,7 +83,7 @@ namespace Catch { m_totals = totals; } - + /////////////////////////////////////////////////////////////////////////// virtual void Result ( @@ -92,7 +92,7 @@ namespace Catch { [m_delegate testWasRun: &result]; } - + /////////////////////////////////////////////////////////////////////////// // Deliberately unimplemented: virtual void StartGroup( const std::string& ){} @@ -107,7 +107,7 @@ namespace Catch private: Totals m_totals; - + id m_delegate; }; }