1996-04-17 18:46:15 +00:00
|
|
|
#include <gnustep/base/all.h>
|
1996-02-22 15:03:00 +00:00
|
|
|
#include <Foundation/NSValue.h>
|
1996-04-17 18:40:03 +00:00
|
|
|
#include <gnustep/base/Invocation.h>
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1996-02-22 15:03:00 +00:00
|
|
|
@interface ConstantCollection (TestingExtras)
|
1994-11-04 16:29:24 +00:00
|
|
|
- printCount;
|
|
|
|
@end
|
1996-02-22 15:03:00 +00:00
|
|
|
@implementation ConstantCollection (TestingExtras)
|
1994-11-04 16:29:24 +00:00
|
|
|
- printCount
|
|
|
|
{
|
1996-03-30 22:43:33 +00:00
|
|
|
printf("%s: count=%d\n", object_get_class_name (self), [self count]);
|
1994-11-04 16:29:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
void checkSameContents(id objectslist)
|
|
|
|
{
|
|
|
|
unsigned i, c = [objectslist count];
|
|
|
|
|
|
|
|
for (i = 1; i < c; i++)
|
|
|
|
if (![[objectslist objectAtIndex:0]
|
|
|
|
contentsEqual:[objectslist objectAtIndex:i]])
|
|
|
|
printf("collection 0 does not have same contents as collection %d\n", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
1996-02-22 15:03:00 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
id array = [Array new];
|
1996-03-30 22:43:33 +00:00
|
|
|
// id bag = [Bag new];
|
|
|
|
// id set = [Set new];
|
1996-02-22 15:03:00 +00:00
|
|
|
id stack = [Stack new];
|
|
|
|
id queue = [Queue new];
|
|
|
|
id gaparray = [GapArray new];
|
|
|
|
id foo = [Array new];
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
id collections = [DelegatePool new];
|
|
|
|
|
|
|
|
[collections delegatePoolAddObject:array];
|
1996-02-22 15:03:00 +00:00
|
|
|
// [collections delegatePoolAddObject:bag];
|
|
|
|
// [collections delegatePoolAddObject:set];
|
1994-11-04 16:29:24 +00:00
|
|
|
[collections delegatePoolAddObject:stack];
|
|
|
|
[collections delegatePoolAddObject:queue];
|
|
|
|
[collections delegatePoolAddObject:gaparray];
|
|
|
|
[collections delegatePoolAddObject:foo];
|
|
|
|
|
|
|
|
printf("delegatePool filled, count=%d\n",
|
|
|
|
[[collections delegatePoolCollection] count]);
|
|
|
|
|
1996-02-22 15:03:00 +00:00
|
|
|
[collections addObject: [NSNumber numberWithInt: 99]];
|
1994-11-04 16:29:24 +00:00
|
|
|
[collections printCount];
|
|
|
|
|
|
|
|
printf("Adding numbers...\n");
|
1996-02-22 15:03:00 +00:00
|
|
|
for (i = 1; i < 17; i++)
|
1994-11-04 16:29:24 +00:00
|
|
|
{
|
1996-02-22 15:03:00 +00:00
|
|
|
printf("%2d ", i);
|
|
|
|
[collections addObject: [NSNumber numberWithInt: i]];
|
1994-11-04 16:29:24 +00:00
|
|
|
}
|
|
|
|
printf("\ncollections filled\n\n");
|
|
|
|
[collections printForDebugger];
|
|
|
|
|
|
|
|
{
|
1996-02-22 15:03:00 +00:00
|
|
|
id inv = [[MethodInvocation alloc]
|
|
|
|
initWithTarget: nil
|
|
|
|
selector: @selector(isEqual:),
|
|
|
|
[NSNumber numberWithInt:0]];
|
|
|
|
if ([array trueForAllObjectsByInvoking: inv])
|
1994-11-04 16:29:24 +00:00
|
|
|
printf("Array contains no zero's\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
checkSameContents([collections delegatePoolCollection]);
|
|
|
|
|
|
|
|
printf("\nremoving 99\n\n");
|
1996-02-22 15:03:00 +00:00
|
|
|
[collections removeObject: [NSNumber numberWithInt: 99]];
|
1994-11-04 16:29:24 +00:00
|
|
|
|
1996-02-22 15:03:00 +00:00
|
|
|
[foo removeObject:[foo minObject]];
|
|
|
|
[foo addObject: [NSNumber numberWithInt: 99]];
|
1996-09-02 13:20:20 +00:00
|
|
|
printf("Collections 0 and 4 should mismatch\n");
|
1994-11-04 16:29:24 +00:00
|
|
|
[collections printForDebugger];
|
|
|
|
|
|
|
|
checkSameContents([collections delegatePoolCollection]);
|
|
|
|
|
1995-04-05 16:15:15 +00:00
|
|
|
[collections release];
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|