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
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
11 : test-two ( str1 str2 -- )
\r
12 [ +lt+ ] -rot [ string<=> ] 2curry unit-test ;
\r
15 parse-test dup 2 <clumps>
\r
16 [ string<=> +lt+ = not ] assoc-filter dup assoc-size ;
\r
19 { primary= secondary= tertiary= quaternary= }
\r
20 [ execute ] with with each ;
\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
31 parse-test 2 <clumps>
\r
32 [ [ test-two ] assoc-each ] with-null-writer
\r