Some clean-up

This commit is contained in:
Phil Nash 2011-02-08 08:42:05 +00:00
parent 9d1259273f
commit 58e9a8bafd
10 changed files with 90 additions and 13 deletions

View File

@ -327,6 +327,26 @@
PREBINDING = NO; PREBINDING = NO;
SDKROOT = macosx10.6; SDKROOT = macosx10.6;
WARNING_CFLAGS = ( 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", "-Wextra",
"-Wall", "-Wall",
); );

View File

@ -5,6 +5,8 @@
// Created by Phil on 13/11/2010. // Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // 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" #include "../../../catch_objc.hpp"

View File

@ -5,6 +5,8 @@
// Created by Phil Nash on 13/11/2010. // Created by Phil Nash on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // 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" #import "CatchOCTestCase.h"

View File

@ -5,6 +5,9 @@
* Created by Phil on 13/11/2010. * Created by Phil on 13/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * 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" #import "../../../catch.hpp"

View File

@ -5,6 +5,8 @@
// Created by Phil on 13/11/2010. // Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // 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 <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>

View File

@ -5,6 +5,8 @@
// Created by Phil on 13/11/2010. // Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved. // 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" #import "TestObj.h"

View File

@ -1,6 +1,6 @@
/* /*
* catch_objc.hpp * catch_objc.hpp
* Test * Catch
* *
* Created by Phil on 14/11/2010. * Created by Phil on 14/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
@ -18,6 +18,9 @@
#include "catch.hpp" #include "catch.hpp"
#include "internal/catch_test_case_info.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 @protocol OcFixture
@optional @optional
@ -32,11 +35,21 @@ namespace Catch
class OcMethod : public ITestCase class OcMethod : public ITestCase
{ {
public: 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 ); id obj = class_createInstance( m_cls, 0 );
obj = [obj init]; obj = [obj init];
@ -53,18 +66,31 @@ namespace Catch
[obj release]; [obj release];
} }
virtual ITestCase* clone() const ///////////////////////////////////////////////////////////////////////
virtual ITestCase* clone
()
const
{ {
return new OcMethod( m_cls, m_sel ); 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<const OcMethod*> ( &other ); const OcMethod* ocmOther = dynamic_cast<const OcMethod*> ( &other );
return ocmOther && ocmOther->m_sel == m_sel; 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<const OcMethod*> ( &other ); const OcMethod* ocmOther = dynamic_cast<const OcMethod*> ( &other );
return ocmOther && ocmOther->m_sel < m_sel; return ocmOther && ocmOther->m_sel < m_sel;
@ -78,12 +104,23 @@ namespace Catch
namespace Detail 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; 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()]; NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
SEL sel = NSSelectorFromString( selStr ); SEL sel = NSSelectorFromString( selStr );
@ -94,7 +131,9 @@ namespace Catch
} }
} }
inline size_t registerTestMethods() ///////////////////////////////////////////////////////////////////////////
inline size_t registerTestMethods
()
{ {
size_t noTestMethods = 0; size_t noTestMethods = 0;
int noClasses = objc_getClassList( NULL, 0 ); int noClasses = objc_getClassList( NULL, 0 );
@ -130,6 +169,7 @@ namespace Catch
} }
} }
///////////////////////////////////////////////////////////////////////////////
#define OC_TEST_CASE( name, desc )\ #define OC_TEST_CASE( name, desc )\
+(const char*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ +(const char*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \
{\ {\

View File

@ -1,6 +1,6 @@
/* /*
* catch_objc_main.hpp * catch_objc_main.hpp
* OCTest * Catch
* *
* Created by Phil on 28/12/2010. * Created by Phil on 28/12/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.

View File

@ -23,7 +23,8 @@ namespace Catch
{} {}
virtual void runAll virtual void runAll
() = 0; ( bool runHiddenTests = false
) = 0;
virtual std::size_t runMatching virtual std::size_t runMatching
( const std::string& rawTestSpec ( const std::string& rawTestSpec

View File

@ -19,6 +19,9 @@
#include "catch_test_case_info.hpp" #include "catch_test_case_info.hpp"
#include "catch_capture.hpp" #include "catch_capture.hpp"
#include <set>
#include <string>
namespace Catch namespace Catch
{ {
class TestSpec class TestSpec
@ -194,12 +197,14 @@ namespace Catch
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
virtual void runAll virtual void runAll
() (
bool runHiddenTests = false
)
{ {
std::vector<TestCaseInfo> allTests = Hub::getTestCaseRegistry().getAllTests(); std::vector<TestCaseInfo> allTests = Hub::getTestCaseRegistry().getAllTests();
for( std::size_t i=0; i < allTests.size(); ++i ) for( std::size_t i=0; i < allTests.size(); ++i )
{ {
if( !allTests[i].isHidden() ) if( runHiddenTests || !allTests[i].isHidden() )
runTest( allTests[i] ); runTest( allTests[i] );
} }
} }