| 3270 | } |
| 3271 | |
| 3272 | inline size_t registerTestMethods() { |
| 3273 | size_t noTestMethods = 0; |
| 3274 | int noClasses = objc_getClassList( CATCH_NULL, 0 ); |
| 3275 | |
| 3276 | Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); |
| 3277 | objc_getClassList( classes, noClasses ); |
| 3278 | |
| 3279 | for( int c = 0; c < noClasses; c++ ) { |
| 3280 | Class cls = classes[c]; |
| 3281 | { |
| 3282 | u_int count; |
| 3283 | Method* methods = class_copyMethodList( cls, &count ); |
| 3284 | for( u_int m = 0; m < count ; m++ ) { |
| 3285 | SEL selector = method_getName(methods[m]); |
| 3286 | std::string methodName = sel_getName(selector); |
| 3287 | if( startsWith( methodName, "Catch_TestCase_" ) ) { |
| 3288 | std::string testCaseName = methodName.substr( 15 ); |
| 3289 | std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); |
| 3290 | std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); |
| 3291 | const char* className = class_getName( cls ); |
| 3292 | |
| 3293 | getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); |
| 3294 | noTestMethods++; |
| 3295 | } |
| 3296 | } |
| 3297 | free(methods); |
| 3298 | } |
| 3299 | } |
| 3300 | return noTestMethods; |
| 3301 | } |
| 3302 | |
| 3303 | namespace Matchers { |
| 3304 | namespace Impl { |
no test coverage detected