Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,7 +1,6 @@ include ../extra.mk -SUBDIRS = OFThread \ - OFXMLParser \ +SUBDIRS = OFXMLParser \ ${OBJC_SYNC} include ../buildsys.mk DELETED tests/OFThread/Makefile Index: tests/OFThread/Makefile ================================================================== --- tests/OFThread/Makefile +++ tests/OFThread/Makefile @@ -1,29 +0,0 @@ -PROG_NOINST = ofthread${PROG_SUFFIX} -SRCS = OFThread.m - -include ../../buildsys.mk -include ../../extra.mk - -CPPFLAGS += -I../../src -I../.. -LIBS := -L../../src -lobjfw ${LIBS} - -.PHONY: run - -all: run -run: ${PROG_NOINST} - rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib - if test -f ../../src/libobjfw.so; then \ - ln -s ../../src/libobjfw.so libobjfw.so.0; \ - ln -s ../../src/libobjfw.so libobjfw.so.0.1; \ - fi - if test -f ../../src/libobjfw.dll; then \ - ln ../../src/libobjfw.dll libobjfw.dll; \ - fi - if test -f ../../src/libobjfw.dylib; then \ - ln -s ../../src/libobjfw.dylib libobjfw.dylib; \ - fi - LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ - DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ - ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ - rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \ - exit $$EXIT DELETED tests/OFThread/OFThread.m Index: tests/OFThread/OFThread.m ================================================================== --- tests/OFThread/OFThread.m +++ tests/OFThread/OFThread.m @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2008 - 2009 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of libobjfw. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE included in - * the packaging of this file. - */ - -#include "config.h" - -#include - -#import "OFThread.h" -#import "OFString.h" - -@interface MyThread: OFThread -@end - -@implementation MyThread -- main -{ - if ([object isEqual: @"foo"]) - return @"successful"; - - return @"failed"; -} -@end - -int -main() -{ - MyThread *t = [MyThread threadWithObject: @"foo"]; - - if (![[t join] isEqual: @"successful"]) { - puts("Test failed!"); - return 1; - } - - puts("Test successful!"); - return 0; -} Index: tests_new/Makefile ================================================================== --- tests_new/Makefile +++ tests_new/Makefile @@ -11,10 +11,11 @@ main.m \ object.m \ ${PLUGIN_M} \ string.m \ tcpsocket.m \ + thread.m \ xmlelement.m .PHONY: run run: all rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib Index: tests_new/main.m ================================================================== --- tests_new/main.m +++ tests_new/main.m @@ -28,10 +28,11 @@ #ifdef OF_PLUGINS extern void plugin_tests(); #endif extern void string_tests(); extern void tcpsocket_tests(); +extern void thread_tests(); extern void xmlelement_tests(); static int fails = 0; static void @@ -101,12 +102,13 @@ dataarray_tests(); array_tests(); dictionary_tests(); list_tests(); tcpsocket_tests(); + thread_tests(); xmlelement_tests(); #ifdef OF_PLUGINS plugin_tests(); #endif return fails; } ADDED tests_new/thread.m Index: tests_new/thread.m ================================================================== --- tests_new/thread.m +++ tests_new/thread.m @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of libobjfw. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#include "config.h" + +#import "OFThread.h" +#import "OFAutoreleasePool.h" +#import "OFString.h" +#import "OFExceptions.h" + +#import "main.h" + +static OFString *module = @"OFThread"; + +@interface TestThread: OFThread +@end + +@implementation TestThread +- main +{ + if ([object isEqual: @"foo"]) + return @"success"; + + return nil; +} +@end + +void +thread_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + TestThread *t; + OFTLSKey *key; + + TEST(@"+[threadWithObject:]", + (t = [TestThread threadWithObject: @"foo"])) + + TEST(@"-[join]", [[t join] isEqual: @"success"]) + + TEST(@"OFTLSKey's +[tlsKey]", (key = [OFTLSKey tlsKey])) + + TEST(@"+[setObject:forTLSKey:]", [OFThread setObject: @"foo" + forTLSKey: key]) + + TEST(@"+[objectForTLSKey:]", + [[OFThread objectForTLSKey: key] isEqual: @"foo"]) + + [pool release]; +}