ObjFW  Check-in [dbb0223586]

Overview
Comment:Migration of OFArray tests to new testing framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dbb0223586dc795fe7a49fa74166e09f4fe81446ea27be8fbec67c2e637a53de
User & Date: js on 2009-09-27 11:42:06
Other Links: manifest | tags
Context
2009-09-27
14:23
Add -[initWithFilePointer:] to OFFile. check-in: 3cf27e00c4 user: js tags: trunk
11:42
Migration of OFArray tests to new testing framework. check-in: dbb0223586 user: js tags: trunk
2009-09-26
13:27
Migration of OFDictionary tests to new testing framework. check-in: a3bfa21725 user: js tags: trunk
Changes

Modified tests/Makefile from [ec507306f8] to [fa107a94eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
include ../extra.mk

SUBDIRS = OFDataArray		\
	  OFArray		\
	  OFHashes		\
	  ${OFPLUGIN}		\
	  OFTCPSocket		\
	  OFThread		\
	  OFList		\
	  OFXMLElement		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk



<










1
2
3

4
5
6
7
8
9
10
11
12
13
include ../extra.mk

SUBDIRS = OFDataArray		\

	  OFHashes		\
	  ${OFPLUGIN}		\
	  OFTCPSocket		\
	  OFThread		\
	  OFList		\
	  OFXMLElement		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk

Deleted tests/OFArray/Makefile version [a3d17e2555].

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 = ofarray${PROG_SUFFIX}
SRCS = OFArray.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/OFArray/OFArray.m version [0b105e4c04].

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
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * 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>
#include <assert.h>

#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"

#define CATCH_EXCEPTION(code, exception)		\
	@try {						\
		code;					\
							\
		puts("NOT CAUGHT!");			\
		return 1;				\
	} @catch (exception *e) {			\
		puts("CAUGHT! Error string was:");	\
		puts([[e string] cString]);		\
		puts("Resuming...");			\
	}

id c_array[] = {
	@"Foo",
	@"Bar",
	@"Baz",
	nil
};

int
main()
{
	OFArray *a = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil];
	OFArray *b = [OFMutableArray array];
	OFArray *c = [OFArray arrayWithCArray: c_array];

	[b addObject: @"Foo"];
	[b addObject: @"Bar"];
	[b addObject: @"Baz"];

	assert([a count] == 3);
	assert([b count] == 3);
	assert([c count] == 3);
	assert([a isEqual: b]);
	assert([a isEqual: c]);

	[b removeNObjects: 1];
	[b addObject: @"Baz"];
	assert([a isEqual: b]);

	[b removeNObjects: 1];
	[b addObject: @"Qux"];
	assert(![a isEqual: b]);

	CATCH_EXCEPTION([a objectAtIndex: 3], OFOutOfRangeException)
	CATCH_EXCEPTION([a addObject: @"foo"], OFNotImplementedException)

	return 0;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































Modified tests_new/Makefile from [26538f9b0c] to [11f3a0cee1].

1

2
3
4
5
6
7
8
9
PROG_NOINST = tests${PROG_SUFFIX}

SRCS = dictionary.m	\
       main.m		\
       object.m		\
       string.m

include ../buildsys.mk
include ../extra.mk


>
|







1
2
3
4
5
6
7
8
9
10
PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dictionary.m	\
       main.m		\
       object.m		\
       string.m

include ../buildsys.mk
include ../extra.mk

Added tests_new/array.m version [765475729a].









































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
58
59
60
61
62
63
64
65
66
67
68
/*
 * 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 "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"

#import "main.h"

static OFString *module = @"OFArray";
static OFString *c_ary[] = {
	@"Foo",
	@"Bar",
	@"Baz",
	nil
};

void
array_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFArray *a[3];

	TEST(@"+[array]", (a[0] = [OFMutableArray array]))

	TEST(@"+[arrayWithObjects:]",
	    (a[1] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))

	TEST(@"+[arrayWithCArray:]", (a[2] = [OFArray arrayWithCArray: c_ary]))

	TEST(@"-[addObject:]", [a[0] addObject: c_ary[0]] &&
	    [a[0] addObject: c_ary[1]] && [a[0] addObject: c_ary[2]])

	TEST(@"-[count]", [a[0] count] == 3 && [a[1] count] == 3 &&
	    [a[2] count] == 3)

	TEST(@"-[isEqual:]", [a[0] isEqual: a[1]] && [a[1] isEqual: a[2]])

	TEST(@"-[objectAtIndex:]",
	    [[a[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 1] isEqual: c_ary[1]] &&
	    [[a[0] objectAtIndex: 2] isEqual: c_ary[2]] &&
	    [[a[1] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[1] objectAtIndex: 1] isEqual: c_ary[1]] &&
	    [[a[1] objectAtIndex: 2] isEqual: c_ary[2]] &&
	    [[a[2] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[2] objectAtIndex: 1] isEqual: c_ary[1]] &&
	    [[a[2] objectAtIndex: 2] isEqual: c_ary[2]])

	TEST(@"-[removeNObjects:]", [a[0] removeNObjects: 2] &&
	    [a[0] count] == 1 && [[a[0] objectAtIndex: 0] isEqual: c_ary[0]])

	EXPECT_EXCEPTION(@"Detect out of range in -[objectAtIndex:]",
	    OFOutOfRangeException, [a[0] objectAtIndex: 1])

	[pool release];
}

Modified tests_new/main.m from [f044fa8a49] to [fe239efee7].

15
16
17
18
19
20
21

22
23
24
25
26
27
28
#include <stdio.h>
#endif
#include <stdlib.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"


extern void dictionary_tests();
extern void object_tests();
extern void string_tests();

static int fails = 0;

static void







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#endif
#include <stdlib.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"

extern void array_tests();
extern void dictionary_tests();
extern void object_tests();
extern void string_tests();

static int fails = 0;

static void
84
85
86
87
88
89
90

91
92
93
94
}

int
main()
{
	object_tests();
	string_tests();

	dictionary_tests();

	return fails;
}







>




85
86
87
88
89
90
91
92
93
94
95
96
}

int
main()
{
	object_tests();
	string_tests();
	array_tests();
	dictionary_tests();

	return fails;
}