ObjFW  Check-in [c4cbcb39b9]

Overview
Comment:OFXMLParserTests: Rename TAG_END to TAG_CLOSE

TAG_END is defined by system headers on MorphOS.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c4cbcb39b9daf7b98d09e5926c35c536ea0396953e61dae7698250f900d8e49a
User & Date: js on 2019-05-05 23:13:04
Other Links: manifest | tags
Context
2019-05-17
23:43
ofarc: Create output dir if missing check-in: e5c4816195 user: js tags: trunk
2019-05-05
23:13
OFXMLParserTests: Rename TAG_END to TAG_CLOSE check-in: c4cbcb39b9 user: js tags: trunk
23:02
OFTCPSocket: Work around missing EPROTO check-in: 366ce5073a user: js tags: trunk
Changes

Modified tests/OFXMLParserTests.m from [3b6a87e478] to [e683ca54ff].

23
24
25
26
27
28
29
30
31


32
33
34
35
36
37
38
23
24
25
26
27
28
29


30
31
32
33
34
35
36
37
38







-
-
+
+







#import "TestsAppDelegate.h"

static OFString *module = @"OFXMLParser";
static int i = 0;

enum event_type {
	PROCESSING_INSTRUCTIONS,
	TAG_START,
	TAG_END,
	TAG_OPEN,
	TAG_CLOSE,
	STRING,
	CDATA,
	COMMENT
};

@implementation TestsAppDelegate (OFXMLParser)
-   (void)parser: (OFXMLParser *)parser
54
55
56
57
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
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

129
130
131
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
165
166
167
168
169

170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203

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

218
219
220
221
222
223
224

225
226
227
228
229
230
231

232
233
234
235
236
237
238
54
55
56
57
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
100
101
102
103
104
105
106
107
108
109

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

128
129
130
131
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
165
166
167
168

169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202

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

217
218
219
220
221
222
223

224
225
226
227
228
229
230

231
232
233
234
235
236
237
238







-
+










-
+



-
+






-
+












-
+













-
+

















-
+













-
+






-
+



















-
+







-
+


















-
+






-
+













-
+






-
+






-
+







		    [string isEqual: @"xml version='1.0'"])
		break;
	case 2:
		TEST(msg, type == PROCESSING_INSTRUCTIONS &&
		    [string isEqual: @"p?i"])
		break;
	case 3:
		TEST(msg, type == TAG_START && [name isEqual: @"root"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil && attrs.count == 0)
		break;
	case 4:
		TEST(msg, type == STRING && [string isEqual: @"\n\n "])
		break;
	case 5:
		TEST(msg, type == CDATA && [string isEqual: @"f<]]]oo]"] &&
		    parser.lineNumber == 3)
		break;
	case 6:
		TEST(msg, type == TAG_START && [name isEqual: @"bar"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"bar"] &&
		    prefix == nil && ns == nil && attrs == nil)
		break;
	case 7:
		TEST(msg, type == TAG_END && [name isEqual: @"bar"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"bar"] &&
		    prefix == nil && ns == nil && attrs == nil)
		break;
	case 8:
		TEST(msg, type == STRING && [string isEqual: @"\n "])
		break;
	case 9:
		TEST(msg, type == TAG_START && [name isEqual: @"foobar"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"foobar"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] &&
		    attrs.count == 1 &&
		    /* xmlns attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"xmlns"] &&
		    [[attrs objectAtIndex: 0] namespace] == nil &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual:
		    @"urn:objfw:test:foobar"])
		break;
	case 10:
		TEST(msg, type == STRING && [string isEqual: @"\n  "])
		break;
	case 11:
		TEST(msg, type == TAG_START && [name isEqual: @"qux"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"qux"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] &&
		    attrs.count == 1 &&
		    /* xmlns:foo attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"foo"] &&
		    [[[attrs objectAtIndex: 0] namespace] isEqual:
		    @"http://www.w3.org/2000/xmlns/"] &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual:
		    @"urn:objfw:test:foo"])
		break;
	case 12:
		TEST(msg, type == STRING && [string isEqual: @"\n   "])
		break;
	case 13:
		TEST(msg, type == TAG_START && [name isEqual: @"bla"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"bla"] &&
		    [prefix isEqual: @"foo"] &&
		    [ns isEqual: @"urn:objfw:test:foo"] &&
		    attrs.count == 2 &&
		    /* foo:bla attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"bla"] &&
		    [[[attrs objectAtIndex: 0] namespace] isEqual:
		    @"urn:objfw:test:foo"] &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual: @"bla"] &&
		    /* blafoo attr */
		    [[[attrs objectAtIndex: 1] name] isEqual: @"blafoo"] &&
		    [[attrs objectAtIndex: 1] namespace] == nil &&
		    [[[attrs objectAtIndex: 1] stringValue] isEqual: @"foo"])
		break;
	case 14:
		TEST(msg, type == STRING && [string isEqual: @"\n    "])
		break;
	case 15:
		TEST(msg, type == TAG_START && [name isEqual: @"blup"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"blup"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] &&
		    attrs.count == 2 &&
		    /* foo:qux attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"qux"] &&
		    [[[attrs objectAtIndex: 0] namespace] isEqual:
		    @"urn:objfw:test:foo"] &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual: @"asd"] &&
		    /* quxqux attr */
		    [[[attrs objectAtIndex: 1] name] isEqual: @"quxqux"] &&
		    [[attrs objectAtIndex: 1] namespace] == nil &&
		    [[[attrs objectAtIndex: 1] stringValue] isEqual: @"test"])
		break;
	case 16:
		TEST(msg, type == TAG_END && [name isEqual: @"blup"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"blup"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"])
		break;
	case 17:
		TEST(msg, type == STRING && [string isEqual: @"\n    "])
		break;
	case 18:
		TEST(msg, type == TAG_START && [name isEqual: @"bla"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"bla"] &&
		    [prefix isEqual: @"bla"] &&
		    [ns isEqual: @"urn:objfw:test:bla"] && attrs.count == 3 &&
		    /* xmlns:bla attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"bla"] &&
		    [[[attrs objectAtIndex: 0] namespace] isEqual:
		    @"http://www.w3.org/2000/xmlns/"] &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual:
		    @"urn:objfw:test:bla"] &&
		    /* qux attr */
		    [[[attrs objectAtIndex: 1] name] isEqual: @"qux"] &&
		    [[attrs objectAtIndex: 1] namespace] == nil &&
		    [[[attrs objectAtIndex: 1] stringValue] isEqual: @"qux"] &&
		    /* bla:foo attr */
		    [[[attrs objectAtIndex: 2] name] isEqual: @"foo"] &&
		    [[[attrs objectAtIndex: 2] namespace] isEqual:
		    @"urn:objfw:test:bla"] &&
		    [[[attrs objectAtIndex: 2] stringValue] isEqual: @"blafoo"])
		break;
	case 19:
		TEST(msg, type == TAG_END && [name isEqual: @"bla"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"bla"] &&
		    [prefix isEqual: @"bla"] &&
		    [ns isEqual: @"urn:objfw:test:bla"])
		break;
	case 20:
		TEST(msg, type == STRING && [string isEqual: @"\n    "])
		break;
	case 21:
		TEST(msg, type == TAG_START && [name isEqual: @"abc"] &&
		TEST(msg, type == TAG_OPEN && [name isEqual: @"abc"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:abc"] &&
		    attrs.count == 3 &&
		    /* xmlns attr */
		    [[[attrs objectAtIndex: 0] name] isEqual: @"xmlns"] &&
		    [[attrs objectAtIndex: 0] namespace] == nil &&
		    [[[attrs objectAtIndex: 0] stringValue] isEqual:
		    @"urn:objfw:test:abc"] &&
		    /* abc attr */
		    [[[attrs objectAtIndex: 1] name] isEqual: @"abc"] &&
		    [[attrs objectAtIndex: 1] namespace] == nil &&
		    [[[attrs objectAtIndex: 1] stringValue] isEqual: @"abc"] &&
		    /* foo:abc attr */
		    [[[attrs objectAtIndex: 2] name] isEqual: @"abc"] &&
		    [[[attrs objectAtIndex: 2] namespace] isEqual:
		    @"urn:objfw:test:foo"] &&
		    [[[attrs objectAtIndex: 2] stringValue] isEqual: @"abc"])
		break;
	case 22:
		TEST(msg, type == TAG_END && [name isEqual: @"abc"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"abc"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:abc"])
		break;
	case 23:
		TEST(msg, type == STRING && [string isEqual: @"\n   "])
		break;
	case 24:
		TEST(msg, type == TAG_END && [name isEqual: @"bla"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"bla"] &&
		    [prefix isEqual: @"foo"] &&
		    [ns isEqual: @"urn:objfw:test:foo"])
		break;
	case 25:
		TEST(msg, type == STRING && [string isEqual: @"\n   "])
		break;
	case 26:
		TEST(msg, type == COMMENT && [string isEqual: @" commänt "])
		break;
	case 27:
		TEST(msg, type == STRING && [string isEqual: @"\n  "])
		break;
	case 28:
		TEST(msg, type == TAG_END && [name isEqual: @"qux"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"qux"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"])
		break;
	case 29:
		TEST(msg, type == STRING && [string isEqual: @"\n "])
		break;
	case 30:
		TEST(msg, type == TAG_END && [name isEqual: @"foobar"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"foobar"] &&
		    prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"])
		break;
	case 31:
		TEST(msg, type == STRING && [string isEqual: @"\n"])
		break;
	case 32:
		TEST(msg, type == TAG_END && [name isEqual: @"root"] &&
		TEST(msg, type == TAG_CLOSE && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil);
		break;
	}
}

-		 (void)parser: (OFXMLParser *)parser
  foundProcessingInstructions: (OFString *)pi
249
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
277







-
+













-
+







-    (void)parser: (OFXMLParser *)parser
  didStartElement: (OFString *)name
	   prefix: (OFString *)prefix
	namespace: (OFString *)ns
       attributes: (OFArray *)attrs
{
	[self	    parser: parser
	    didCreateEvent: TAG_START
	    didCreateEvent: TAG_OPEN
		      name: name
		    prefix: prefix
		 namespace: ns
		attributes: attrs
		    string: nil];
}

-  (void)parser: (OFXMLParser *)parser
  didEndElement: (OFString *)name
	 prefix: (OFString *)prefix
      namespace: (OFString *)ns
{
	[self	    parser: parser
	    didCreateEvent: TAG_END
	    didCreateEvent: TAG_CLOSE
		      name: name
		    prefix: prefix
		 namespace: ns
		attributes: nil
		    string: nil];
}