| 2770 | } // namespace Detail |
| 2771 | |
| 2772 | inline std::size_t registerTestMethods() { |
| 2773 | std::size_t noTestMethods = 0; |
| 2774 | int noClasses = objc_getClassList(nullptr, 0); |
| 2775 | |
| 2776 | Class *classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc(sizeof(Class) * noClasses); |
| 2777 | objc_getClassList(classes, noClasses); |
| 2778 | |
| 2779 | for (int c = 0; c < noClasses; c++) { |
| 2780 | Class cls = classes[c]; |
| 2781 | { |
| 2782 | u_int count; |
| 2783 | Method *methods = class_copyMethodList(cls, &count); |
| 2784 | for (u_int m = 0; m < count; m++) { |
| 2785 | SEL selector = method_getName(methods[m]); |
| 2786 | std::string methodName = sel_getName(selector); |
| 2787 | if (startsWith(methodName, "Catch_TestCase_")) { |
| 2788 | std::string testCaseName = methodName.substr(15); |
| 2789 | std::string name = Detail::getAnnotation(cls, "Name", testCaseName); |
| 2790 | std::string desc = Detail::getAnnotation(cls, "Description", testCaseName); |
| 2791 | const char *className = class_getName(cls); |
| 2792 | |
| 2793 | getMutableRegistryHub().registerTest( |
| 2794 | makeTestCase(new OcMethod(cls, selector), className, name.c_str(), desc.c_str(), SourceLineInfo("", 0))); |
| 2795 | noTestMethods++; |
| 2796 | } |
| 2797 | } |
| 2798 | free(methods); |
| 2799 | } |
| 2800 | } |
| 2801 | return noTestMethods; |
| 2802 | } |
| 2803 | |
| 2804 | #if !defined(CATCH_CONFIG_DISABLE_MATCHERS) |
| 2805 |
no test coverage detected