Mercurial > hg > xemacs-beta
comparison tests/automated/query-coding-tests.el @ 4855:189fb67ca31a
Create Assert-eq, Assert-equal, etc.
These are equivalent to (Assert (eq ...)) but display both the actual value
and the expected value of the comparison.
Use them throughout the test suite.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 14 Jan 2010 02:18:03 -0600 |
parents | 257b468bf2ca |
children | 0f66906b6e37 |
comparison
equal
deleted
inserted
replaced
4854:95c4ced5c07c | 4855:189fb67ca31a |
---|---|
68 unix-coding-system))) | 68 unix-coding-system))) |
69 (coding-system-list nil)) | 69 (coding-system-list nil)) |
70 :test #'eq)) | 70 :test #'eq)) |
71 (multiple-value-bind (query-coding-succeeded query-coding-table) | 71 (multiple-value-bind (query-coding-succeeded query-coding-table) |
72 (query-coding-region (point-min) (point-max) coding-system) | 72 (query-coding-region (point-min) (point-max) coding-system) |
73 (Assert (eq t query-coding-succeeded) | 73 (Assert-eq t query-coding-succeeded |
74 (format "checking query-coding-region ASCII-transparency, %s" | 74 (format "checking query-coding-region ASCII-transparency, %s" |
75 coding-system)) | 75 coding-system)) |
76 (Assert (null query-coding-table) | 76 (Assert (null query-coding-table) |
77 (format "checking query-coding-region ASCII-transparency, %s" | 77 (format "checking query-coding-region ASCII-transparency, %s" |
78 coding-system))) | 78 coding-system))) |
79 (multiple-value-bind (query-coding-succeeded query-coding-table) | 79 (multiple-value-bind (query-coding-succeeded query-coding-table) |
80 (query-coding-string ascii-chars-string coding-system) | 80 (query-coding-string ascii-chars-string coding-system) |
81 (Assert (eq t query-coding-succeeded) | 81 (Assert-eq t query-coding-succeeded |
82 (format "checking query-coding-string ASCII-transparency, %s" | 82 (format "checking query-coding-string ASCII-transparency, %s" |
83 coding-system)) | 83 coding-system)) |
84 (Assert (null query-coding-table) | 84 (Assert (null query-coding-table) |
85 (format "checking query-coding-string ASCII-transparency, %s" | 85 (format "checking query-coding-string ASCII-transparency, %s" |
86 coding-system)))) | 86 coding-system)))) |
87 (delete-region (point-min) (point-max)) | 87 (delete-region (point-min) (point-max)) |
88 ;; Check for success from the two Latin-1 coding systems | 88 ;; Check for success from the two Latin-1 coding systems |
89 (insert latin-1-chars-string) | 89 (insert latin-1-chars-string) |
90 (multiple-value-bind (query-coding-succeeded query-coding-table) | 90 (multiple-value-bind (query-coding-succeeded query-coding-table) |
91 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) | 91 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) |
92 (Assert (eq t query-coding-succeeded) | 92 (Assert-eq t query-coding-succeeded |
93 "checking query-coding-region iso-8859-1-transparency") | 93 "checking query-coding-region iso-8859-1-transparency") |
94 (Assert (null query-coding-table) | 94 (Assert (null query-coding-table) |
95 "checking query-coding-region iso-8859-1-transparency")) | 95 "checking query-coding-region iso-8859-1-transparency")) |
96 (multiple-value-bind (query-coding-succeeded query-coding-table) | 96 (multiple-value-bind (query-coding-succeeded query-coding-table) |
97 (query-coding-string (buffer-string) 'iso-8859-1-unix) | 97 (query-coding-string (buffer-string) 'iso-8859-1-unix) |
98 (Assert (eq t query-coding-succeeded) | 98 (Assert-eq t query-coding-succeeded |
99 "checking query-coding-string iso-8859-1-transparency") | 99 "checking query-coding-string iso-8859-1-transparency") |
100 (Assert (null query-coding-table) | 100 (Assert (null query-coding-table) |
101 "checking query-coding-string iso-8859-1-transparency")) | 101 "checking query-coding-string iso-8859-1-transparency")) |
102 (multiple-value-bind (query-coding-succeeded query-coding-table) | 102 (multiple-value-bind (query-coding-succeeded query-coding-table) |
103 (query-coding-string (buffer-string) 'iso-latin-1-with-esc-unix) | 103 (query-coding-string (buffer-string) 'iso-latin-1-with-esc-unix) |
104 (Assert | 104 (Assert-eq t query-coding-succeeded |
105 (eq t query-coding-succeeded) | |
106 "checking query-coding-region iso-latin-1-with-esc-transparency") | 105 "checking query-coding-region iso-latin-1-with-esc-transparency") |
107 (Assert | 106 (Assert |
108 (null query-coding-table) | 107 (null query-coding-table) |
109 "checking query-coding-region iso-latin-1-with-esc-transparency")) | 108 "checking query-coding-region iso-latin-1-with-esc-transparency")) |
110 ;; Make it fail, check that it fails correctly | 109 ;; Make it fail, check that it fails correctly |
112 (multiple-value-bind (query-coding-succeeded query-coding-table) | 111 (multiple-value-bind (query-coding-succeeded query-coding-table) |
113 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) | 112 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) |
114 (Assert | 113 (Assert |
115 (null query-coding-succeeded) | 114 (null query-coding-succeeded) |
116 "checking that query-coding-region fails, U+20AC, iso-8859-1") | 115 "checking that query-coding-region fails, U+20AC, iso-8859-1") |
117 (Assert | 116 (Assert-equal query-coding-table |
118 (equal query-coding-table | |
119 #s(range-table type start-closed-end-open data | 117 #s(range-table type start-closed-end-open data |
120 ((257 258) unencodable))) | 118 ((257 258) unencodable)) |
121 "checking query-coding-region fails correctly, U+20AC, iso-8859-1")) | 119 "checking query-coding-region fails correctly, U+20AC, iso-8859-1")) |
122 (multiple-value-bind (query-coding-succeeded query-coding-table) | 120 (multiple-value-bind (query-coding-succeeded query-coding-table) |
123 (query-coding-region (point-min) (point-max) | 121 (query-coding-region (point-min) (point-max) |
124 'iso-latin-1-with-esc-unix) | 122 'iso-latin-1-with-esc-unix) |
125 ;; Stupidly, this succeeds. The behaviour is compatible with | 123 ;; Stupidly, this succeeds. The behaviour is compatible with |
159 (multiple-value-bind (query-coding-succeeded query-coding-table) | 157 (multiple-value-bind (query-coding-succeeded query-coding-table) |
160 (query-coding-region (point-min) (point-max) 'windows-1252-unix) | 158 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
161 (Assert | 159 (Assert |
162 (null query-coding-succeeded) | 160 (null query-coding-succeeded) |
163 "check query-coding-region fails, windows-1252, invalid-sequences") | 161 "check query-coding-region fails, windows-1252, invalid-sequences") |
164 (Assert | 162 (Assert-equal query-coding-table |
165 (equal query-coding-table | |
166 #s(range-table type start-closed-end-open | 163 #s(range-table type start-closed-end-open |
167 data ((130 131) invalid-sequence | 164 data ((130 131) invalid-sequence |
168 (142 143) invalid-sequence | 165 (142 143) invalid-sequence |
169 (144 146) invalid-sequence | 166 (144 146) invalid-sequence |
170 (158 159) invalid-sequence))) | 167 (158 159) invalid-sequence)) |
171 "check query-coding-region fails, windows-1252, invalid-sequences")) | 168 "check query-coding-region fails, windows-1252, invalid-sequences")) |
172 (multiple-value-bind (query-coding-succeeded query-coding-table) | 169 (multiple-value-bind (query-coding-succeeded query-coding-table) |
173 (query-coding-region (point-min) (point-max) 'windows-1252-unix | 170 (query-coding-region (point-min) (point-max) 'windows-1252-unix |
174 (current-buffer) t) | 171 (current-buffer) t) |
175 (Assert | 172 (Assert-eq t query-coding-succeeded |
176 (eq t query-coding-succeeded) | |
177 "checking that query-coding-region succeeds, U+20AC, windows-1252") | 173 "checking that query-coding-region succeeds, U+20AC, windows-1252") |
178 (Assert | 174 (Assert |
179 (null query-coding-table) | 175 (null query-coding-table) |
180 "checking that query-coding-region succeeds, U+20AC, windows-1252")) | 176 "checking that query-coding-region succeeds, U+20AC, windows-1252")) |
181 (insert ?\x80) | 177 (insert ?\x80) |
183 (query-coding-region (point-min) (point-max) 'windows-1252-unix | 179 (query-coding-region (point-min) (point-max) 'windows-1252-unix |
184 (current-buffer) t) | 180 (current-buffer) t) |
185 (Assert | 181 (Assert |
186 (null query-coding-succeeded) | 182 (null query-coding-succeeded) |
187 "checking that query-coding-region fails, U+0080, windows-1252") | 183 "checking that query-coding-region fails, U+0080, windows-1252") |
188 (Assert | 184 (Assert-equal query-coding-table |
189 (equal query-coding-table | |
190 #s(range-table type start-closed-end-open data | 185 #s(range-table type start-closed-end-open data |
191 ((257 258) unencodable))) | 186 ((257 258) unencodable)) |
192 "checking that query-coding-region fails, U+0080, windows-1252")) | 187 "checking that query-coding-region fails, U+0080, windows-1252")) |
193 (multiple-value-bind (query-coding-succeeded query-coding-table) | 188 (multiple-value-bind (query-coding-succeeded query-coding-table) |
194 (query-coding-region (point-min) (point-max) 'windows-1252-unix) | 189 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
195 (Assert | 190 (Assert |
196 (null query-coding-succeeded) | 191 (null query-coding-succeeded) |
197 "check query-coding-region fails, U+0080, invalid-sequence, cp1252") | 192 "check query-coding-region fails, U+0080, invalid-sequence, cp1252") |
198 (Assert | 193 (Assert-equal query-coding-table |
199 (equal query-coding-table | |
200 #s(range-table type start-closed-end-open | 194 #s(range-table type start-closed-end-open |
201 data ((130 131) invalid-sequence | 195 data ((130 131) invalid-sequence |
202 (142 143) invalid-sequence | 196 (142 143) invalid-sequence |
203 (144 146) invalid-sequence | 197 (144 146) invalid-sequence |
204 (158 159) invalid-sequence | 198 (158 159) invalid-sequence |
205 (257 258) unencodable))) | 199 (257 258) unencodable)) |
206 "check query-coding-region fails, U+0080, invalid-sequence, cp1252")) | 200 "check query-coding-region fails, U+0080, invalid-sequence, cp1252")) |
207 ;; Try a similar approach with koi8-o, the koi8 variant with | 201 ;; Try a similar approach with koi8-o, the koi8 variant with |
208 ;; support for Old Church Slavonic. | 202 ;; support for Old Church Slavonic. |
209 (delete-region (point-min) (point-max)) | 203 (delete-region (point-min) (point-max)) |
210 (insert latin-1-chars-string) | 204 (insert latin-1-chars-string) |
217 (Assert | 211 (Assert |
218 (null query-coding-table) | 212 (null query-coding-table) |
219 "checking that query-coding-region succeeds, koi8-o-unix")) | 213 "checking that query-coding-region succeeds, koi8-o-unix")) |
220 (multiple-value-bind (query-coding-succeeded query-coding-table) | 214 (multiple-value-bind (query-coding-succeeded query-coding-table) |
221 (query-coding-region (point-min) (point-max) 'escape-quoted) | 215 (query-coding-region (point-min) (point-max) 'escape-quoted) |
222 (Assert (eq t query-coding-succeeded) | 216 (Assert-eq t query-coding-succeeded |
223 "checking that query-coding-region succeeds, escape-quoted") | 217 "checking that query-coding-region succeeds, escape-quoted") |
224 (Assert (null query-coding-table) | 218 (Assert (null query-coding-table) |
225 "checking that query-coding-region succeeds, escape-quoted")) | 219 "checking that query-coding-region succeeds, escape-quoted")) |
226 (multiple-value-bind (query-coding-succeeded query-coding-table) | 220 (multiple-value-bind (query-coding-succeeded query-coding-table) |
227 (query-coding-region (point-min) (point-max) 'windows-1252-unix) | 221 (query-coding-region (point-min) (point-max) 'windows-1252-unix) |
281 utf-16-little-endian-bom)) | 275 utf-16-little-endian-bom)) |
282 (multiple-value-bind (query-coding-succeeded query-coding-table) | 276 (multiple-value-bind (query-coding-succeeded query-coding-table) |
283 (query-coding-region (point-min) (point-max) coding-system) | 277 (query-coding-region (point-min) (point-max) coding-system) |
284 (Assert (null query-coding-succeeded) | 278 (Assert (null query-coding-succeeded) |
285 "checking unicode coding systems fail with unmapped chars") | 279 "checking unicode coding systems fail with unmapped chars") |
286 (Assert (equal query-coding-table | 280 (Assert-equal query-coding-table |
287 #s(range-table type start-closed-end-open data | 281 #s(range-table type start-closed-end-open data |
288 ((173 174) unencodable | 282 ((173 174) unencodable |
289 (209 210) unencodable | 283 (209 210) unencodable |
290 (254 255) unencodable))) | 284 (254 255) unencodable)) |
291 "checking unicode coding systems fail with unmapped chars")) | 285 "checking unicode coding systems fail with unmapped chars")) |
292 (multiple-value-bind (query-coding-succeeded query-coding-table) | 286 (multiple-value-bind (query-coding-succeeded query-coding-table) |
293 (query-coding-region (point-min) 173 coding-system) | 287 (query-coding-region (point-min) 173 coding-system) |
294 (Assert (eq t query-coding-succeeded) | 288 (Assert-eq t query-coding-succeeded |
295 "checking unicode coding systems succeed sans unmapped chars") | 289 "checking unicode coding systems succeed sans unmapped chars") |
296 (Assert | 290 (Assert |
297 (null query-coding-table) | 291 (null query-coding-table) |
298 "checking unicode coding systems succeed sans unmapped chars")) | 292 "checking unicode coding systems succeed sans unmapped chars")) |
299 (multiple-value-bind (query-coding-succeeded query-coding-table) | 293 (multiple-value-bind (query-coding-succeeded query-coding-table) |
304 (Assert | 298 (Assert |
305 (null query-coding-table) | 299 (null query-coding-table) |
306 "checking unicode coding systems succeed sans unmapped chars again")) | 300 "checking unicode coding systems succeed sans unmapped chars again")) |
307 (multiple-value-bind (query-coding-succeeded query-coding-table) | 301 (multiple-value-bind (query-coding-succeeded query-coding-table) |
308 (query-coding-region 210 254 coding-system) | 302 (query-coding-region 210 254 coding-system) |
309 (Assert (eq t query-coding-succeeded)) | 303 (Assert-eq t query-coding-succeeded) |
310 (Assert (null query-coding-table))) | 304 (Assert (null query-coding-table))) |
311 ;; Check that it errors correctly. | 305 ;; Check that it errors correctly. |
312 (setq text-conversion-error-signalled nil) | 306 (setq text-conversion-error-signalled nil) |
313 (condition-case nil | 307 (condition-case nil |
314 (query-coding-region (point-min) (point-max) coding-system | 308 (query-coding-region (point-min) (point-max) coding-system |
340 (query-coding-region (point-min) (point-max) coding-system) | 334 (query-coding-region (point-min) (point-max) coding-system) |
341 (Assert (null query-coding-succeeded) | 335 (Assert (null query-coding-succeeded) |
342 (format | 336 (format |
343 "checking %s fails with unmapped chars and invalid seqs" | 337 "checking %s fails with unmapped chars and invalid seqs" |
344 coding-system)) | 338 coding-system)) |
345 (Assert (equal query-coding-table | 339 (Assert-equal query-coding-table |
346 #s(range-table type start-closed-end-open | 340 #s(range-table type start-closed-end-open |
347 data ((1 5) unencodable | 341 data ((1 5) unencodable |
348 (5 9) invalid-sequence | 342 (5 9) invalid-sequence |
349 (9 13) unencodable))) | 343 (9 13) unencodable)) |
350 (format | 344 (format |
351 "checking %s fails with unmapped chars and invalid seqs" | 345 "checking %s fails with unmapped chars and invalid seqs" |
352 coding-system))) | 346 coding-system))) |
353 (multiple-value-bind (query-coding-succeeded query-coding-table) | 347 (multiple-value-bind (query-coding-succeeded query-coding-table) |
354 (query-coding-region (point-min) (point-max) coding-system | 348 (query-coding-region (point-min) (point-max) coding-system |
394 (equal '(257) (unencodable-char-position (point-min) (point-max) | 388 (equal '(257) (unencodable-char-position (point-min) (point-max) |
395 'iso-8859-1 0)) | 389 'iso-8859-1 0)) |
396 "check #'unencodable-char-position has some borked GNU semantics") | 390 "check #'unencodable-char-position has some borked GNU semantics") |
397 (dotimes (i 6) (insert (decode-char 'ucs #x20ac))) | 391 (dotimes (i 6) (insert (decode-char 'ucs #x20ac))) |
398 ;; Check if it stops at one: | 392 ;; Check if it stops at one: |
399 (Assert (equal '(257) (unencodable-char-position (point-min) (point-max) | 393 (Assert-equal '(257) (unencodable-char-position (point-min) (point-max) |
400 'iso-8859-1 1)) | 394 'iso-8859-1 1) |
401 "check #'unencodable-char-position stops at 1 when asked to") | 395 "check #'unencodable-char-position stops at 1 when asked to") |
402 ;; Check if it stops at four: | 396 ;; Check if it stops at four: |
403 (Assert (equal '(260 259 258 257) | 397 (Assert-equal '(260 259 258 257) |
404 (unencodable-char-position (point-min) (point-max) | 398 (unencodable-char-position (point-min) (point-max) |
405 'iso-8859-1 4)) | 399 'iso-8859-1 4) |
406 "check #'unencodable-char-position stops at 4 when asked to") | 400 "check #'unencodable-char-position stops at 4 when asked to") |
407 ;; Check whether it stops at seven: | 401 ;; Check whether it stops at seven: |
408 (Assert (equal '(263 262 261 260 259 258 257) | 402 (Assert-equal '(263 262 261 260 259 258 257) |
409 (unencodable-char-position (point-min) (point-max) | 403 (unencodable-char-position (point-min) (point-max) |
410 'iso-8859-1 7)) | 404 'iso-8859-1 7) |
411 "check #'unencodable-char-position stops at 7 when asked to") | 405 "check #'unencodable-char-position stops at 7 when asked to") |
412 ;; Check that it still stops at seven: | 406 ;; Check that it still stops at seven: |
413 (Assert (equal '(263 262 261 260 259 258 257) | 407 (Assert-equal '(263 262 261 260 259 258 257) |
414 (unencodable-char-position (point-min) (point-max) | 408 (unencodable-char-position (point-min) (point-max) |
415 'iso-8859-1 2000)) | 409 'iso-8859-1 2000) |
416 "check #'unencodable-char-position stops at 7 if 2000 asked for") | 410 "check #'unencodable-char-position stops at 7 if 2000 asked for") |
417 ;; Now, #'check-coding-systems-region. | 411 ;; Now, #'check-coding-systems-region. |
418 ;; UTF-8 should certainly be able to encode these characters: | 412 ;; UTF-8 should certainly be able to encode these characters: |
419 (Assert (null (check-coding-systems-region (point-min) (point-max) | 413 (Assert (null (check-coding-systems-region (point-min) (point-max) |
420 '(utf-8))) | 414 '(utf-8))) |