mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Fixes nil NSString issue reported in #159
This commit is contained in:
parent
17479c6e49
commit
32e70b2235
@ -161,9 +161,13 @@ inline std::string toString( std::nullptr_t ) {
|
||||
|
||||
#ifdef __OBJC__
|
||||
inline std::string toString( NSString const * const& nsstring ) {
|
||||
if( !nsstring )
|
||||
return "nil";
|
||||
return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
|
||||
}
|
||||
inline std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
|
||||
if( !nsstring )
|
||||
return "nil";
|
||||
return std::string( "@\"" ) + [nsstring UTF8String] + "\"";
|
||||
}
|
||||
inline std::string toString( NSObject* const& nsObject ) {
|
||||
|
@ -74,4 +74,9 @@ OC_TEST_CASE( "OCTest/matchers", "Matches work with OC types (NSString so far)"
|
||||
REQUIRE_THAT( @"This is a string", EndsWith( @"string" ) );
|
||||
}
|
||||
|
||||
OC_TEST_CASE( "OCTest/matchers/nil", "nil NSString should not crash the test" )
|
||||
{
|
||||
REQUIRE_THAT( (NSString*)nil, Equals( @"This should fail, but not crash" ) );
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user