Index: new_tests/Makefile ================================================================== --- new_tests/Makefile +++ new_tests/Makefile @@ -24,14 +24,16 @@ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_SUBPROCESSES} \ + ${USE_SRCS_THREADS} \ testfile_bin.m SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFSocketTests.m SRCS_SUBPROCESSES = OFSubprocessTests.m +SRCS_THREADS = OFThreadTests.m include ../buildsys.mk testfile_bin.m: testfile.bin ${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@ ADDED new_tests/OFThreadTests.m Index: new_tests/OFThreadTests.m ================================================================== --- new_tests/OFThreadTests.m +++ new_tests/OFThreadTests.m @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2008-2024 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 + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "ObjFW.h" +#import "ObjFWTest.h" + +@interface OFThreadTests: OTTestCase +@end + +@interface TestThread: OFThread +@end + +@implementation TestThread +- (id)main +{ + [[OFThread threadDictionary] setObject: @"bar" forKey: @"foo"]; + OFEnsure([[[OFThread threadDictionary] + objectForKey: @"foo"] isEqual: @"bar"]); + + return @"success"; +} +@end + +@implementation OFThreadTests +- (void)testThread +{ + TestThread *thread = [TestThread thread]; + + [thread start]; + + OTAssertEqualObjects([thread join], @"success"); + OTAssertNil([[OFThread threadDictionary] objectForKey: @"foo"]); +} +@end Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -35,11 +35,10 @@ RuntimeTests.m \ ${RUNTIME_ARC_TESTS_M} \ TestsAppDelegate.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_SOCKETS} \ - ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} \ testfile_ini.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieTests.m \ @@ -54,11 +53,10 @@ SRCS_IPX = OFIPXSocketTests.m \ OFSPXSocketTests.m \ OFSPXStreamSocketTests.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m \ OFUNIXStreamSocketTests.m -SRCS_THREADS = OFThreadTests.m SRCS_WINDOWS = OFWindowsRegistryKeyTests.m IOS_USER ?= mobile IOS_TMP ?= /tmp/objfw-test DELETED tests/OFThreadTests.m Index: tests/OFThreadTests.m ================================================================== --- tests/OFThreadTests.m +++ tests/OFThreadTests.m @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2008-2024 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 - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "TestsAppDelegate.h" - -static OFString *const module = @"OFThread"; - -@interface TestThread: OFThread -@end - -@implementation TestThread -- (id)main -{ - [[OFThread threadDictionary] setObject: @"bar" forKey: @"foo"]; - OFEnsure([[[OFThread threadDictionary] - objectForKey: @"foo"] isEqual: @"bar"]); - - return @"success"; -} -@end - -@implementation TestsAppDelegate (OFThreadTests) -- (void)threadTests -{ - void *pool = objc_autoreleasePoolPush(); - TestThread *thread; - - TEST(@"+[thread]", (thread = [TestThread thread])) - - TEST(@"-[start]", R([thread start])) - - TEST(@"-[join]", [[thread join] isEqual: @"success"]) - - TEST(@"-[threadDictionary]", - [[OFThread threadDictionary] objectForKey: @"foo"] == nil) - - objc_autoreleasePoolPop(pool); -} -@end Index: tests/TestsAppDelegate.h ================================================================== --- tests/TestsAppDelegate.h +++ tests/TestsAppDelegate.h @@ -161,14 +161,10 @@ @interface TestsAppDelegate (OFTCPSocketTests) - (void)TCPSocketTests; @end -@interface TestsAppDelegate (OFThreadTests) -- (void)threadTests; -@end - @interface TestsAppDelegate (OFUDPSocketTests) - (void)UDPSocketTests; @end @interface TestsAppDelegate (OFUNIXDatagramSocketTests) Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -406,13 +406,10 @@ # ifdef OF_HAVE_APPLETALK [self DDPSocketTests]; # endif [self kernelEventObserverTests]; #endif -#ifdef OF_HAVE_THREADS - [self threadTests]; -#endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS) [self HTTPClientTests]; #endif #ifdef OF_HAVE_SOCKETS [self HTTPCookieTests];