Differences From Artifact [7058ecd776]:
- File src/test/OTAppDelegate.m — part of check-in [0ceea01454] at 2024-02-10 12:55:59 on branch trunk — Add ObjFWTest (user: js, size: 3934) [annotate] [blame] [check-ins using] [more...]
To Artifact [1f6282da2f]:
- File
src/test/OTAppDelegate.m
— part of check-in
[f5b4f0fa39]
at
2024-02-10 14:00:38
on branch trunk
— ObjFWTest: Don't rely on +[isSubclassOfClass:]
Not all classes returned by objc_copyClassList() might have this method.
This fixes crashing when using the Apple runtime (which presumably has
some internal classes without said method). (user: js, size: 4130) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFValue.h" #import "OTTestCase.h" #import "OTAssertionFailedException.h" OF_APPLICATION_DELEGATE(OTAppDelegate) @implementation OTAppDelegate - (OFSet OF_GENERIC(Class) *)testClasses { Class *classes = objc_copyClassList(NULL); OFMutableSet *testClasses; if (classes == NULL) return nil; @try { testClasses = [OFMutableSet set]; for (Class *iter = classes; *iter != Nil; iter++) | > > > > > > > > > > | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #import "OFValue.h" #import "OTTestCase.h" #import "OTAssertionFailedException.h" OF_APPLICATION_DELEGATE(OTAppDelegate) static bool isSubclassOfClass(Class class, Class superclass) { for (Class iter = class; iter != Nil; iter = class_getSuperclass(iter)) if (iter == superclass) return true; return false; } @implementation OTAppDelegate - (OFSet OF_GENERIC(Class) *)testClasses { Class *classes = objc_copyClassList(NULL); OFMutableSet *testClasses; if (classes == NULL) return nil; @try { testClasses = [OFMutableSet set]; for (Class *iter = classes; *iter != Nil; iter++) if (isSubclassOfClass(*iter, [OTTestCase class])) [testClasses addObject: *iter]; } @finally { OFFreeMemory(classes); } [testClasses removeObject: [OTTestCase class]]; |
︙ | ︙ |