1 ;;; -*- coding: utf-8 -*-
2 ;;; enc-cn.impure.lisp: test case for enc-cn.lisp and enc-cn-tbl.lisp
3 #+(or (not sb-unicode
) unicode-lite
) (invoke-restart 'run-tests
::skip-file
)
5 (let ((str (coerce '(#\u0031 #\u0041 #\uff21 #\u3042 #\u80e1 #\u73a5 #\u59ee)
7 (gbk '(#x31
#x41
#xa3
#xc1
#xa4
#xa2
#xba
#xfa
#xab
#x68
#x8a
#xac
))
8 (file (scratch-file-name)))
9 (dolist (pair (list (list gbk
:gbk
)))
10 (destructuring-bind (bytes enc
) pair
11 ;; check if output works
12 (with-open-file (s file
:direction
:output
13 :if-exists
:supersede
:external-format enc
)
15 (with-open-file (s file
:direction
:input
16 :element-type
'(unsigned-byte 8))
18 do
(assert (eql (read-byte s
) c
))))
20 ;; check if input works
21 (with-open-file (s file
:direction
:input
:external-format enc
)
22 (loop for c across str
23 do
(assert (eql (read-char s
) c
))))
25 ;; check if string conversion works
26 (assert (equal (coerce (string-to-octets str
:external-format enc
)
29 (assert (equal (octets-to-string (coerce bytes
30 '(vector (unsigned-byte 8)))