author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 12 May 2015 12:20:53 +0100 | |
changeset 296 | ea3dbc023c80 |
parent 174 | core/trunk/XMLv2__EncodingTests.st@76f50ac2e6a0 |
child 300 | b6d834208d33 |
permissions | -rw-r--r-- |
3
7909b6680107
Loaded into & commited from 5.3.6
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
1 |
"{ Package: 'stx:goodies/xmlsuite/core' }" |
0 | 2 |
|
3 |
"{ NameSpace: XMLv2 }" |
|
4 |
||
5 |
TestCase subclass:#EncodingTests |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'XML Suite-Tests' |
|
10 |
! |
|
11 |
||
12 |
!EncodingTests class methodsFor:'documentation'! |
|
13 |
||
14 |
documentation |
|
15 |
" |
|
16 |
documentation to be added. |
|
17 |
||
18 |
[author:] |
|
19 |
Jan Vrany (janfrog@bruxa) |
|
20 |
||
21 |
[instance variables:] |
|
22 |
||
23 |
[class variables:] |
|
24 |
||
25 |
[see also:] |
|
26 |
||
27 |
" |
|
28 |
! |
|
29 |
||
30 |
history |
|
31 |
"Created: / 15-06-2005 / 13:48:02 / janfrog" |
|
32 |
! ! |
|
33 |
||
34 |
!EncodingTests class methodsFor:'defaults'! |
|
35 |
||
36 |
defaultTestDirectory |
|
37 |
||
38 |
^(Smalltalk getPackageDirectoryForPackage:self package) |
|
39 |
construct:'resources/tests/encoding' |
|
40 |
||
41 |
"Created: / 15-06-2005 / 14:26:36 / janfrog" |
|
42 |
"Modified: / 22-06-2005 / 09:22:56 / masca" |
|
43 |
! ! |
|
44 |
||
45 |
!EncodingTests methodsFor:'accessing'! |
|
46 |
||
47 |
letters |
|
48 |
||
49 |
^'+ěščřžýáíéúů+ĚŠČŘŽÝÁÍÉÚŮ' |
|
50 |
utf8Decoded |
|
51 |
||
52 |
"Created: / 15-06-2005 / 14:44:15 / janfrog" |
|
53 |
! |
|
54 |
||
55 |
sentence |
|
56 |
||
57 |
^'Příliš žluťoučký kůň úpěl ďábelské ódy' |
|
58 |
utf8Decoded |
|
59 |
||
60 |
"Modified: / 15-06-2005 / 14:43:28 / janfrog" |
|
61 |
! ! |
|
62 |
||
63 |
!EncodingTests methodsFor:'initialize / release'! |
|
64 |
||
65 |
setUp |
|
66 |
"common setup - invoked before testing." |
|
67 |
||
68 |
super setUp |
|
69 |
||
70 |
"Created: / 15-06-2005 / 13:48:02 / janfrog" |
|
71 |
! |
|
72 |
||
73 |
tearDown |
|
74 |
"common cleanup - invoked after testing." |
|
75 |
||
76 |
super tearDown |
|
77 |
||
78 |
"Created: / 15-06-2005 / 13:48:02 / janfrog" |
|
79 |
! ! |
|
80 |
||
81 |
!EncodingTests methodsFor:'tests'! |
|
82 |
||
83 |
test_read_iso8859_2 |
|
84 |
||
85 |
| doc xmlSentence xmlLetters| |
|
86 |
doc := XMLv2::Parser new |
|
87 |
processDocumentInFilename: |
|
88 |
(self class defaultTestDirectory |
|
89 |
construct:'enc-iso8859-2.xml'). |
|
90 |
xmlSentence := (doc root anyElementNamed:'sentence') characterData. |
|
91 |
xmlLetters := (doc root anyElementNamed:'letters') characterData. |
|
92 |
||
93 |
self assert:self sentence = xmlSentence. |
|
94 |
self assert:self letters = xmlLetters. |
|
95 |
||
96 |
"Created: / 15-06-2005 / 14:56:14 / janfrog" |
|
97 |
! |
|
98 |
||
99 |
test_read_utf8 |
|
100 |
||
101 |
| doc xmlSentence xmlLetters| |
|
102 |
doc := XMLv2::Parser new |
|
103 |
processDocumentInFilename: |
|
104 |
(self class defaultTestDirectory |
|
105 |
construct:'enc-utf8.xml'). |
|
106 |
xmlSentence := (doc root anyElementNamed:'sentence') characterData. |
|
107 |
xmlLetters := (doc root anyElementNamed:'letters') characterData. |
|
108 |
||
109 |
self assert:self sentence = xmlSentence. |
|
110 |
self assert:self letters = xmlLetters. |
|
111 |
||
112 |
" |
|
113 |
self sentence |
|
114 |
xmlSentence |
|
115 |
" |
|
116 |
||
117 |
"Created: / 15-06-2005 / 14:55:41 / janfrog" |
|
118 |
! |
|
119 |
||
120 |
test_read_utf8_without_encoding_decl |
|
121 |
||
122 |
| doc xmlSentence xmlLetters| |
|
123 |
doc := XMLv2::Parser new |
|
124 |
processDocumentInFilename: |
|
125 |
(self class defaultTestDirectory |
|
126 |
construct:'enc-utf8-without-encoding-decl.xml'). |
|
127 |
xmlSentence := (doc root anyElementNamed:'sentence') characterData. |
|
128 |
xmlLetters := (doc root anyElementNamed:'letters') characterData. |
|
129 |
||
130 |
self assert:self sentence = xmlSentence. |
|
131 |
self assert:self letters = xmlLetters. |
|
132 |
||
133 |
" |
|
134 |
self sentence |
|
135 |
xmlSentence |
|
136 |
" |
|
137 |
||
138 |
"Created: / 16-06-2005 / 09:19:28 / janfrog" |
|
139 |
! |
|
140 |
||
141 |
test_write_iso8859_2 |
|
142 |
||
143 |
| doc fileBuffer docBuffer | |
|
144 |
doc := XML::Document new. |
|
145 |
doc addNode:(XML::Element tag:'enc'). |
|
146 |
doc root addNode: |
|
147 |
((XML::Element tag:'sentence') |
|
148 |
addNode:(XML::Text text:self sentence)). |
|
149 |
doc root addNode: |
|
150 |
((XML::Element tag:'letters') |
|
151 |
addNode:(XML::Text text:self letters)). |
|
152 |
||
153 |
||
154 |
fileBuffer := (self class defaultTestDirectory |
|
155 |
construct:'enc-iso8859-2.xml') readStream binary contents. |
|
156 |
||
157 |
docBuffer := (ByteArray new:189) writeStream. |
|
158 |
OldXMLWriter new |
|
159 |
stream:docBuffer; |
|
160 |
formatOutput:false; |
|
161 |
encoding:#'iso-8859-2'; |
|
162 |
write:doc. |
|
163 |
docBuffer := docBuffer contents. |
|
164 |
||
165 |
self assert:docBuffer = fileBuffer. |
|
166 |
||
167 |
||
168 |
||
169 |
"doc := XMLv2::Parser new |
|
170 |
processDocumentInFilename: |
|
171 |
(self class defaultTestDirectory |
|
172 |
construct:'enc-utf8.xml'). |
|
173 |
xmlSentence := (doc root anyElementNamed:'sentence') characterData. |
|
174 |
xmlLetters := (doc root anyElementNamed:'letters') characterData. |
|
175 |
||
176 |
self assert:self sentence = xmlSentence. |
|
177 |
self assert:self letters = xmlLetters. |
|
178 |
" |
|
179 |
||
180 |
" |
|
181 |
self sentence |
|
182 |
xmlSentence |
|
183 |
" |
|
184 |
||
185 |
"Created: / 15-06-2005 / 19:29:44 / janfrog" |
|
186 |
"Modified: / 18-10-2005 / 11:31:57 / janfrog" |
|
187 |
! |
|
188 |
||
189 |
test_write_utf8 |
|
190 |
||
191 |
| doc fileBuffer docBuffer | |
|
192 |
doc := XML::Document new. |
|
193 |
doc addNode:(XML::Element tag:'enc'). |
|
194 |
doc root addNode: |
|
195 |
((XML::Element tag:'sentence') |
|
196 |
addNode:(XML::Text text:self sentence)). |
|
197 |
doc root addNode: |
|
198 |
((XML::Element tag:'letters') |
|
199 |
addNode:(XML::Text text:self letters)). |
|
200 |
||
201 |
||
202 |
fileBuffer := (self class defaultTestDirectory |
|
203 |
construct:'enc-utf8.xml') readStream binary contents. |
|
204 |
||
205 |
docBuffer := (ByteArray new:189) writeStream. |
|
206 |
OldXMLWriter write:doc on:docBuffer format:false. |
|
207 |
docBuffer := docBuffer contents. |
|
208 |
||
209 |
self assert:docBuffer = fileBuffer. |
|
210 |
||
211 |
||
212 |
"doc := XMLv2::Parser new |
|
213 |
processDocumentInFilename: |
|
214 |
(self class defaultTestDirectory |
|
215 |
construct:'enc-utf8.xml'). |
|
216 |
xmlSentence := (doc root anyElementNamed:'sentence') characterData. |
|
217 |
xmlLetters := (doc root anyElementNamed:'letters') characterData. |
|
218 |
||
219 |
self assert:self sentence = xmlSentence. |
|
220 |
self assert:self letters = xmlLetters. |
|
221 |
" |
|
222 |
||
223 |
" |
|
224 |
self sentence |
|
225 |
xmlSentence |
|
226 |
" |
|
227 |
||
228 |
"Created: / 15-06-2005 / 19:09:33 / janfrog" |
|
229 |
"Modified: / 18-10-2005 / 11:31:53 / janfrog" |
|
230 |
! ! |
|
231 |
||
232 |
!EncodingTests class methodsFor:'documentation'! |
|
233 |
||
234 |
version |
|
235 |
^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/XMLv2__EncodingTests.st,v 1.1.1.1 2005-11-01 22:05:44 vranyj1 Exp $' |
|
174
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
236 |
! |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
237 |
|
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
238 |
version_SVN |
76f50ac2e6a0
removed dependency on libutilui ans sunit, testcases are autoloaded
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3
diff
changeset
|
239 |
^ '$Id$' |
0 | 240 |
! ! |