]> gitweb.factorcode.org Git - factor.git/blob - basis/unicode/collation/collation-tests.factor
bf87c6b7da027a016f442ad2c832906a5116a961
[factor.git] / basis / unicode / collation / collation-tests.factor
1 USING: io io.files splitting grouping unicode.collation\r
2 sequences kernel io.encodings.utf8 math.parser math.order\r
3 tools.test assocs io.streams.null words ;\r
4 IN: unicode.collation.tests\r
5 \r
6 : parse-test ( -- strings )\r
7     "resource:basis/unicode/collation/CollationTest_SHIFTED.txt"\r
8     utf8 file-lines 5 tail\r
9     [ ";" split1 drop " " split [ hex> ] "" map-as ] map ;\r
10 \r
11 : test-two ( str1 str2 -- )\r
12     [ +lt+ ] -rot [ string<=> ] 2curry unit-test ;\r
13 \r
14 : failures\r
15     parse-test dup 2 <clumps>\r
16     [ string<=> +lt+ = not ] assoc-filter dup assoc-size ;\r
17 \r
18 : test-equality\r
19     { primary= secondary= tertiary= quaternary= }\r
20     [ execute ] with with each ;\r
21 \r
22 [ f f f f ] [ "hello" "hi" test-equality ] unit-test\r
23 [ t f f f ] [ "hello" "h\u0000e9llo" test-equality ] unit-test\r
24 [ t t f f ] [ "hello" "HELLO" test-equality ] unit-test\r
25 [ t t t f ] [ "hello" "h e l l o." test-equality ] unit-test\r
26 [ t t t t ] [ "hello" "\0hello\0" test-equality ] unit-test\r
27 [ { "good bye" "goodbye" "hello" "HELLO" } ]\r
28 [ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ]\r
29 unit-test\r
30 \r
31 parse-test 2 <clumps>\r
32 [ [ test-two ] assoc-each ] with-null-writer\r