1692
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#EncoderTests
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression-Collections'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!EncoderTests class methodsFor:'queries'!
|
|
14 |
|
|
15 |
coveredClassNames
|
|
16 |
^ #( Base64Coder Base32Coder )
|
|
17 |
|
|
18 |
"Modified: / 26-08-2017 / 12:38:14 / cg"
|
|
19 |
! !
|
|
20 |
|
|
21 |
!EncoderTests methodsFor:'testing'!
|
|
22 |
|
|
23 |
test01_base64
|
|
24 |
|verbose|
|
|
25 |
|
|
26 |
verbose := false.
|
|
27 |
|
|
28 |
0 to:80 do:[:l |
|
|
29 |
|coder decoder data encoding decoded|
|
|
30 |
|
|
31 |
data := (0 to:l) asByteArray copyTo:l.
|
|
32 |
coder := Base64Coder on:'' writeStream.
|
|
33 |
coder nextPutAll:data.
|
|
34 |
coder flush.
|
|
35 |
|
|
36 |
encoding := coder contents.
|
|
37 |
|
|
38 |
decoder := Base64Coder on:encoding readStream.
|
|
39 |
decoded := decoder upToEnd.
|
|
40 |
|
|
41 |
verbose ifTrue:[
|
|
42 |
Transcript showCR:(data printString).
|
|
43 |
Transcript show:' -> '; showCR:encoding.
|
|
44 |
Transcript show:' ---> '; showCR:(decoded printString).
|
|
45 |
].
|
|
46 |
|
|
47 |
self assert:(data = decoded).
|
|
48 |
].
|
|
49 |
|
|
50 |
"
|
|
51 |
self new test01_base64
|
|
52 |
"
|
|
53 |
|
|
54 |
"Created: / 26-08-2017 / 12:38:40 / cg"
|
|
55 |
!
|
|
56 |
|
|
57 |
test11_base32
|
|
58 |
|verbose|
|
|
59 |
|
|
60 |
verbose := false.
|
|
61 |
|
|
62 |
0 to:80 do:[:l |
|
|
63 |
|coder decoder data encoding decoded|
|
|
64 |
|
|
65 |
data := (0 to:l) asByteArray copyTo:l.
|
|
66 |
coder := Base32Coder on:'' writeStream.
|
|
67 |
coder nextPutAll:data.
|
|
68 |
coder flush.
|
|
69 |
|
|
70 |
encoding := coder contents.
|
|
71 |
|
|
72 |
decoder := Base32Coder on:encoding readStream.
|
|
73 |
decoded := decoder upToEnd.
|
|
74 |
|
|
75 |
verbose ifTrue:[
|
|
76 |
Transcript showCR:(data printString).
|
|
77 |
Transcript show:' -> '; showCR:encoding.
|
|
78 |
Transcript show:' ---> '; showCR:(decoded printString).
|
|
79 |
].
|
|
80 |
self assert:(data = decoded).
|
|
81 |
].
|
|
82 |
|
|
83 |
"
|
|
84 |
self new test11_base32
|
|
85 |
"
|
|
86 |
|
|
87 |
"Created: / 26-08-2017 / 12:38:59 / cg"
|
|
88 |
! !
|
|
89 |
|
|
90 |
!EncoderTests class methodsFor:'documentation'!
|
|
91 |
|
|
92 |
version
|
|
93 |
^ '$Header$'
|
|
94 |
!
|
|
95 |
|
|
96 |
version_CVS
|
|
97 |
^ '$Header$'
|
|
98 |
! !
|
|
99 |
|