ObjFW  Check-in [07e630588d]

Overview
Comment:tests: Use __VA_ARGS__ for TEST() and clean up
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 07e630588d3cebb1a11d7e7c16dc96b40736bdcbbeac239c68ea6b0d780eb158
User & Date: js on 2015-06-28 16:39:34
Other Links: manifest | tags
Context
2015-06-28
17:02
utils/ofzip: Make use of generics check-in: c3581d80a2 user: js tags: trunk
16:39
tests: Use __VA_ARGS__ for TEST() and clean up check-in: 07e630588d user: js tags: trunk
16:28
Add OF_SUBCLASSING_RESTRICTED check-in: 5116342c0a user: js tags: trunk
Changes

Modified tests/ForwardingTests.m from [ac5ac4e4b2] to [aadba91af6].

203
204
205
206
207
208
209
210

211
212
213
214
215
216
217
203
204
205
206
207
208
209

210
211
212
213
214
215
216
217







-
+







	target = [[[ForwardingTarget alloc] init] autorelease];
	TEST(@"-[forwardingTargetForSelector:]",
	    [t forwardingTargetTest: 0xDEADBEEF
				   : -1
				   : 1.25
				   : 2.75] == 0x12345678)
	TEST(@"-[forwardingTargetForSelector:] variable arguments",
	   [([t forwardingTargetVarArgTest: FMT, ARGS]) isEqual: RESULT])
	   [[t forwardingTargetVarArgTest: FMT, ARGS] isEqual: RESULT])
	/*
	 * Don't try fpret on Win64 if we don't have stret forwarding, as
	 * long double is handled as a struct there.
	 */
# if !defined(_WIN64) || defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET)
	TEST(@"-[forwardingTargetForSelector:] fp return",
	    [t forwardingTargetFPRetTest] == 12345678.00006103515625)

Modified tests/OFArrayTests.m from [370db7500f] to [a0e388f1bc].

90
91
92
93
94
95
96
97

98
99
100
101
102
103
104
90
91
92
93
94
95
96

97
98
99
100
101
102
103
104







-
+







	TEST(@"-[indexOfObject:]", [a[0] indexOfObject: c_ary[1]] == 1)

	TEST(@"-[indexOfObjectIdenticalTo:]",
	    [a[1] indexOfObjectIdenticalTo: c_ary[1]] == 1)

	TEST(@"-[objectsInRange:]",
	    [[a[0] objectsInRange: of_range(1, 2)] isEqual:
	    ([OFArray arrayWithObjects: c_ary[1], c_ary[2], nil])])
	    [OFArray arrayWithObjects: c_ary[1], c_ary[2], nil]])

	TEST(@"-[replaceObject:withObject:]",
	    R([m[0] replaceObject: c_ary[1]
		       withObject: c_ary[0]]) &&
	    [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
	    [[m[0] objectAtIndex: 2] isEqual: c_ary[2]])
132
133
134
135
136
137
138
139
140


141
142
143
144
145
146
147


148
149
150
151
152
153
154


155
156
157


158
159
160
161
162
163
164
132
133
134
135
136
137
138


139
140
141
142
143
144
145


146
147
148
149
150
151
152


153
154
155


156
157
158
159
160
161
162
163
164







-
-
+
+





-
-
+
+





-
-
+
+

-
-
+
+







	    R([m[1] removeObjectsInRange: of_range(0, 2)]) &&
	    [m[1] count] == 1 && [[m[1] objectAtIndex: 0] isEqual: c_ary[2]])

	m[1] = [[a[0] mutableCopy] autorelease];
	[m[1] addObject: @"qux"];
	[m[1] addObject: @"last"];
	TEST(@"-[reverse]",
	    R([m[1] reverse]) && [m[1] isEqual: ([OFArray arrayWithObjects:
	    @"last", @"qux", @"Baz", @"Bar", @"Foo", nil])])
	    R([m[1] reverse]) && [m[1] isEqual: [OFArray arrayWithObjects:
	    @"last", @"qux", @"Baz", @"Bar", @"Foo", nil]])

	m[1] = [[a[0] mutableCopy] autorelease];
	[m[1] addObject: @"qux"];
	[m[1] addObject: @"last"];
	TEST(@"-[reversedArray]",
	    [[m[1] reversedArray] isEqual: ([OFArray arrayWithObjects:
	    @"last", @"qux", @"Baz", @"Bar", @"Foo", nil])])
	    [[m[1] reversedArray] isEqual: [OFArray arrayWithObjects:
	    @"last", @"qux", @"Baz", @"Bar", @"Foo", nil]])

	m[1] = [[a[0] mutableCopy] autorelease];
	[m[1] addObject: @"0"];
	[m[1] addObject: @"z"];
	TEST(@"-[sortedArray]",
	    [[m[1] sortedArray] isEqual: ([OFArray arrayWithObjects:
	    @"0", @"Bar", @"Baz", @"Foo", @"z", nil])] &&
	    [[m[1] sortedArray] isEqual: [OFArray arrayWithObjects:
	    @"0", @"Bar", @"Baz", @"Foo", @"z", nil]] &&
	    [[m[1] sortedArrayWithOptions: OF_ARRAY_SORT_DESCENDING]
	    isEqual: ([OFArray arrayWithObjects:
	    @"z", @"Foo", @"Baz", @"Bar", @"0", nil])])
	    isEqual: [OFArray arrayWithObjects:
	    @"z", @"Foo", @"Baz", @"Bar", @"0", nil]])

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

	EXPECT_EXCEPTION(@"Detect out of range in -[removeObjectsInRange:]",
	    OFOutOfRangeException, [m[0] removeObjectsInRange:
		of_range(0, [m[0] count] + 1)])
311
312
313
314
315
316
317
318
319


320
321
322
323
324
325
326
327
311
312
313
314
315
316
317


318
319
320
321
322
323
324
325
326
327







-
-
+
+









	TEST(@"-[filteredArrayUsingBlock:]",
	   [[[m[0] filteredArrayUsingBlock: ^ bool (id obj, size_t idx) {
		return [obj isEqual: @"foo"];
	    }] description] isEqual: @"(\n\tfoo\n)"])

	TEST(@"-[foldUsingBlock:]",
	    [([OFArray arrayWithObjects: [OFMutableString string], @"foo",
	    @"bar", @"baz", nil]) foldUsingBlock: ^ id (id left, id right) {
	    [[OFArray arrayWithObjects: [OFMutableString string], @"foo",
	    @"bar", @"baz", nil] foldUsingBlock: ^ id (id left, id right) {
		[left appendString: right];
		return left;
	    }])
#endif

	[pool drain];
}
@end

Modified tests/OFDictionaryTests.m from [8f675067b8] to [9df1f8a4e7].

64
65
66
67
68
69
70
71
72


73
74
75
76


77
78
79
80
81
82
83
64
65
66
67
68
69
70


71
72
73
74


75
76
77
78
79
80
81
82
83







-
-
+
+


-
-
+
+







	    [OFString stringWithString: values[0]]])

	TEST(@"-[description]",
	    [[dict description] isEqual:
	    @"{\n\tkey1 = value1;\n\tkey2 = value2;\n}"])

	TEST(@"-[allKeys]",
	    [[dict allKeys] isEqual: ([OFArray arrayWithObjects: keys[0],
	    keys[1], nil])])
	    [[dict allKeys] isEqual: [OFArray arrayWithObjects: keys[0],
	    keys[1], nil]])

	TEST(@"-[allObjects]",
	    [[dict allObjects] isEqual: ([OFArray arrayWithObjects: values[0],
	    values[1], nil])])
	    [[dict allObjects] isEqual: [OFArray arrayWithObjects: values[0],
	    values[1], nil]])

	TEST(@"-[keyEnumerator]", (key_enum = [dict keyEnumerator]))
	TEST(@"-[objectEnumerator]", (obj_enum = [dict objectEnumerator]))

	TEST(@"OFEnumerator's -[nextObject]",
	    [[key_enum nextObject] isEqual: keys[0]] &&
	    [[obj_enum nextObject] isEqual: values[0]] &&

Modified tests/OFHTTPClientTests.m from [08ace1af61] to [e466b71e49].

109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
125
126
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123
124
125
126







-
+











	TEST(@"-[performRequest:]",
	    (client = [OFHTTPClient client]) &&
	    R(request = [OFHTTPRequest requestWithURL: url]) &&
	    R(response = [client performRequest: request]))

	TEST(@"Normalization of server header keys",
	    ([[response headers] objectForKey: @"Content-Length"] != nil))
	    [[response headers] objectForKey: @"Content-Length"] != nil)

	TEST(@"Correct parsing of data",
	    (data = [response readDataArrayTillEndOfStream]) &&
	    [data count] == 7 && !memcmp([data items], "foo\nbar", 7))

	[server join];

	[pool drain];
}
@end

Modified tests/OFObjectTests.m from [fe18f7b293] to [a7d43007a4].

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







-
+

-
+




	    [[MyObj description] isEqual: @"MyObj"])

	o = [[[OFObject alloc] init] autorelease];
	m = [[[MyObj alloc] init] autorelease];

	TEST(@"-[description]",
	    [[o description] isEqual:
	    ([OFString stringWithFormat: @"<OFObject: %p>", o])] &&
	    [OFString stringWithFormat: @"<OFObject: %p>", o]] &&
	    [[m description] isEqual:
	    ([OFString stringWithFormat: @"<MyObj: %p>", m])])
	    [OFString stringWithFormat: @"<MyObj: %p>", m]])

	[pool drain];
}
@end

Modified tests/OFSetTests.m from [19d4bbd605] to [ae430dfeb5].

58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78

79
80
81
82


83
84
85
86
87



88
89
90
91
92



93
94
95
96
97
98
99
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72
73
74
75
76
77

78
79
80


81
82
83
84



85
86
87
88
89



90
91
92
93
94
95
96
97
98
99







-
+












-
+


-
-
+
+


-
-
-
+
+
+


-
-
-
+
+
+








	TEST(@"-[mutableCopy]",
	    (mutableSet = [[set1 mutableCopy] autorelease]));

	TEST(@"-[addObject:]",
	    R([mutableSet addObject: @"baz"]) && [mutableSet isEqual: set2] &&
	    R([mutableSet addObject: @"y"]) && [mutableSet isEqual:
	    ([OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", @"y", nil])])
	    [OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", @"y", nil]])

	TEST(@"-[removeObject:]",
	    R([mutableSet removeObject: @"y"]) && [mutableSet isEqual: set1])

	TEST(@"-[isSubsetOfSet:]",
	    R([mutableSet removeObject: @"foo"]) &&
	    [mutableSet isSubsetOfSet: set1] &&
	    ![set1 isSubsetOfSet: mutableSet]);

	TEST(@"-[intersectsSet:]",
	    [(set2 = [OFSet setWithObjects: @"x", nil]) intersectsSet: set1] &&
	    [set1 intersectsSet: set2] &&
	    ![([OFSet setWithObjects: @"1", nil]) intersectsSet: set1]);
	    ![[OFSet setWithObjects: @"1", nil] intersectsSet: set1]);

	TEST(@"-[minusSet:]",
	    R([mutableSet minusSet: ([OFSet setWithObjects: @"x", nil])]) &&
	    [mutableSet isEqual: ([OFSet setWithObjects: @"baz", @"bar", nil])])
	    R([mutableSet minusSet: [OFSet setWithObjects: @"x", nil]]) &&
	    [mutableSet isEqual: [OFSet setWithObjects: @"baz", @"bar", nil]])

	TEST(@"-[intersectSet:]",
	    R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    nil])])
	    R([mutableSet intersectSet: [OFSet setWithObjects: @"baz",
	    nil]]) && [mutableSet isEqual: [OFSet setWithObjects: @"baz",
	    nil]])

	TEST(@"-[unionSet:]",
	    R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil])])
	    R([mutableSet unionSet: [OFSet setWithObjects: @"x", @"bar",
	    nil]]) && [mutableSet isEqual: [OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil]])

#ifdef OF_HAVE_FAST_ENUMERATION
	ok = true;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {

Modified tests/TestsAppDelegate.h from [7884d34f10] to [7b05c7a3ed].

13
14
15
16
17
18
19
20

21
22
23
24
25

26
27
28
29
30
31
32
13
14
15
16
17
18
19

20
21
22
23
24

25
26
27
28
29
30
31
32







-
+




-
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFApplication.h"
#import "OFXMLElementBuilder.h"

#define TEST(test, cond)				\
#define TEST(test, ...)					\
	{						\
		[self outputTesting: test		\
			   inModule: module];		\
							\
		if (cond)				\
		if (__VA_ARGS__)			\
			[self outputSuccess: test	\
				   inModule: module];	\
		else {					\
			[self outputFailure: test	\
				   inModule: module];	\
			_fails++;			\
		}					\
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63







-
+







				   inModule: module];	\
		else {					\
			[self outputFailure: test	\
				   inModule: module];	\
			_fails++;			\
		}					\
	}
#define R(x) (x, 1)
#define R(...) (__VA_ARGS__, 1)

@class OFString;

@interface TestsAppDelegate: OFObject
{
	int _fails;
}