libs-base/Tests/base/NSHashTable/weak.m
theraven 407c9d0053 Tweak the weak tests so that they should still work, even if -base was compiled
with something that doesn't do a very good job of optimising autorelease
operations away.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33644 72102866-910b-0410-8b05-ffd578937521
2011-07-26 20:12:32 +00:00

20 lines
676 B
Objective-C

#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSHashTable.h>
int main()
{
[NSAutoreleasePool new];
id pool = [NSAutoreleasePool new];
NSHashTable *ht = [[NSHashTable hashTableWithWeakObjects] retain];
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];
[pool drain];
PASS(0 == [ht count], "Weak hash table contains no objects");
PASS(0 == [[ht allObjects] count], "Weak hash table contains no objects");
return 0;
}