diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp index b0a697e5..8fd88ad1 100644 --- a/include/internal/catch_matchers.hpp +++ b/include/internal/catch_matchers.hpp @@ -15,9 +15,11 @@ namespace Matchers { template struct Matcher : SharedImpl { + typedef ExpressionT ExpressionType; + virtual ~Matcher() {} virtual Ptr clone() const = 0; - virtual bool match( const ExpressionT& expr ) const = 0; + virtual bool match( ExpressionT const& expr ) const = 0; virtual std::string toString() const = 0; }; diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index dbc5a97f..eb8c5264 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -93,7 +93,7 @@ namespace Catch { std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - getMutableRegistryHub().registerTest( TestCase( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) ); + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), "", name.c_str(), desc.c_str(), SourceLineInfo() ) ); noTestMethods++; } } @@ -107,8 +107,10 @@ namespace Catch { namespace Impl { namespace NSStringMatchers { - struct StringHolder { + template + struct StringHolder : MatcherImpl{ StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} StringHolder() { arcSafeRelease( m_substr ); } @@ -116,54 +118,50 @@ namespace Catch { NSString* m_substr; }; - struct Equals : StringHolder { + struct Equals : StringHolder { Equals( NSString* substr ) : StringHolder( substr ){} - bool operator()( NSString* str ) const { + virtual bool match( ExpressionType const& str ) const { return [str isEqualToString:m_substr]; } - friend std::ostream& operator<<( std::ostream& os, const Equals& matcher ) { - os << "equals string: " << Catch::toString( matcher.m_substr ); - return os; + virtual std::string toString() const { + return "equals string: \"" + Catch::toString( m_substr ) + "\""; } }; - struct Contains : StringHolder { + struct Contains : StringHolder { Contains( NSString* substr ) : StringHolder( substr ){} - bool operator()( NSString* str ) const { + virtual bool match( ExpressionType const& str ) const { return [str rangeOfString:m_substr].location != NSNotFound; } - friend std::ostream& operator<<( std::ostream& os, const Contains& matcher ) { - os << "contains: " << Catch::toString( matcher.m_substr ); - return os; + virtual std::string toString() const { + return "contains string: \"" + Catch::toString( m_substr ) + "\""; } }; - struct StartsWith : StringHolder { + struct StartsWith : StringHolder { StartsWith( NSString* substr ) : StringHolder( substr ){} - bool operator()( NSString* str ) const { + virtual bool match( ExpressionType const& str ) const { return [str rangeOfString:m_substr].location == 0; } - friend std::ostream& operator<<( std::ostream& os, const StartsWith& matcher ) { - os << "starts with: " << Catch::toString( matcher.m_substr ); - return os; + virtual std::string toString() const { + return "starts with: \"" + Catch::toString( m_substr ) + "\""; } }; - struct EndsWith : StringHolder { + struct EndsWith : StringHolder { EndsWith( NSString* substr ) : StringHolder( substr ){} - bool operator()( NSString* str ) const { + virtual bool match( ExpressionType const& str ) const { return [str rangeOfString:m_substr].location == [str length] - [m_substr length]; } - friend std::ostream& operator<<( std::ostream& os, const EndsWith& matcher ) { - os << "ends with: " << Catch::toString( matcher.m_substr ); - return os; + virtual std::string toString() const { + return "ends with: \"" + Catch::toString( m_substr ) + "\""; } }; diff --git a/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj b/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj index d6db4ae8..93f668c3 100644 --- a/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj @@ -208,7 +208,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; - HEADER_SEARCH_PATHS = ../../../single_include; + HEADER_SEARCH_PATHS = ../../../include; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -217,7 +217,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; - HEADER_SEARCH_PATHS = ../../../single_include; + HEADER_SEARCH_PATHS = ../../../include; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release;