mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Added toString overload for chars
(and, by extension, Obj-C's BOOL)
This commit is contained in:
parent
e463687725
commit
78372d09d4
@ -115,6 +115,16 @@ inline std::string toString( bool value ) {
|
|||||||
return value ? "true" : "false";
|
return value ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string toString( char value ) {
|
||||||
|
return value < ' '
|
||||||
|
? toString( (unsigned int)value )
|
||||||
|
: Detail::makeString( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string toString( signed char value ) {
|
||||||
|
return toString( static_cast<char>( value ) );
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
inline std::string toString( std::nullptr_t ) {
|
inline std::string toString( std::nullptr_t ) {
|
||||||
return "nullptr";
|
return "nullptr";
|
||||||
|
@ -42,6 +42,12 @@ OC_TEST_CASE( "OCTest/test2", "This is another test case" )
|
|||||||
REQUIRE( obj.int_val == 2 );
|
REQUIRE( obj.int_val == 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OC_TEST_CASE( "OCTest/BOOL", "tests a boolean value" )
|
||||||
|
{
|
||||||
|
CHECK( [obj isTrue] == NO );
|
||||||
|
CHECK( [obj isFalse] == YES );
|
||||||
|
}
|
||||||
|
|
||||||
OC_TEST_CASE( "OCTest/throws/objc", "throws an Objective-C exception" )
|
OC_TEST_CASE( "OCTest/throws/objc", "throws an Objective-C exception" )
|
||||||
{
|
{
|
||||||
@throw [[NSException alloc] initWithName: NSGenericException
|
@throw [[NSException alloc] initWithName: NSGenericException
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
int int_val;
|
int int_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL) isTrue;
|
||||||
|
-(BOOL) isFalse;
|
||||||
|
|
||||||
@property (nonatomic, assign ) int int_val;
|
@property (nonatomic, assign ) int int_val;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -15,4 +15,11 @@
|
|||||||
|
|
||||||
@synthesize int_val;
|
@synthesize int_val;
|
||||||
|
|
||||||
|
-(BOOL) isTrue {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
-(BOOL) isFalse {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Generated: 2012-06-05 20:50:55.068066
|
* Generated: 2012-06-06 08:05:56.928287
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -633,6 +633,16 @@ inline std::string toString( bool value ) {
|
|||||||
return value ? "true" : "false";
|
return value ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string toString( char value ) {
|
||||||
|
return value < ' '
|
||||||
|
? toString( (unsigned int)value )
|
||||||
|
: Detail::makeString( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string toString( signed char value ) {
|
||||||
|
return toString( static_cast<char>( value ) );
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
inline std::string toString( std::nullptr_t ) {
|
inline std::string toString( std::nullptr_t ) {
|
||||||
return "nullptr";
|
return "nullptr";
|
||||||
|
Loading…
Reference in New Issue
Block a user