diff --git a/include/catch.hpp b/include/catch.hpp index 7ff7c8b9..61321400 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -42,6 +42,7 @@ #include "internal/catch_interfaces_exception.h" #include "internal/catch_approx.hpp" #include "internal/catch_compiler_capabilities.h" +#include "internal/catch_string_manip.h" #ifndef CATCH_CONFIG_DISABLE_MATCHERS #include "internal/catch_capture_matchers.h" diff --git a/include/internal/catch_default_main.hpp b/include/internal/catch_default_main.hpp index 8155c43f..4372e9cc 100644 --- a/include/internal/catch_default_main.hpp +++ b/include/internal/catch_default_main.hpp @@ -32,7 +32,7 @@ int main (int argc, char * const argv[]) { #endif Catch::registerTestMethods(); - int result = Catch::Session().run( argc, (char* const*)argv ); + int result = Catch::Session().run( argc, (char**)argv ); #if !CATCH_ARC_ENABLED [pool drain]; diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index 188f5577..93fbfdfb 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -18,6 +18,8 @@ // in catch.hpp first to make sure they are included by the single // header for non obj-usage #include "catch_test_case_info.h" +#include "catch_string_manip.h" +#include "catch_tostring.h" /////////////////////////////////////////////////////////////////////////////// // This protocol is really only here for (self) documenting purposes, since @@ -91,7 +93,7 @@ namespace Catch { std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); const char* className = class_getName( cls ); - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo("",0) ) ); noTestMethods++; } } @@ -118,7 +120,7 @@ namespace Catch { return false; } - NSString* m_substr; + NSString* CATCH_ARC_STRONG m_substr; }; struct Equals : StringHolder { @@ -130,7 +132,7 @@ namespace Catch { } std::string describe() const override { - return "equals string: " + Catch::toString( m_substr ); + return "equals string: " + Catch::Detail::stringify( m_substr ); } }; @@ -143,7 +145,7 @@ namespace Catch { } std::string describe() const override { - return "contains string: " + Catch::toString( m_substr ); + return "contains string: " + Catch::Detail::stringify( m_substr ); } }; @@ -156,7 +158,7 @@ namespace Catch { } std::string describe() const override { - return "starts with: " + Catch::toString( m_substr ); + return "starts with: " + Catch::Detail::stringify( m_substr ); } }; struct EndsWith : StringHolder { @@ -168,7 +170,7 @@ namespace Catch { } std::string describe() const override { - return "ends with: " + Catch::toString( m_substr ); + return "ends with: " + Catch::Detail::stringify( m_substr ); } }; @@ -196,15 +198,18 @@ namespace Catch { } // namespace Catch /////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ { \ return @ desc; \ } \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) #endif // TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED diff --git a/include/internal/catch_tostring.cpp b/include/internal/catch_tostring.cpp index f3b9267c..56aefa63 100644 --- a/include/internal/catch_tostring.cpp +++ b/include/internal/catch_tostring.cpp @@ -210,20 +210,4 @@ std::string StringMaker::convert(double value) { } -#ifdef __OBJC__ -std::string StringMaker::convert(NSString* nsstring) { - if (!nsstring) - return "nil"; - return "@" + toString([nsstring UTF8String]); -} -std::string StringMaker::convert(NSString* CATCH_ARC_STRONG nsstring) { - if (!nsstring) - return "nil"; - return "@" + toString([nsstring UTF8String]); -} -std::string StringMaker::convert(NSObject* nsObject) { - return ::Catch::Detail::stringify([nsObject description]); -} -#endif - } // end namespace Catch diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 81d122d6..5a82eba6 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -299,17 +299,26 @@ namespace Catch { #ifdef __OBJC__ template<> struct StringMaker { - static std::string convert(NSString* nsstring); + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } }; template<> - struct StringMaker { - static std::string convert(NSString * CATCH_ARC_STRONG nsstring); + struct StringMaker { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + }; - template<> - struct StringMaker { - static std::string convert(NSObject* nsObject); - }; -#endif + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ } // namespace Catch