]> gitweb.factorcode.org Git - factor.git/blob - extra/io/encodings/detect/detect-tests.factor
Update some copyright headers to follow the current convention
[factor.git] / extra / io / encodings / detect / detect-tests.factor
1 ! Copyright (C) 2010 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: byte-arrays io.encodings.8-bit.koi8-r
4 io.encodings.8-bit.latin1 io.encodings.binary
5 io.encodings.detect io.encodings.utf16 io.encodings.utf32
6 io.encodings.utf8 namespaces tools.test ;
7 IN: io.encodings.detect.tests
8
9 ! UTF encodings with BOMs
10 { utf16be } [ B{ 0xFE 0xFF 0x00 0x31 0x00 0x32 0x00 0x33 } detect-byte-array ] unit-test
11 { utf16le } [ B{ 0xFF 0xFE 0x31 0x00 0x32 0x00 0x33 0x00 } detect-byte-array ] unit-test
12 { utf32be } [ B{ 0x00 0x00 0xFE 0xFF 0x00 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 } detect-byte-array ] unit-test
13 { utf32le } [ B{ 0xFF 0xFE 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 0x00 0x00 0x00 } detect-byte-array ] unit-test
14 { utf8 } [ B{ 0xEF 0xBB 0xBF 0x31 0x32 0x33 } detect-byte-array ] unit-test
15
16 ! XML prolog
17 { utf8 }
18 [ "<?xml version=\"1.0\"?>" >byte-array detect-byte-array ]
19 unit-test
20
21 { utf8 }
22 [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >byte-array detect-byte-array ]
23 unit-test
24
25 { latin1 }
26 [ "<?xml version='1.0' encoding='ISO-8859-1'?>" >byte-array detect-byte-array ]
27 unit-test
28
29 { latin1 }
30 [ "<?xml version='1.0' encoding=\"ISO-8859-1\" " >byte-array detect-byte-array ]
31 unit-test
32
33 ! Default to utf8 if decoding succeeds and there are no nulls
34 { utf8 } [ B{ } detect-byte-array ] unit-test
35 { utf8 } [ B{ 0x31 0x32 0x33 } detect-byte-array ] unit-test
36 { utf8 } [ B{ 0x31 0x32 0xC2 0xA0 0x33 } detect-byte-array ] unit-test
37 { latin1 } [ B{ 0x31 0x32 0xA0 0x33 } detect-byte-array ] unit-test
38 { koi8-r } [
39     koi8-r default-8bit-encoding [
40         B{ 0x31 0x32 0xA0 0x33 } detect-byte-array
41     ] with-variable
42 ] unit-test
43
44 { binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 } detect-byte-array ] unit-test
45 { binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 0x30 } detect-byte-array ] unit-test