2011-03-28 16:26:47 +00:00
|
|
|
#import "ObjectTesting.h"
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <AppKit/NSApplication.h>
|
|
|
|
#import <AppKit/NSCell.h>
|
2013-03-18 22:50:11 +00:00
|
|
|
#import <AppKit/NSImage.h>
|
2011-03-28 16:26:47 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2013-03-18 22:50:11 +00:00
|
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
2011-03-28 16:26:47 +00:00
|
|
|
id testObject;
|
2013-03-18 22:50:11 +00:00
|
|
|
id testObject1;
|
|
|
|
id testObject2;
|
|
|
|
NSArray *testObjects;
|
2011-03-28 16:26:47 +00:00
|
|
|
|
2016-05-13 15:41:27 +00:00
|
|
|
START_SET("NSCell GNUstep basic")
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[NSApplication sharedApplication];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
if ([[localException name] isEqualToString: NSInternalInconsistencyException ])
|
|
|
|
SKIP("It looks like GNUstep backend is not yet installed")
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
2013-03-18 22:50:11 +00:00
|
|
|
|
2011-03-28 16:26:47 +00:00
|
|
|
test_alloc(@"NSCell");
|
2013-03-18 22:50:11 +00:00
|
|
|
|
|
|
|
testObject = [NSCell new];
|
|
|
|
testObject1 = [[NSCell alloc] initImageCell: [NSImage imageNamed: @"GNUstep"]];
|
|
|
|
testObject2 = [[NSCell alloc] initTextCell: @"GNUstep"];
|
|
|
|
|
|
|
|
testObjects = [NSArray arrayWithObjects: testObject, testObject1, testObject2, nil];
|
|
|
|
test_NSObject(@"NSCell", testObjects);
|
|
|
|
test_NSCoding(testObjects);
|
|
|
|
test_keyed_NSCoding(testObjects);
|
2011-03-28 16:26:47 +00:00
|
|
|
test_NSCopying(@"NSCell",
|
|
|
|
@"NSCell",
|
2013-03-18 22:50:11 +00:00
|
|
|
testObjects, NO, NO);
|
2011-03-28 16:26:47 +00:00
|
|
|
|
2016-05-13 15:41:27 +00:00
|
|
|
END_SET("NSCell GNUstep basic")
|
2013-03-18 22:50:11 +00:00
|
|
|
[arp release];
|
2011-03-28 16:26:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@implementation NSCell (Testing)
|
|
|
|
|
|
|
|
- (BOOL) isEqual: (id)anObject
|
|
|
|
{
|
|
|
|
if (self == anObject)
|
|
|
|
return YES;
|
|
|
|
if (![anObject isKindOfClass: [NSCell class]])
|
|
|
|
return NO;
|
2017-12-28 16:18:03 +00:00
|
|
|
if (![[(NSCell *)anObject stringValue] isEqual: [self stringValue]])
|
2011-03-28 16:26:47 +00:00
|
|
|
return NO;
|
2017-12-28 16:18:03 +00:00
|
|
|
if (![[(NSCell *)anObject title] isEqual: [self title]])
|
2011-03-28 16:26:47 +00:00
|
|
|
return NO;
|
2017-12-28 16:18:03 +00:00
|
|
|
if (!([(NSCell *)anObject image] == [self image])
|
|
|
|
&& ![[(NSCell *)anObject image] isEqual: [self image]])
|
2013-03-18 22:50:11 +00:00
|
|
|
{
|
|
|
|
NSLog(@"image differ %@ %@", [self image], [anObject image]);
|
|
|
|
return NO;
|
|
|
|
}
|
2017-12-28 16:18:03 +00:00
|
|
|
if ([(NSCell *)anObject type] != [self type])
|
2011-03-28 16:26:47 +00:00
|
|
|
return NO;
|
2017-12-28 16:18:03 +00:00
|
|
|
if ([(NSCell *)anObject tag] != [self tag])
|
2011-03-28 16:26:47 +00:00
|
|
|
return NO;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2017-12-28 16:18:03 +00:00
|
|
|
@end
|