ObjFW  Check-in [f4d994aba0]

Overview
Comment:Add tests for JSON.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f4d994aba051d15280a4a9d8bf976b188d30738b271d5e80ddfc015617636b5e
User & Date: js on 2011-12-29 02:04:07
Other Links: manifest | tags
Context
2011-12-29
14:59
Enhance JSON tests. check-in: db8fae97f2 user: js tags: trunk
02:04
Add tests for JSON. check-in: f4d994aba0 user: js tags: trunk
01:55
Fix -[OFNumber isEqual:] for booleans. check-in: f42b841347 user: js tags: trunk
Changes

Modified tests/Makefile from [63192b1060] to [c9ead1e9ad].

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19











+







include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = OFArrayTests.m			\
       ${OFBLOCKTESTS_M}		\
       OFDataArrayTests.m		\
       OFDateTests.m			\
       OFDictionaryTests.m		\
       ${OFHTTPREQUESTTESTS_M}		\
       OFJSONTests.m			\
       OFListTests.m			\
       OFMD5HashTests.m			\
       OFNumberTests.m			\
       OFObjectTests.m			\
       ${OFPLUGINTESTS_M}		\
       OFSerializationTests.m		\
       OFSet.m				\

Added tests/OFJSONTests.m version [5fec8cecc1].





















































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFNull.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFJSON";

@implementation TestsAppDelegate (JSONTests)
- (void)JSONTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *s = @"{\"foo\"\t:\"bar\", \"x\": [7.5\r,null,\"foo\",false]}";
	OFDictionary *d = [OFDictionary dictionaryWithKeysAndObjects:
	    @"foo", @"bar",
	    @"x", [OFArray arrayWithObjects:
		[OFNumber numberWithFloat: 7.5],
		[OFNull null],
		@"foo",
		[OFNumber numberWithBool: NO],
		nil],
	    nil];

	TEST(@"-[JSONValue]", [[s JSONValue] isEqual: d])

	TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
	    @"{\"foo\":\"bar\",\"x\":[7.5,null,\"foo\",false]}"])

	[pool drain];
}
@end

Modified tests/TestsAppDelegate.h from [947968bb2d] to [0108670e3a].

91
92
93
94
95
96
97




98
99
100
101
102
103
104
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108







+
+
+
+







@interface TestsAppDelegate (OFDictionaryTests)
- (void)dictionaryTests;
@end

@interface TestsAppDelegate (OFHTTPRequestTests)
- (void)HTTPRequestTests;
@end

@interface TestsAppDelegate (OFJSONTests)
- (void)JSONTests;
@end

@interface TestsAppDelegate (OFListTests)
- (void)listTests;
@end

@interface TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests;

Modified tests/TestsAppDelegate.m from [6f2bdb4fac] to [491be227cf].

136
137
138
139
140
141
142

143
144
145
146
147
148
149
150
151
152
153
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154







+











#ifdef OF_THREADS
	[self HTTPRequestTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];
	[self XMLElementBuilderTests];
	[self serializationTests];
	[self JSONTests];
#ifdef OF_PLUGINS
	[self pluginTests];
#endif
#ifdef OF_HAVE_PROPERTIES
	[self propertiesTests];
#endif

	if (fails > 0)
		[OFApplication terminateWithStatus: fails];
}
@end