ObjFW  Check-in [2437d2d0be]

Overview
Comment:Migration of OFXMLElement tests to new testing framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2437d2d0be4adbd15ae35a3e02b2eef7024623721b1e0bce6d67577714438820
User & Date: js on 2009-09-30 13:33:37
Other Links: manifest | tags
Context
2009-09-30
15:01
Migration of OFDataArray tests to new testing framework. check-in: e7a372fea9 user: js tags: trunk
13:33
Migration of OFXMLElement tests to new testing framework. check-in: 2437d2d0be user: js tags: trunk
13:23
Migration of OFTCPSocket tests to new testing framework. check-in: 67cf530ed3 user: js tags: trunk
Changes

Modified tests/Makefile from [843c47a19e] to [0ad94f9883].

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

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

include ../buildsys.mk






<




1
2
3
4
5
6

7
8
9
10
include ../extra.mk

SUBDIRS = OFDataArray		\
	  OFHashes		\
	  ${OFPLUGIN}		\
	  OFThread		\

	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk

Deleted tests/OFXMLElement/Makefile version [e5f5abe055].

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 = ofxmlelement${PROG_SUFFIX}
SRCS = OFXMLElement.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/OFXMLElement/OFXMLElement.m version [6153658720].

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
71
72
73
74
75
76
77
/*
 * 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 "OFXMLElement.h"

#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif

#define NUM_TESTS 5
#define SUCCESS								\
	printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m",	\
	    (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS);		\
	fflush(stdout);
#define FAIL								\
	printf("\r\033[K\033[1;31mTest " ZD "/%d failed!\033[m\n",	\
	    i + 1, NUM_TESTS);						\
	return 1;
#define CHECK(cond)							\
	if (cond) {							\
		SUCCESS							\
	} else {							\
		FAIL							\
	}								\
	i++;
#define CHECK_EXCEPT(code, exception)					\
	@try {								\
		code;							\
		FAIL							\
	} @catch (exception *e) {					\
		SUCCESS							\
	}								\
	i++;

int
main()
{
	size_t i = 0;

	OFXMLElement *elem;

	elem = [OFXMLElement elementWithName: @"foo"];
	CHECK([[elem string] isEqual: @"<foo/>"]);

	[elem addAttributeWithName: @"foo"
		       stringValue: @"b&ar"];
	CHECK([[elem string] isEqual: @"<foo foo='b&amp;ar'/>"])

	[elem addChild: [OFXMLElement elementWithName: @"bar"]];
	CHECK([[elem string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"])

	elem = [OFXMLElement elementWithName: @"foo"
				 stringValue: @"b&ar"];
	CHECK([[elem string] isEqual: @"<foo>b&amp;ar</foo>"])

	[elem addAttributeWithName: @"foo"
		       stringValue: @"b&ar"];
	CHECK([[elem string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])

	puts("");

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


























































































































































Modified tests_new/Makefile from [0c23107fa9] to [98d32fa459].

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dictionary.m	\
       list.m		\
       main.m		\
       object.m		\
       string.m		\
       tcpsocket.m


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

CPPFLAGS += -I../src -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${LIBS}








|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dictionary.m	\
       list.m		\
       main.m		\
       object.m		\
       string.m		\
       tcpsocket.m	\
       xmlelement.m

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

CPPFLAGS += -I../src -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${LIBS}

Modified tests_new/main.m from [144512e59e] to [8a5fa64125].

21
22
23
24
25
26
27

28
29
30
31
32
33
34

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


static int fails = 0;

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







>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

extern void array_tests();
extern void dictionary_tests();
extern void list_tests();
extern void object_tests();
extern void string_tests();
extern void tcpsocket_tests();
extern void xmlelement_tests();

static int fails = 0;

static void
output(OFString *str, int color)
{
#ifdef STDOUT
91
92
93
94
95
96
97

98
99
100
{
	object_tests();
	string_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();


	return fails;
}







>



92
93
94
95
96
97
98
99
100
101
102
{
	object_tests();
	string_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();
	xmlelement_tests();

	return fails;
}

Added tests_new/xmlelement.m version [374a7a3822].







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * 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 "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"

#import "main.h"

static OFString *module = @"OFXMLElement";

void
xmlelement_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *elem[2];

	TEST(@"+[elementWithName:]",
	    (elem[0] = [OFXMLElement elementWithName: @"foo"]) &&
	    [[elem[0] string] isEqual: @"<foo/>"])

	TEST(@"+[elementWithName:stringValue:]",
	    (elem[1] = [OFXMLElement elementWithName: @"foo"
					 stringValue: @"b&ar"]) &&
	    [[elem[1] string] isEqual: @"<foo>b&amp;ar</foo>"])

	TEST(@"-[addAttributeWithName:stringValue:]",
	    [elem[0] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'/>"] &&
	    [elem[1] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[1] string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])

	TEST(@"-[addChild",
	    [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"])

	[pool release];
}