Make stuff regarding debug names much less complex.
[sbcl.git] / tests / enc-jpn.pure.lisp
blob681f855add795e7b46526721efa3d939ccd3658f
1 ;; -*- coding: utf-8 -*-
2 #+(or (not sb-unicode) unicode-lite) (invoke-restart 'run-tests::skip-file)
4 (let ((str (coerce '(#\u0041 #\uff71 #\uff21 #\u3042 #\u6f3e #\u71f9 #\u91ed)
5 'string))
6 (eucjp '(#x41 #x8e #xb1 #xa3 #xc1 #xa4 #xa2 #xdf #xa1 #xe0 #xa1
7 #x8f #xe3 #xaf))
8 (sjis '(#x41 #xb1 #x82 #x60 #x82 #xa0 #xe0 #x40 #xe0 #x9f #xfb #xbd))
9 (file (scratch-file-name)))
10 (dolist (pair (list (list eucjp :euc-jp)
11 (list sjis :shift_jis)))
12 (destructuring-bind (bytes enc) pair
13 ;; check if output works
14 (with-open-file (s file :direction :output
15 :if-exists :supersede :external-format enc)
16 (write-string str s))
17 (with-open-file (s file :direction :input
18 :element-type '(unsigned-byte 8))
19 (loop for c in bytes
20 do (assert (eql (read-byte s) c))))
22 ;; check if input works
23 (with-open-file (s file :direction :input :external-format enc)
24 (loop for c across str
25 do (assert (eql (read-char s) c))))
27 ;; check if string conversion works
28 (assert (equal (coerce (string-to-octets str :external-format enc)
29 'list)
30 bytes))
31 (assert (equal (octets-to-string (coerce bytes
32 '(vector (unsigned-byte 8)))
33 :external-format enc)
34 str))))
36 (delete-file file))
37 ;;; success