2011-07-24 13:09:22 +00:00
|
|
|
#import "ObjectTesting.h"
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <Foundation/NSHashTable.h>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
[NSAutoreleasePool new];
|
2011-07-26 20:12:32 +00:00
|
|
|
id pool = [NSAutoreleasePool new];
|
|
|
|
NSHashTable *ht = [[NSHashTable hashTableWithWeakObjects] retain];
|
2011-07-24 13:09:22 +00:00
|
|
|
id obj = [NSObject new];
|
|
|
|
[ht addObject: obj];
|
|
|
|
PASS([ht containsObject: obj], "Added object to weak hash table");
|
|
|
|
PASS(1 == [ht count], "Weak hash table contains one object");
|
|
|
|
PASS([ht containsObject: obj], "Added object to weak hash table");
|
|
|
|
[obj release];
|
2011-07-26 20:12:32 +00:00
|
|
|
[pool drain];
|
2011-07-24 13:09:22 +00:00
|
|
|
PASS(0 == [ht count], "Weak hash table contains no objects");
|
|
|
|
PASS(0 == [[ht allObjects] count], "Weak hash table contains no objects");
|
|
|
|
return 0;
|
|
|
|
}
|