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