mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32187 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
734c214892
commit
0e02133729
374 changed files with 20864 additions and 0 deletions
13
Tests/base/NSObject/basic.m
Normal file
13
Tests/base/NSObject/basic.m
Normal file
|
@ -0,0 +1,13 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
test_alloc(@"NSObject");
|
||||
test_NSObject(@"NSObject", [NSArray arrayWithObject:[[NSObject new] autorelease]]);
|
||||
PASS([[[NSObject new] autorelease] methodSignatureForSelector: 0] == nil,
|
||||
"a null selector proiduces a nil method signature");
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
12
Tests/base/NSObject/test00.m
Normal file
12
Tests/base/NSObject/test00.m
Normal file
|
@ -0,0 +1,12 @@
|
|||
#import "Testing.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
Class theClass = NSClassFromString(@"NSObject");
|
||||
PASS(theClass == [NSObject class],
|
||||
"'NSObject' %s","uses +class to return self");
|
||||
return 0;
|
||||
}
|
63
Tests/base/NSObject/test01.m
Normal file
63
Tests/base/NSObject/test01.m
Normal file
|
@ -0,0 +1,63 @@
|
|||
#import "Testing.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
@interface MyEvilClass : NSObject
|
||||
{
|
||||
Class class;
|
||||
const char *name;
|
||||
long version;
|
||||
unsigned long info;
|
||||
/* not sure which of these is correct */
|
||||
Class class_;
|
||||
const char *name_;
|
||||
long version_;
|
||||
unsigned long info_;
|
||||
}
|
||||
-(void)setInfo:(unsigned long)info;
|
||||
@end
|
||||
|
||||
@implementation MyEvilClass
|
||||
-(void)setInfo:(unsigned long)theInfo
|
||||
{
|
||||
info = theInfo;
|
||||
}
|
||||
@end
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
id evilObject;
|
||||
PASS([NSObject isClass] &&
|
||||
[NSString isClass] &&
|
||||
[NSArray isClass],
|
||||
"-isClass returns YES on a Class");
|
||||
|
||||
PASS((![[[NSObject new] autorelease] isClass] &&
|
||||
![[NSString stringWithCString:"foo"] isClass] &&
|
||||
![[[NSArray new] autorelease] isClass]),
|
||||
"-isClass returns NO on an instance");
|
||||
|
||||
evilObject = [MyEvilClass new];
|
||||
[evilObject setInfo:1];
|
||||
PASS(![evilObject isClass],
|
||||
"-isClass returns NO on an instance (special test for broken libobjc)");
|
||||
|
||||
PASS(([[[NSObject new] autorelease] isKindOfClass:[NSObject class]] &&
|
||||
[[[NSString new] autorelease] isKindOfClass:[NSString class]] &&
|
||||
![[[NSObject new] autorelease] isKindOfClass:[NSString class]] &&
|
||||
[[[NSString new] autorelease] isKindOfClass:[NSObject class]] &&
|
||||
![[[NSString new] autorelease] isKindOfClass:[NSArray class]] &&
|
||||
[[[NSMutableString new] autorelease] isKindOfClass:[NSString class]]),
|
||||
"-isKindOfClass: works");
|
||||
|
||||
/* should return YES if receiver and argument are both NSObject */
|
||||
PASS([NSObject isKindOfClass:[NSObject class]] &&
|
||||
![NSString isKindOfClass:[NSString class]] &&
|
||||
![NSObject isKindOfClass:[NSString class]] &&
|
||||
[NSString isKindOfClass:[NSObject class]],
|
||||
"+isKindOfClass: works");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
55
Tests/base/NSObject/test02.m
Normal file
55
Tests/base/NSObject/test02.m
Normal file
|
@ -0,0 +1,55 @@
|
|||
#import "Testing.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
/* Nicola Pero, Tue Dec 18 17:54:53 GMT 2001 */
|
||||
@protocol DoingNothing
|
||||
- (void) doNothing;
|
||||
@end
|
||||
|
||||
@protocol DoingNothingCategory
|
||||
- (void) doNothingCategory;
|
||||
@end
|
||||
|
||||
|
||||
@interface NicolaTest : NSObject <DoingNothing>
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NicolaTest
|
||||
- (void) doNothing
|
||||
{
|
||||
return;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NicolaTest (Category) <DoingNothingCategory>
|
||||
@end
|
||||
|
||||
@implementation NicolaTest (Category)
|
||||
- (void) doNothingCategory
|
||||
{
|
||||
return;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
PASS([NicolaTest conformsToProtocol:@protocol(DoingNothing)],
|
||||
"+conformsToProtocol returns YES on an implemented protocol");
|
||||
PASS([NicolaTest conformsToProtocol:@protocol(DoingNothingCategory)],
|
||||
"+conformsToProtocol returns YES on a protocol implemented in a category");
|
||||
PASS(![NicolaTest conformsToProtocol:@protocol(NSCoding)],
|
||||
"+conformsToProtocol returns NO on an unimplemented protocol");
|
||||
PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothing)],
|
||||
"-conformsToProtocol returns YES on an implemented protocol");
|
||||
PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothingCategory)],
|
||||
"-conformsToProtocol returns YES on a protocol implemented in a category");
|
||||
PASS(![[NicolaTest new] conformsToProtocol:@protocol(NSCoding)],
|
||||
"-conformsToProtocol returns NO on an unimplemented protocol");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue