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