Overview
Comment: | 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 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f5b4f0fa39817304820efca20ea57722 |
User & Date: | js on 2024-02-10 14:00:38 |
Original Comment: | 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 |
Other Links: | manifest | tags |
Context
2024-02-10
| ||
14:16 | ObjFWTest: Make sure classes are initialized check-in: f4bb3f5a76 user: js tags: trunk | |
14:02 | Merge trunk into branch "objfwtest" check-in: d47c2a18aa user: js tags: objfwtest | |
14:00 | ObjFWTest: Don't rely on +[isSubclassOfClass:] check-in: f5b4f0fa39 user: js tags: trunk | |
13:14 | Silence warnings coming from OTAssert.h check-in: f264948665 user: js tags: trunk | |
Changes
Modified src/test/OTAppDelegate.m from [7058ecd776] to [1f6282da2f].
︙ | ︙ | |||
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]]; |
︙ | ︙ |