| 1 |
;; -*- coding: utf-8 -*- |
| 2 |
;; Auxiliary test for string <-> uvector conversion (UTF-8) |
| 3 |
|
| 4 |
(test "mb string->u8vector" '#u8(#xe3 #x81 #x82 #xe3 #x81 #x84 #xe3 #x81 #x86) |
| 5 |
(lambda () |
| 6 |
(string->u8vector "あいう"))) |
| 7 |
(test "mb string->u8vector (start)" '#u8(#xe3 #x81 #x84 #xe3 #x81 #x86) |
| 8 |
(lambda () |
| 9 |
(string->u8vector "あいう" 1))) |
| 10 |
(test "mb string->u8vector (start,end)" '#u8(#xe3 #x81 #x82 #xe3 #x81 #x84) |
| 11 |
(lambda () |
| 12 |
(string->u8vector "あいう" 0 2))) |
| 13 |
(test "mb string->u8vector (start,end)" 'error |
| 14 |
(lambda () |
| 15 |
(with-error-handler |
| 16 |
(^e 'error) |
| 17 |
(lambda () |
| 18 |
(string->u8vector "あいう" 0 4))))) |
| 19 |
|
| 20 |
(test "mb u8vector->string" "あいう" |
| 21 |
(lambda () |
| 22 |
(u8vector->string '#u8(#xe3 #x81 #x82 #xe3 #x81 #x84 #xe3 #x81 #x86)))) |
| 23 |
(test "mb u8vector->string (incomplete, premature)" #*"\xe3\x81\x82\xe3" |
| 24 |
(lambda () |
| 25 |
(u8vector->string '#u8(#xe3 #x81 #x82 #xe3 #x81 #x84 #xe3 #x81 #x86) 0 4))) |
| 26 |
(test "mb u8vector->string (incomplete, bad leading byte)" #*"\x80" |
| 27 |
(lambda () |
| 28 |
(u8vector->string '#u8(#x80)))) |
| 29 |
(test "mb u8vector->string (incomplete, redundant encoding)" #*"\xc0\x90" |
| 30 |
(lambda () |
| 31 |
(u8vector->string '#u8(#xc0 #x90)))) |
| 32 |
|
| 33 |
(test "mb string->u32vector" '#u32(#x3042 #x41 #x3044 #x42) |
| 34 |
(lambda () |
| 35 |
(string->u32vector "あAいB"))) |
| 36 |
(test "mb string->u32vector (start)" '#u32(#x41 #x3044 #x42) |
| 37 |
(lambda () |
| 38 |
(string->u32vector "あAいB" 1))) |
| 39 |
(test "mb string->u32vector (start, end)" '#u32(#x3042 #x41 #x3044) |
| 40 |
(lambda () |
| 41 |
(string->u32vector "あAいB" 0 3))) |
| 42 |
|
| 43 |
(test "mb u32vector->string" "あAいB" |
| 44 |
(lambda () |
| 45 |
(u32vector->string '#u32(#x3042 #x41 #x3044 #x42)))) |
| 46 |
(test "mb u32vector->string (start, end)" "Aい" |
| 47 |
(lambda () |
| 48 |
(u32vector->string '#u32(#x3042 #x41 #x3044 #x42) 1 3))) |