ObjFW  Check-in [9c435fddfc]

Overview
Comment:Add test for OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9c435fddfc849e9ca26bb256363e4fe6114d07c6acc9615f4a7ad33fdfbadee8
User & Date: js on 2009-05-18 19:38:27
Other Links: manifest | tags
Context
2009-05-18
20:41
Add one more convenience method to OFArray. check-in: 7107bd9906 user: js tags: trunk
19:38
Add test for OFArray. check-in: 9c435fddfc user: js tags: trunk
19:08
Add - isEqual: for OFArray. check-in: 66293c1fe8 user: js tags: trunk
Changes

Modified tests/Makefile from [c416da49fe] to [d73d2d7d1e].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
include ../extra.mk

SUBDIRS = OFObject		\
	  OFAutoreleasePool	\
	  OFDataArray		\

	  OFDictionary		\
	  OFHashes		\
	  ${OFPLUGIN}		\
	  OFString		\
	  OFTCPSocket		\
	  OFThread		\
	  OFList		\
	  OFXMLFactory

include ../buildsys.mk





>










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

SUBDIRS = OFObject		\
	  OFAutoreleasePool	\
	  OFDataArray		\
	  OFArray		\
	  OFDictionary		\
	  OFHashes		\
	  ${OFPLUGIN}		\
	  OFString		\
	  OFTCPSocket		\
	  OFThread		\
	  OFList		\
	  OFXMLFactory

include ../buildsys.mk

Added tests/OFArray/Makefile version [73ba36baf5].















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
	ln -s ../../src/libobjfw.so libobjfw.so.0
	ln -s ../../src/libobjfw.so libobjfw.so.0.1
	ln -s ../../src/libobjfw.dll libobjfw.dll
	ln -s ../../src/libobjfw.dylib libobjfw.dylib
	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

Added tests/OFArray/OFArray.m version [d1f0787995].

























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * 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.
 */

#import "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...");			\
	}

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

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

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

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

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

	CATCH_EXCEPTION([a object: 3], OFOutOfRangeException)
	CATCH_EXCEPTION([a add: @"foo"], OFNotImplementedException)

	return 0;
}

Modified tests/OFDataArray/OFDataArray.m from [156e55b3b9] to [a5da935c08].

13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#import "OFDataArray.h"
#import "OFExceptions.h"
#import "OFAutoreleasePool.h"


#define CATCH_EXCEPTION(code, exception)		\
	@try {						\
		code;					\
							\
		puts("NOT CAUGHT!");			\
		return 1;				\







<

>







13
14
15
16
17
18
19

20
21
22
23
24
25
26
27
28

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#import "OFDataArray.h"

#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#define CATCH_EXCEPTION(code, exception)		\
	@try {						\
		code;					\
							\
		puts("NOT CAUGHT!");			\
		return 1;				\