@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -15,19 +15,19 @@ #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); } @@ -62,22 +62,25 @@ @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 = OFAllocMemory(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)) - - OFFreeMemory(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] #1", [[test readLine] isEqual: @"foo"]) + + string = [test readLine]; + TEST(@"-[readLine] #2", string != nil && + string.length == pageSize - 3 && + !strcmp(string.UTF8String, cString)) + + OFFreeMemory(cString); objc_autoreleasePoolPop(pool); } @end