factor/basis/unicode/collation/collation-tests.factor

33 lines
1.1 KiB
Factor
Raw Normal View History

2008-06-09 06:22:21 -04:00
USING: io io.files splitting grouping unicode.collation
sequences kernel io.encodings.utf8 math.parser math.order
2008-06-25 04:33:58 -04:00
tools.test assocs io.streams.null words ;
2008-05-20 17:57:53 -04:00
IN: unicode.collation.tests
: parse-test ( -- strings )
2008-07-28 23:03:13 -04:00
"resource:basis/unicode/collation/CollationTest_SHIFTED.txt"
2008-05-20 17:57:53 -04:00
utf8 file-lines 5 tail
[ ";" split1 drop " " split [ hex> ] "" map-as ] map ;
: test-two ( str1 str2 -- )
2008-05-24 13:17:08 -04:00
[ +lt+ ] -rot [ string<=> ] 2curry unit-test ;
2008-05-20 17:57:53 -04:00
: failures
parse-test dup 2 <clumps>
[ string<=> +lt+ = not ] assoc-filter dup assoc-size ;
2008-05-25 21:21:39 -04:00
: test-equality
{ primary= secondary= tertiary= quaternary= }
2008-06-25 05:06:18 -04:00
[ execute ] with with each ;
2008-05-25 21:21:39 -04:00
[ f f f f ] [ "hello" "hi" test-equality ] unit-test
2008-05-29 03:51:16 -04:00
[ t f f f ] [ "hello" "h\u0000e9llo" test-equality ] unit-test
2008-05-25 21:21:39 -04:00
[ t t f f ] [ "hello" "HELLO" test-equality ] unit-test
[ t t t f ] [ "hello" "h e l l o." test-equality ] unit-test
[ t t t t ] [ "hello" "\0hello\0" test-equality ] unit-test
2008-06-01 14:50:12 -04:00
[ { "good bye" "goodbye" "hello" "HELLO" } ]
[ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ]
unit-test
2008-05-25 21:21:39 -04:00
parse-test 2 <clumps>
[ [ test-two ] assoc-each ] with-null-writer