Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Added toString overload for chars

(and, by extension, Obj-C's BOOL)
Commit
78372d09d469590b3e57e14d2fa8f41667cbdc77
Author
Phil Nash ·
Parents
e463687725b1

Files · Download .tar.gz

Changes

 include/internal/catch_tostring.hpp              | 10 ++++++++++
 projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm |  6 ++++++
 projects/XCode4/OCTest/OCTest/TestObj.h          |  3 +++
 projects/XCode4/OCTest/OCTest/TestObj.m          |  7 +++++++
 single_include/catch.hpp                         | 12 +++++++++++-
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp
index 551bafbc..9b4cf9b3 100644
--- a/include/internal/catch_tostring.hpp
+++ b/include/internal/catch_tostring.hpp
@@ -115,6 +115,16 @@ inline std::string toString( bool value ) {
     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
 inline std::string toString( std::nullptr_t ) {
     return "nullptr";
diff --git a/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm b/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
index 4b67efee..032660f3 100644
--- a/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
+++ b/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
@@ -42,6 +42,12 @@ OC_TEST_CASE( "OCTest/test2", "This is another test case" )
     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" )
 {
     @throw [[NSException alloc] initWithName: NSGenericException
diff --git a/projects/XCode4/OCTest/OCTest/TestObj.h b/projects/XCode4/OCTest/OCTest/TestObj.h
index 388e9a8d..be0a4141 100644
--- a/projects/XCode4/OCTest/OCTest/TestObj.h
+++ b/projects/XCode4/OCTest/OCTest/TestObj.h
@@ -16,6 +16,9 @@
     int int_val;
 }
 
+-(BOOL) isTrue;
+-(BOOL) isFalse;
+
 @property (nonatomic, assign ) int int_val;
 
 @end
diff --git a/projects/XCode4/OCTest/OCTest/TestObj.m b/projects/XCode4/OCTest/OCTest/TestObj.m
index 943f4450..2c7dc99b 100644
--- a/projects/XCode4/OCTest/OCTest/TestObj.m
+++ b/projects/XCode4/OCTest/OCTest/TestObj.m
@@ -15,4 +15,11 @@
 
 @synthesize int_val;
 
+-(BOOL) isTrue {
+    return YES;
+}
+-(BOOL) isFalse {
+    return NO;
+}
+
 @end
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index 556cb916..3921b1c7 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -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
  *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -633,6 +633,16 @@ inline std::string toString( bool value ) {
     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
 inline std::string toString( std::nullptr_t ) {
     return "nullptr";