mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Implement dast enumeration mutation checks and add testcases for NSPointerArray
This commit is contained in:
parent
39b1b7fd01
commit
c225efa3ba
2 changed files with 49 additions and 6 deletions
|
@ -1,8 +1,4 @@
|
|||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSOrderedSet.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ObjectTesting.h"
|
||||
#import "../../../Source/GSFastEnumeration.h"
|
||||
|
||||
|
@ -10,6 +6,25 @@ static SEL add;
|
|||
static SEL set;
|
||||
static SEL key;
|
||||
|
||||
@implementation NSPointerArray (TestHelpers)
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
[self addPointer: anObject];
|
||||
}
|
||||
- (void) removeObject: (id)anObject
|
||||
{
|
||||
int i = [self count];
|
||||
|
||||
while (i-- > 0)
|
||||
{
|
||||
if ([self pointerAtIndex: i] == (void*)anObject)
|
||||
{
|
||||
[self removePointerAtIndex: i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
void fast_enumeration_mutation_add(id mutableCollection)
|
||||
{
|
||||
NSUInteger i = 0;
|
||||
|
@ -139,6 +154,14 @@ int main()
|
|||
test_fast_enumeration(table, objects);
|
||||
END_SET("NSHashTable")
|
||||
|
||||
START_SET("NSPointerArray")
|
||||
id array = [NSPointerArray weakObjectsPointerArray];
|
||||
FOR_IN(id, o, objects)
|
||||
[array addPointer: o];
|
||||
END_FOR_IN(objects)
|
||||
test_fast_enumeration(array, objects);
|
||||
END_SET("NSPointerArray")
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue