From 58e9a8bafd1ad1080e9ee559199b3b2e1cb21d54 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 8 Feb 2011 08:42:05 +0000 Subject: [PATCH] Some clean-up --- Test/Test.xcodeproj/project.pbxproj | 20 ++++++++++ Test/Xcode/OCTest/CatchOCTestCase.h | 2 + Test/Xcode/OCTest/CatchOCTestCase.mm | 2 + Test/Xcode/OCTest/OCTest.mm | 3 ++ Test/Xcode/OCTest/TestObj.h | 2 + Test/Xcode/OCTest/TestObj.m | 2 + catch_objc.hpp | 58 +++++++++++++++++++++++----- catch_objc_main.hpp | 2 +- internal/catch_interfaces_runner.h | 3 +- internal/catch_runner_impl.hpp | 9 ++++- 10 files changed, 90 insertions(+), 13 deletions(-) diff --git a/Test/Test.xcodeproj/project.pbxproj b/Test/Test.xcodeproj/project.pbxproj index 5fc2ba24..3901574b 100644 --- a/Test/Test.xcodeproj/project.pbxproj +++ b/Test/Test.xcodeproj/project.pbxproj @@ -327,6 +327,26 @@ PREBINDING = NO; SDKROOT = macosx10.6; WARNING_CFLAGS = ( + "-Wfloat-equal", + "-Wundef", + "-Wshadow", + "-Wpointer-arith", + "-Wcast-qual", + "-Wcast-align", + "-Wwrite-strings", + "-Wconversion", + "-Wsign-compare", + "-Wmissing-noreturn", + "-Wmissing-format-attribute", + "-Wpacked", + "-Winline", + "-Wdisabled-optimization", + "-Wctor-dtor-privacy", + "-Wnon-virtual-dtor", + "-Wreorder", + "-Wold-style-cast", + "-Woverloaded-virtual", + "-ffor-scope", "-Wextra", "-Wall", ); diff --git a/Test/Xcode/OCTest/CatchOCTestCase.h b/Test/Xcode/OCTest/CatchOCTestCase.h index da6048f3..ebe2c605 100644 --- a/Test/Xcode/OCTest/CatchOCTestCase.h +++ b/Test/Xcode/OCTest/CatchOCTestCase.h @@ -5,6 +5,8 @@ // Created by Phil on 13/11/2010. // Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "../../../catch_objc.hpp" diff --git a/Test/Xcode/OCTest/CatchOCTestCase.mm b/Test/Xcode/OCTest/CatchOCTestCase.mm index 0d0bf42c..b07bf712 100644 --- a/Test/Xcode/OCTest/CatchOCTestCase.mm +++ b/Test/Xcode/OCTest/CatchOCTestCase.mm @@ -5,6 +5,8 @@ // Created by Phil Nash on 13/11/2010. // Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #import "CatchOCTestCase.h" diff --git a/Test/Xcode/OCTest/OCTest.mm b/Test/Xcode/OCTest/OCTest.mm index a98cc872..bf49154d 100644 --- a/Test/Xcode/OCTest/OCTest.mm +++ b/Test/Xcode/OCTest/OCTest.mm @@ -5,6 +5,9 @@ * Created by Phil on 13/11/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * */ #import "../../../catch.hpp" diff --git a/Test/Xcode/OCTest/TestObj.h b/Test/Xcode/OCTest/TestObj.h index ff02713d..26e59286 100644 --- a/Test/Xcode/OCTest/TestObj.h +++ b/Test/Xcode/OCTest/TestObj.h @@ -5,6 +5,8 @@ // Created by Phil on 13/11/2010. // Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #import diff --git a/Test/Xcode/OCTest/TestObj.m b/Test/Xcode/OCTest/TestObj.m index 27f46f37..943f4450 100644 --- a/Test/Xcode/OCTest/TestObj.m +++ b/Test/Xcode/OCTest/TestObj.m @@ -5,6 +5,8 @@ // Created by Phil on 13/11/2010. // Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #import "TestObj.h" diff --git a/catch_objc.hpp b/catch_objc.hpp index 7f459a70..0412f777 100644 --- a/catch_objc.hpp +++ b/catch_objc.hpp @@ -1,6 +1,6 @@ /* * catch_objc.hpp - * Test + * Catch * * Created by Phil on 14/11/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. @@ -18,6 +18,9 @@ #include "catch.hpp" #include "internal/catch_test_case_info.hpp" +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. @protocol OcFixture @optional @@ -32,11 +35,21 @@ namespace Catch class OcMethod : public ITestCase { public: - OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) + /////////////////////////////////////////////////////////////////////// + OcMethod + ( + Class cls, + SEL sel + ) + : m_cls( cls ), + m_sel( sel ) { } - virtual void invoke() const + /////////////////////////////////////////////////////////////////////// + virtual void invoke + () + const { id obj = class_createInstance( m_cls, 0 ); obj = [obj init]; @@ -53,18 +66,31 @@ namespace Catch [obj release]; } - virtual ITestCase* clone() const + /////////////////////////////////////////////////////////////////////// + virtual ITestCase* clone + () + const { return new OcMethod( m_cls, m_sel ); } - virtual bool operator == ( const ITestCase& other ) const + /////////////////////////////////////////////////////////////////////// + virtual bool operator == + ( + const ITestCase& other + ) + const { const OcMethod* ocmOther = dynamic_cast ( &other ); return ocmOther && ocmOther->m_sel == m_sel; } - virtual bool operator < ( const ITestCase& other ) const + /////////////////////////////////////////////////////////////////////// + virtual bool operator < + ( + const ITestCase& other + ) + const { const OcMethod* ocmOther = dynamic_cast ( &other ); return ocmOther && ocmOther->m_sel < m_sel; @@ -78,12 +104,23 @@ namespace Catch namespace Detail { - inline bool startsWith( const std::string& str, const std::string& sub ) + /////////////////////////////////////////////////////////////////////// + inline bool startsWith + ( + const std::string& str, + const std::string& sub + ) { return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub; } - inline const char* getAnnotation( Class cls, const std::string& annotationName, const std::string& testCaseName ) + /////////////////////////////////////////////////////////////////////// + inline const char* getAnnotation + ( + Class cls, + const std::string& annotationName, + const std::string& testCaseName + ) { NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; SEL sel = NSSelectorFromString( selStr ); @@ -94,7 +131,9 @@ namespace Catch } } - inline size_t registerTestMethods() + /////////////////////////////////////////////////////////////////////////// + inline size_t registerTestMethods + () { size_t noTestMethods = 0; int noClasses = objc_getClassList( NULL, 0 ); @@ -130,6 +169,7 @@ namespace Catch } } +/////////////////////////////////////////////////////////////////////////////// #define OC_TEST_CASE( name, desc )\ +(const char*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ {\ diff --git a/catch_objc_main.hpp b/catch_objc_main.hpp index 1ded44c0..7933a636 100644 --- a/catch_objc_main.hpp +++ b/catch_objc_main.hpp @@ -1,6 +1,6 @@ /* * catch_objc_main.hpp - * OCTest + * Catch * * Created by Phil on 28/12/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. diff --git a/internal/catch_interfaces_runner.h b/internal/catch_interfaces_runner.h index 9252f9de..864ce634 100644 --- a/internal/catch_interfaces_runner.h +++ b/internal/catch_interfaces_runner.h @@ -23,7 +23,8 @@ namespace Catch {} virtual void runAll - () = 0; + ( bool runHiddenTests = false + ) = 0; virtual std::size_t runMatching ( const std::string& rawTestSpec diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp index 12537472..a435d69a 100644 --- a/internal/catch_runner_impl.hpp +++ b/internal/catch_runner_impl.hpp @@ -19,6 +19,9 @@ #include "catch_test_case_info.hpp" #include "catch_capture.hpp" +#include +#include + namespace Catch { class TestSpec @@ -194,12 +197,14 @@ namespace Catch /////////////////////////////////////////////////////////////////////////// virtual void runAll - () + ( + bool runHiddenTests = false + ) { std::vector allTests = Hub::getTestCaseRegistry().getAllTests(); for( std::size_t i=0; i < allTests.size(); ++i ) { - if( !allTests[i].isHidden() ) + if( runHiddenTests || !allTests[i].isHidden() ) runTest( allTests[i] ); } }