1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
163
|
2 |
|
208
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
163
|
5 |
TestCase subclass:#XMLCoderTests
|
219
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
1551
|
9 |
category:'tests-Regression-XML'
|
163
|
10 |
!
|
|
11 |
|
|
12 |
!XMLCoderTests class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
documentation to be added.
|
|
17 |
|
|
18 |
[author:]
|
1447
|
19 |
Stefan Vogel (stefan@zwerg)
|
163
|
20 |
|
|
21 |
[see also:]
|
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
"
|
|
27 |
! !
|
|
28 |
|
|
29 |
!XMLCoderTests methodsFor:'helpers'!
|
|
30 |
|
|
31 |
encodeAndDecode:anObject
|
|
32 |
"test, that encoding and decoding an Object results in anObject"
|
|
33 |
|
|
34 |
|encodedString decodedObject|
|
|
35 |
|
|
36 |
encodedString := XMLStandardCoder new encodingOf:anObject.
|
|
37 |
decodedObject := (XMLStandardDecoder on:encodedString readStream) next.
|
|
38 |
|
|
39 |
self should:anObject = decodedObject.
|
|
40 |
|
|
41 |
encodedString := XMLStandardCoder new aspect:#encodeInstanceVariables; encodingOf:anObject.
|
|
42 |
decodedObject := (XMLStandardDecoder on:encodedString readStream) useSend:true; next.
|
|
43 |
|
|
44 |
self should:anObject = decodedObject.
|
|
45 |
|
|
46 |
^ decodedObject.
|
|
47 |
! !
|
|
48 |
|
|
49 |
!XMLCoderTests methodsFor:'initialize / release'!
|
|
50 |
|
|
51 |
setUp
|
|
52 |
"common setup - invoked before testing"
|
|
53 |
|
|
54 |
super setUp
|
|
55 |
!
|
|
56 |
|
|
57 |
tearDown
|
|
58 |
"common cleanup - invoked after testing"
|
|
59 |
|
|
60 |
super tearDown
|
|
61 |
! !
|
|
62 |
|
|
63 |
!XMLCoderTests methodsFor:'tests'!
|
|
64 |
|
|
65 |
testArray
|
|
66 |
"test encoding an decoding of an integer"
|
|
67 |
|
|
68 |
|arr|
|
|
69 |
|
|
70 |
arr := Array new:10.
|
|
71 |
arr at:1 put:true.
|
|
72 |
arr at:2 put:'hallo'.
|
|
73 |
arr at:3 put:#symbol.
|
|
74 |
arr at:4 put:nil.
|
|
75 |
"/ arr at:6 put:arr.
|
|
76 |
|
|
77 |
self encodeAndDecode:arr
|
|
78 |
|
|
79 |
"
|
|
80 |
self run:#testArray
|
|
81 |
"
|
|
82 |
!
|
|
83 |
|
|
84 |
testBytes
|
|
85 |
"test encoding an decoding of an ByteArray"
|
|
86 |
|
|
87 |
self encodeAndDecode:#[1].
|
|
88 |
self encodeAndDecode:#[1 2].
|
|
89 |
self encodeAndDecode:#[1 2 3].
|
|
90 |
self encodeAndDecode:#[1 2 3 4].
|
|
91 |
self encodeAndDecode:#[1 2 3 4 5].
|
|
92 |
self encodeAndDecode:#[1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 9 0 12 3 4 56 7 8 9 0].
|
|
93 |
|
|
94 |
"
|
|
95 |
self run:#testBytes
|
|
96 |
"
|
|
97 |
!
|
|
98 |
|
|
99 |
testCharacter
|
|
100 |
"test encoding an decoding of a Character"
|
|
101 |
|
|
102 |
self encodeAndDecode:$a.
|
|
103 |
self encodeAndDecode:$ä.
|
|
104 |
|
|
105 |
"
|
|
106 |
self run:#testCharacter
|
|
107 |
"
|
|
108 |
!
|
|
109 |
|
|
110 |
testComplex
|
|
111 |
"test encoding an decoding of an OrderedCollection"
|
|
112 |
|
|
113 |
|coll r decodedObject|
|
|
114 |
|
|
115 |
coll := OrderedCollection new.
|
|
116 |
coll add:true.
|
|
117 |
coll add:'hallo'.
|
|
118 |
coll add:#symbol.
|
|
119 |
coll add:(r:= #[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]).
|
|
120 |
coll add:#symbol.
|
|
121 |
coll add:r.
|
|
122 |
coll add:coll copy.
|
|
123 |
|
|
124 |
decodedObject := self encodeAndDecode:coll.
|
|
125 |
|
|
126 |
self should:(decodedObject at:4) == (decodedObject at:6).
|
|
127 |
|
|
128 |
"
|
|
129 |
self run:#testComplex
|
|
130 |
"
|
|
131 |
!
|
|
132 |
|
|
133 |
testDictionary
|
|
134 |
"test encoding an decoding of an integer"
|
|
135 |
|
|
136 |
|dict|
|
|
137 |
|
|
138 |
dict := Dictionary new.
|
|
139 |
dict at:true put:1234.
|
|
140 |
dict at:#murks put:'hallo'.
|
|
141 |
dict at:5 put:#symbol.
|
1447
|
142 |
|
163
|
143 |
self encodeAndDecode:dict
|
|
144 |
|
|
145 |
"
|
164
|
146 |
self run:#testDictionary
|
|
147 |
"
|
|
148 |
!
|
|
149 |
|
|
150 |
testEmptyCollection
|
|
151 |
"test encoding an decoding of an OrderedCollection"
|
|
152 |
|
|
153 |
|set|
|
|
154 |
|
|
155 |
set := OrderedCollection new.
|
|
156 |
|
|
157 |
self encodeAndDecode:set
|
|
158 |
|
|
159 |
"
|
163
|
160 |
self run:#testEmptyCollection
|
|
161 |
"
|
|
162 |
!
|
|
163 |
|
217
|
164 |
testFloat
|
163
|
165 |
"test encoding an decoding of an integer"
|
|
166 |
|
|
167 |
-1.0 to: 1.0 by:0.5 do:[:i|
|
1447
|
168 |
self encodeAndDecode:i
|
163
|
169 |
].
|
|
170 |
|
|
171 |
"
|
|
172 |
self run:#testFloat
|
|
173 |
"
|
|
174 |
!
|
|
175 |
|
217
|
176 |
testFraction
|
163
|
177 |
"test encoding an decoding of an integer"
|
|
178 |
|
|
179 |
(-3/4) to:(3/4) by:(1/4) do:[:i|
|
1447
|
180 |
self encodeAndDecode:i
|
163
|
181 |
].
|
|
182 |
|
|
183 |
"
|
|
184 |
self run:#testFraction
|
|
185 |
"
|
|
186 |
!
|
|
187 |
|
|
188 |
testIdentityDictionary
|
|
189 |
"test encoding an decoding of an integer"
|
|
190 |
|
|
191 |
|dict|
|
|
192 |
|
|
193 |
dict := IdentityDictionary new.
|
|
194 |
dict at:true put:1234.
|
|
195 |
dict at:#test put:'hallo'.
|
|
196 |
dict at:5 put:#symbol.
|
1447
|
197 |
|
163
|
198 |
self encodeAndDecode:dict
|
|
199 |
|
|
200 |
"
|
|
201 |
self run:#testIdentityDictionary
|
|
202 |
"
|
|
203 |
!
|
218
|
204 |
|
|
205 |
testInteger
|
|
206 |
"test encoding an decoding of an integer"
|
163
|
207 |
|
219
|
208 |
#( 0 1 10 100 1000 10000 100000 1000000 16rFFFF 16rFFFFFF) do:[:i|
|
1447
|
209 |
self encodeAndDecode:i.
|
|
210 |
self encodeAndDecode:i negated.
|
218
|
211 |
].
|
163
|
212 |
|
|
213 |
"
|
219
|
214 |
self run:#testInteger
|
163
|
215 |
"
|
|
216 |
!
|
|
217 |
|
166
|
218 |
testInterval
|
|
219 |
"test encoding an decoding of a set"
|
|
220 |
|
|
221 |
|interval|
|
|
222 |
|
|
223 |
interval := Interval from:1 to:100.
|
|
224 |
|
|
225 |
self encodeAndDecode:interval
|
|
226 |
|
|
227 |
"
|
|
228 |
self run:#testInterval
|
|
229 |
"
|
|
230 |
!
|
|
231 |
|
217
|
232 |
testLargeInteger
|
|
233 |
"test encoding an decoding of an integer"
|
|
234 |
|
1447
|
235 |
#(
|
|
236 |
16r1FFFFFFF 16r20000000
|
|
237 |
16r3FFFFFFF 16r40000000
|
|
238 |
16r7FFFFFFF 16r80000000
|
|
239 |
16rFFFFFFFF 16r100000000
|
217
|
240 |
|
1447
|
241 |
16r1FFFFFFFF 16r200000000
|
|
242 |
16r3FFFFFFFF 16r400000000
|
|
243 |
16r7FFFFFFFF 16r800000000
|
|
244 |
16rFFFFFFFFF 16r1000000000
|
217
|
245 |
|
1447
|
246 |
16r1FFFFFFFFF 16r2000000000
|
|
247 |
16r3FFFFFFFFF 16r4000000000
|
|
248 |
16r7FFFFFFFFF 16r8000000000
|
|
249 |
16rFFFFFFFFFF 16r10000000000
|
217
|
250 |
|
1447
|
251 |
16r1FFFFFFFFFF 16r20000000000
|
|
252 |
16r3FFFFFFFFFF 16r40000000000
|
|
253 |
16r7FFFFFFFFFF 16r80000000000
|
|
254 |
16rFFFFFFFFFFF 16r100000000000
|
217
|
255 |
|
1447
|
256 |
16r1FFFFFFFFFFF 16r200000000000
|
|
257 |
16r3FFFFFFFFFFF 16r400000000000
|
|
258 |
16r7FFFFFFFFFFF 16r800000000000
|
|
259 |
16rFFFFFFFFFFFF 16r1000000000000
|
217
|
260 |
|
1447
|
261 |
16r1FFFFFFFFFFFFFF 16r200000000000000
|
|
262 |
16r3FFFFFFFFFFFFFF 16r400000000000000
|
|
263 |
16r7FFFFFFFFFFFFFF 16r800000000000000
|
|
264 |
16rFFFFFFFFFFFFFFF 16r1000000000000000
|
217
|
265 |
|
|
266 |
) do:[:i|
|
1447
|
267 |
self encodeAndDecode:i.
|
|
268 |
self encodeAndDecode:i negated.
|
217
|
269 |
].
|
|
270 |
|
|
271 |
"
|
|
272 |
self run:#testLargeInteger
|
|
273 |
self basicNew testLargeInteger
|
|
274 |
"
|
|
275 |
!
|
|
276 |
|
163
|
277 |
testOrderedCollection
|
|
278 |
"test encoding an decoding of an OrderedCollection"
|
|
279 |
|
|
280 |
|set|
|
|
281 |
|
|
282 |
set := OrderedCollection new.
|
|
283 |
set add:true.
|
|
284 |
set add:'hallo'.
|
|
285 |
set add:#symbol.
|
|
286 |
|
|
287 |
self encodeAndDecode:set
|
|
288 |
|
|
289 |
"
|
|
290 |
self run:#testOrderedCollection
|
|
291 |
"
|
|
292 |
!
|
|
293 |
|
217
|
294 |
testPoint
|
|
295 |
"test encoding an decoding of a point"
|
|
296 |
|
|
297 |
-4 to:4 do:[:x |
|
1447
|
298 |
-4 to:4 do:[:y |
|
|
299 |
self encodeAndDecode:(x @ y)
|
|
300 |
]
|
217
|
301 |
].
|
|
302 |
|
|
303 |
"
|
|
304 |
self run:#testPoint
|
|
305 |
"
|
|
306 |
!
|
|
307 |
|
1551
|
308 |
testRecursiveArray
|
|
309 |
|arr encodedString decodedObject|
|
|
310 |
|
|
311 |
arr := Array new:3.
|
|
312 |
arr at:1 put:1.
|
|
313 |
arr at:2 put:arr.
|
|
314 |
arr at:3 put:3.
|
|
315 |
|
|
316 |
encodedString := XMLStandardCoder new encodingOf:arr.
|
|
317 |
decodedObject := (XMLStandardDecoder on:encodedString readStream) next.
|
|
318 |
self assert:(decodedObject at:1) == 1.
|
|
319 |
self assert:(decodedObject at:3) == 3.
|
|
320 |
self assert:(decodedObject at:2) == decodedObject.
|
|
321 |
"
|
|
322 |
self run:#testRecursiveArray
|
|
323 |
"
|
|
324 |
|
|
325 |
!
|
|
326 |
|
163
|
327 |
testSet
|
|
328 |
"test encoding an decoding of a set"
|
|
329 |
|
|
330 |
|set|
|
|
331 |
|
|
332 |
set := Set new.
|
|
333 |
set add:true.
|
|
334 |
set add:'hallo'.
|
|
335 |
set add:#symbol.
|
|
336 |
|
|
337 |
self encodeAndDecode:set
|
|
338 |
|
|
339 |
"
|
|
340 |
self run:#testSet
|
|
341 |
"
|
|
342 |
!
|
|
343 |
|
|
344 |
testString
|
|
345 |
"test encoding an decoding of a String"
|
165
|
346 |
|
217
|
347 |
self encodeAndDecode:'hello world'.
|
|
348 |
self encodeAndDecode:'hello world üö#*ß'.
|
1447
|
349 |
self encodeAndDecode:Character tab asString , 'with',
|
|
350 |
Character tab asString, Character tab asString, 'tabs',
|
|
351 |
Character tab asString.
|
|
352 |
self encodeAndDecode:Character tab asString , '& with',
|
|
353 |
Character tab asString, Character tab asString, 'tabs',
|
|
354 |
Character tab asString.
|
163
|
355 |
|
|
356 |
"
|
208
|
357 |
self run:#testString
|
|
358 |
"
|
|
359 |
!
|
|
360 |
|
|
361 |
testUUID
|
|
362 |
"test encoding an decoding of an ByteArray"
|
|
363 |
|
|
364 |
self encodeAndDecode:UUID genUUID.
|
|
365 |
|
|
366 |
"
|
163
|
367 |
self run:#testUUID
|
|
368 |
"
|
1551
|
369 |
|
163
|
370 |
! !
|
|
371 |
|
217
|
372 |
!XMLCoderTests class methodsFor:'documentation'!
|
163
|
373 |
|
|
374 |
version
|
|
375 |
^ '$Header$'
|
|
376 |
! !
|
1551
|
377 |
|