mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
(Hopefully) Fix Obj-C++ compilation of matchers
Thanks to bdb for the patch, related to #1661
This commit is contained in:
parent
7a6af7ba76
commit
0ab11aa9b4
@ -44,6 +44,15 @@ namespace Matchers {
|
|||||||
virtual bool match( ObjectT const& arg ) const = 0;
|
virtual bool match( ObjectT const& arg ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(__OBJC__)
|
||||||
|
// Hack to fix Catch GH issue #1661. Could use id for generic Object support.
|
||||||
|
// use of const for Object pointers is very uncommon and under ARC it causes some kind of signature mismatch that breaks compilation
|
||||||
|
template<>
|
||||||
|
struct MatcherMethod<NSString*> {
|
||||||
|
virtual bool match( NSString* arg ) const = 0;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,7 +116,7 @@ namespace Catch {
|
|||||||
arcSafeRelease( m_substr );
|
arcSafeRelease( m_substr );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match( NSString* const& str ) const override {
|
bool match( NSString* str ) const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ namespace Catch {
|
|||||||
struct Equals : StringHolder {
|
struct Equals : StringHolder {
|
||||||
Equals( NSString* substr ) : StringHolder( substr ){}
|
Equals( NSString* substr ) : StringHolder( substr ){}
|
||||||
|
|
||||||
bool match( NSString* const& str ) const override {
|
bool match( NSString* str ) const override {
|
||||||
return (str != nil || m_substr == nil ) &&
|
return (str != nil || m_substr == nil ) &&
|
||||||
[str isEqualToString:m_substr];
|
[str isEqualToString:m_substr];
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ namespace Catch {
|
|||||||
struct Contains : StringHolder {
|
struct Contains : StringHolder {
|
||||||
Contains( NSString* substr ) : StringHolder( substr ){}
|
Contains( NSString* substr ) : StringHolder( substr ){}
|
||||||
|
|
||||||
bool match( NSString* const& str ) const override {
|
bool match( NSString* str ) const override {
|
||||||
return (str != nil || m_substr == nil ) &&
|
return (str != nil || m_substr == nil ) &&
|
||||||
[str rangeOfString:m_substr].location != NSNotFound;
|
[str rangeOfString:m_substr].location != NSNotFound;
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ namespace Catch {
|
|||||||
struct StartsWith : StringHolder {
|
struct StartsWith : StringHolder {
|
||||||
StartsWith( NSString* substr ) : StringHolder( substr ){}
|
StartsWith( NSString* substr ) : StringHolder( substr ){}
|
||||||
|
|
||||||
bool match( NSString* const& str ) const override {
|
bool match( NSString* str ) const override {
|
||||||
return (str != nil || m_substr == nil ) &&
|
return (str != nil || m_substr == nil ) &&
|
||||||
[str rangeOfString:m_substr].location == 0;
|
[str rangeOfString:m_substr].location == 0;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ namespace Catch {
|
|||||||
struct EndsWith : StringHolder {
|
struct EndsWith : StringHolder {
|
||||||
EndsWith( NSString* substr ) : StringHolder( substr ){}
|
EndsWith( NSString* substr ) : StringHolder( substr ){}
|
||||||
|
|
||||||
bool match( NSString* const& str ) const override {
|
bool match( NSString* str ) const override {
|
||||||
return (str != nil || m_substr == nil ) &&
|
return (str != nil || m_substr == nil ) &&
|
||||||
[str rangeOfString:m_substr].location == [str length] - [m_substr length];
|
[str rangeOfString:m_substr].location == [str length] - [m_substr length];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user