ObjFW  Check-in [23aa1c1bf5]

Overview
Comment:Migration of OFThread tests to new testing framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 23aa1c1bf5efad79d1bc77497edd790463f9585d148d91c47793ca4527e7fb67
User & Date: js on 2009-10-03 11:58:13
Other Links: manifest | tags
Context
2009-10-03
13:29
Set variables to nil to prevent double-free. check-in: 7a3968b9a3 user: js tags: trunk
11:58
Migration of OFThread tests to new testing framework. check-in: 23aa1c1bf5 user: js tags: trunk
11:51
Add +[tlsKey] to OFTLSKey. check-in: fad0ff6539 user: js tags: trunk
Changes

Modified tests/Makefile from [a9e8b7dd64] to [be948a048f].

1
2
3
4
5
6
7
include ../extra.mk

SUBDIRS = OFThread		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk


|
<



1
2
3

4
5
6
include ../extra.mk

SUBDIRS = OFXMLParser		\

	  ${OBJC_SYNC}

include ../buildsys.mk

Deleted tests/OFThread/Makefile version [bc130a8d56].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 version [ba2cf4a280].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * 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 <stdio.h>

#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;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































Modified tests_new/Makefile from [7122393b5c] to [4beb3c855a].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
       hashes.m		\
       list.m		\
       main.m		\
       object.m		\
       ${PLUGIN_M}	\
       string.m		\
       tcpsocket.m	\

       xmlelement.m

.PHONY: run
run: all
	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; \







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
       hashes.m		\
       list.m		\
       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
	if test -f ../src/libobjfw.so; then \
		ln -s ../src/libobjfw.so libobjfw.so.0; \

Modified tests_new/main.m from [3ca199df22] to [209c9edd89].

26
27
28
29
30
31
32

33
34
35
36
37
38
39
extern void list_tests();
extern void object_tests();
#ifdef OF_PLUGINS
extern void plugin_tests();
#endif
extern void string_tests();
extern void tcpsocket_tests();

extern void xmlelement_tests();

static int fails = 0;

static void
output(OFString *str, int color)
{







>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
extern void list_tests();
extern void object_tests();
#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
output(OFString *str, int color)
{
99
100
101
102
103
104
105

106
107
108
109
110
111
112
	hashes_tests();
	string_tests();
	dataarray_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();

	xmlelement_tests();
#ifdef OF_PLUGINS
	plugin_tests();
#endif

	return fails;
}







>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
	hashes_tests();
	string_tests();
	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 version [00764890e1].



















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * 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];
}