@@ -15,26 +15,25 @@ #include "config.h" #import "TestsAppDelegate.h" -static OFString *module = @"OFStream"; +static OFString *const module = @"OFStream"; -@interface StreamTester: OFStream +@interface StreamTest: OFStream { int state; } @end -@implementation StreamTester +@implementation StreamTest - (bool)lowlevelIsAtEndOfStream { return (state > 1); } -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)size +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)size { size_t pageSize = [OFSystemInfo pageSize]; switch (state) { case 0: @@ -63,22 +62,22 @@ @implementation TestsAppDelegate (OFStreamTests) - (void)streamTests { void *pool = objc_autoreleasePoolPush(); size_t pageSize = [OFSystemInfo pageSize]; - StreamTester *t = [[[StreamTester alloc] init] autorelease]; - OFString *str; - char *cstr; - - cstr = of_alloc(pageSize - 2, 1); - memset(cstr, 'X', pageSize - 3); - cstr[pageSize - 3] = '\0'; - - TEST(@"-[readLine]", [[t readLine] isEqual: @"foo"] && - [(str = [t readLine]) length] == pageSize - 3 && - !strcmp(str.UTF8String, cstr)) - - free(cstr); + StreamTest *test = [[[StreamTest alloc] init] autorelease]; + OFString *string; + char *cString; + + cString = OFAllocMemory(pageSize - 2, 1); + memset(cString, 'X', pageSize - 3); + cString[pageSize - 3] = '\0'; + + TEST(@"-[readLine]", [[test readLine] isEqual: @"foo"] && + (string = [test readLine]).length == pageSize - 3 && + !strcmp(string.UTF8String, cString)) + + OFFreeMemory(cString); objc_autoreleasePoolPop(pool); } @end