@@ -16,17 +16,25 @@ #import "OFExceptions.h" #import "TestsAppDelegate.h" static OFString *module = @"OFObject"; + +@interface MyObj: OFObject +@end + +@implementation MyObj +@end @implementation TestsAppDelegate (OFObjectTests) - (void)objectTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFObject *obj = [[[OFObject alloc] init] autorelease]; void *p, *q, *r; + OFObject *o; + MyObj *m; EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj freeMemory: (void*)1]) TEST(@"Allocating 4096 bytes", @@ -63,8 +71,21 @@ EXPECT_EXCEPTION(@"Detect resizing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj resizeMemory: (void*)1 toSize: 1024]) + TEST(@"+[description]", + [[OFObject description] isEqual: @"OFObject"] && + [[MyObj description] isEqual: @"MyObj"]) + + o = [[[OFObject alloc] init] autorelease]; + m = [[[MyObj alloc] init] autorelease]; + + TEST(@"-[description]", + [[o description] isEqual: + ([OFString stringWithFormat: @"", o])] && + [[m description] isEqual: + ([OFString stringWithFormat: @"", m])]) + [pool drain]; } @end