mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix the case where we replace a value already in the map
This commit is contained in:
parent
b78b2e2030
commit
28ba7788ce
4 changed files with 84 additions and 11 deletions
|
@ -6,6 +6,14 @@
|
|||
@end
|
||||
|
||||
@implementation MyClass
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
- (BOOL) isEqual: (id)other
|
||||
{
|
||||
return [other isKindOfClass: [self class]];
|
||||
}
|
||||
#if 0
|
||||
- (oneway void) release
|
||||
{
|
||||
|
@ -27,6 +35,7 @@ int main()
|
|||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMapTable *t;
|
||||
MyClass *o;
|
||||
MyClass *o2;
|
||||
int c;
|
||||
|
||||
t = [[NSMapTable alloc] initWithKeyOptions: NSMapTableObjectPointerPersonality
|
||||
|
@ -78,8 +87,15 @@ int main()
|
|||
[t removeObjectForKey: @"a"];
|
||||
PASS([o retainCount] == c, "remove map table val decrements retain count")
|
||||
|
||||
[t setObject: o forKey: @"a"];
|
||||
o2 = [MyClass new];
|
||||
[t setObject: o2 forKey: @"a"];
|
||||
PASS([o retainCount] == 1, "old instance removed")
|
||||
PASS([o2 retainCount] == 2, "new instance added")
|
||||
|
||||
RELEASE(t);
|
||||
RELEASE(o);
|
||||
RELEASE(o2);
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue