123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "test.h"
- @protocol NewNSCodingSuperProto
- @end
- @protocol NSCoding <NewNSCodingSuperProto>
- @end
- int main()
- {
-
- Protocol* codingSuperProto = objc_getProtocol("NewNSCodingSuperProto");
- Protocol* codingProto = objc_getProtocol("NSCoding");
- if (@protocol(NewNSCodingSuperProto) != codingSuperProto) fail("Protocol mismatch");
- if (@protocol(NSCoding) != codingProto) fail("Protocol mismatch");
- if (!protocol_conformsToProtocol(codingProto, codingSuperProto)) fail("Our NSCoding should conform to NewNSCodingSuperProto");
-
- if (objc_getProtocol("NSSecureCoding")) fail("Test assumes we don't have NSSecureCoding yet");
- if (objc_getClass("NSDictionary")) fail("Test assumes we don't have NSDictionary yet");
- void *dl = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
- if (!dl) fail("couldn't open CoreFoundation");
-
-
- Protocol* secureCodingProto = objc_getProtocol("NSSecureCoding");
- id dictionaryClass = objc_getClass("NSDictionary");
- if (!secureCodingProto) fail("Should have got NSSecureCoding from CoreFoundation");
- if (!dictionaryClass) fail("Should have got NSDictionary from CoreFoundation");
-
- if (!protocol_conformsToProtocol(secureCodingProto, codingProto)) fail("NSSecureCoding should conform to our NSCoding");
- if (!protocol_conformsToProtocol(secureCodingProto, codingSuperProto)) fail("NSSecureCoding should conform to our NewNSCodingSuperProto");
- if (!class_conformsToProtocol(dictionaryClass, codingProto)) fail("NSDictionary should conform to our NSCoding");
- if (!class_conformsToProtocol(dictionaryClass, codingSuperProto)) fail("NSDictionary should conform to our NewNSCodingSuperProto");
- }
|