]> gitweb.factorcode.org Git - factor.git/blob - core/io/encodings/utf8/utf8-tests.factor
a99575b4bac585295acfa4c8adbb29c79947a7c1
[factor.git] / core / io / encodings / utf8 / utf8-tests.factor
1 USING: io.encodings.utf8 tools.test io.encodings.string strings arrays
2 bootstrap.unicode ;
3 IN: io.encodings.utf8.tests
4
5 : decode-utf8-w/stream ( array -- newarray )
6     utf8 decode >array ;
7
8 : encode-utf8-w/stream ( array -- newarray )
9     utf8 encode >array ;
10
11 [ { CHAR: replacement-character } ] [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 11111111 } decode-utf8-w/stream ] unit-test
12
13 [ { BIN: 101111111000000111111 } ] [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 } decode-utf8-w/stream ] unit-test
14
15 [ "x" ] [ "x" decode-utf8-w/stream >string ] unit-test
16
17 [ { BIN: 11111000000 } ] [ { BIN: 11011111 BIN: 10000000 } decode-utf8-w/stream >array ] unit-test
18
19 [ { CHAR: replacement-character } ] [ { BIN: 10000000 } decode-utf8-w/stream ] unit-test
20
21 [ { BIN: 1111000000111111 } ] [ { BIN: 11101111 BIN: 10000000 BIN: 10111111 } decode-utf8-w/stream >array ] unit-test
22
23 [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ]
24 [ { BIN: 101111111000000111111 BIN: 1111000000111111 BIN: 11111000000 CHAR: x } encode-utf8-w/stream ] unit-test