mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added test for creating class / adding methods. Based on Wolfgang Lux' test example.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32997 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
27aa31a2b4
commit
7fea03e697
1 changed files with 32 additions and 0 deletions
32
Tests/base/Functions/clsCreate.m
Normal file
32
Tests/base/Functions/clsCreate.m
Normal file
|
@ -0,0 +1,32 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "Testing.h"
|
||||
|
||||
static NSString *desc = @"[MyObject]";
|
||||
|
||||
static NSString *
|
||||
myObjectDescription(id self, SEL _cmd)
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
id obj;
|
||||
Class cls;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [NSAutoreleasePool new];
|
||||
cls = (Class)objc_allocateClassPair([NSObject class], "MyObject", 0);
|
||||
if (cls != Nil)
|
||||
{
|
||||
objc_registerClassPair(cls);
|
||||
class_addMethod(cls, @selector(description),
|
||||
(IMP)myObjectDescription, "@@:");
|
||||
obj = [cls new];
|
||||
pass([obj description] == desc, "New class's description method is called correctly");
|
||||
[obj release];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue