Skip NSHashTable/NSMapTable weak objects tests if ARC is unavailable

This commit is contained in:
Frederik Seiffert 2019-12-10 10:45:53 +01:00
parent 260a2cb969
commit d8565b075f
2 changed files with 22 additions and 0 deletions

View file

@ -1,9 +1,19 @@
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSHashTable.h>
#if __has_include(<objc/capabilities.h>)
#include <objc/capabilities.h>
#endif
int main()
{
START_SET("NSHashTable weak objects")
#ifdef OBJC_CAP_ARC
if (!objc_test_capability(OBJC_CAP_ARC))
#endif
{
SKIP("ARC support unavailable")
}
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSHashTable *hashTable = [NSHashTable weakObjectsHashTable];
@ -18,5 +28,6 @@ int main()
PASS([[hashTable allObjects] count] == 0, "Table removes dead weak reference");
[arp release]; arp = nil;
END_SET("NSHashTable weak objects")
return 0;
}

View file

@ -1,9 +1,19 @@
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSMapTable.h>
#if __has_include(<objc/capabilities.h>)
#include <objc/capabilities.h>
#endif
int main()
{
START_SET("NSMapTable weak objects")
#ifdef OBJC_CAP_ARC
if (!objc_test_capability(OBJC_CAP_ARC))
#endif
{
SKIP("ARC support unavailable")
}
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSMapTable *mapTable = [NSMapTable strongToWeakObjectsMapTable];
@ -18,5 +28,6 @@ int main()
PASS([mapTable objectForKey:@"test"] == nil, "Table removes dead weak reference");
[arp release]; arp = nil;
END_SET("NSMapTable weak objects")
return 0;
}