racket/collects/tests/r6rs/unicode.ss
Matthew Flatt 53bc658226 r6rs tests and repairs
svn: r8905
2008-03-06 18:56:31 +00:00

86 lines
3.1 KiB
Scheme

#!r6rs
(library (tests r6rs unicode)
(export run-unicode-tests)
(import (rnrs)
(tests r6rs test))
(define (run-unicode-tests)
(test (char-upcase #\i) #\I)
(test (char-downcase #\i) #\i)
(test (char-titlecase #\i) #\I)
(test (char-foldcase #\i) #\i)
(test (char-upcase #\xDF) #\xDF)
(test (char-downcase #\xDF) #\xDF)
(test (char-titlecase #\xDF) #\xDF)
(test (char-foldcase #\xDF) #\xDF)
(test (char-upcase #\x3A3) #\x3A3)
(test (char-downcase #\x3A3) #\x3C3)
(test (char-titlecase #\x3A3) #\x3A3)
(test (char-foldcase #\x3A3) #\x3C3)
(test (char-upcase #\x3C2) #\x3A3)
(test (char-downcase #\x3C2) #\x3C2)
(test (char-titlecase #\x3C2) #\x3A3)
(test (char-foldcase #\x3C2) #\x3C3)
(test (char-ci<? #\z #\Z) #f)
(test (char-ci=? #\z #\Z) #t)
(test (char-ci=? #\x3C2 #\x3C3) #t)
(test (char-alphabetic? #\a) #t)
(test (char-numeric? #\1) #t)
(test (char-whitespace? #\space) #t)
(test (char-whitespace? #\x00A0) #t)
(test (char-upper-case? #\x3A3) #t)
(test (char-lower-case? #\x3C3) #t)
(test (char-lower-case? #\x00AA) #t)
(test (char-title-case? #\I) #f)
(test (char-title-case? #\x01C5) #t)
(test (char-general-category #\a) 'Ll)
(test (char-general-category #\space) 'Zs)
(test (char-general-category #\x10FFFF) 'Cn)
(test (string-upcase "Hi") "HI")
(test (string-downcase "Hi") "hi")
(test (string-foldcase "Hi") "hi")
(test (string-upcase "Stra\xDF;e") "STRASSE")
(test (string-downcase "Stra\xDF;e") "stra\xDF;e")
(test (string-foldcase "Stra\xDF;e") "strasse")
(test (string-downcase "STRASSE") "strasse")
(test (string-downcase "\x3A3;") "\x3C3;")
(test (string-upcase "\x39E;\x391;\x39F;\x3A3;") "\x39E;\x391;\x39F;\x3A3;")
(test (string-downcase "\x39E;\x391;\x39F;\x3A3;") "\x3BE;\x3B1;\x3BF;\x3C2;")
(test (string-downcase "\x39E;\x391;\x39F;\x3A3;\x3A3;") "\x3BE;\x3B1;\x3BF;\x3C3;\x3C2;")
(test (string-downcase "\x39E;\x391;\x39F;\x3A3; \x3A3;") "\x3BE;\x3B1;\x3BF;\x3C2; \x3C3;")
(test (string-foldcase "\x39E;\x391;\x39F;\x3A3;") "\x3BE;\x3B1;\x3BF;\x3C3;")
(test (string-upcase "\x3BE;\x3B1;\x3BF;\x3C3;") "\x39E;\x391;\x39F;\x3A3;")
(test (string-upcase "\x3BE;\x3B1;\x3BF;\x3C2;") "\x39E;\x391;\x39F;\x3A3;")
(test (string-titlecase "kNock KNoCK") "Knock Knock")
(test (string-titlecase "who's there?") "Who's There?")
(test (string-titlecase "r6rs") "R6Rs")
(test (string-titlecase "R6RS") "R6Rs")
(test (string-ci<? "z" "Z") #f)
(test (string-ci=? "z" "Z") #t)
(test (string-ci=? "Stra\xDF;e" "Strasse") #t)
(test (string-ci=? "Stra\xDF;e" "STRASSE") #t)
(test (string-ci=? "\x39E;\x391;\x39F;\x3A3;" "\x3BE;\x3B1;\x3BF;\x3C2;") #t)
(test (string-ci=? "\x39E;\x391;\x39F;\x3A3;" "\x3BE;\x3B1;\x3BF;\x3C3;") #t)
(test (string-normalize-nfd "\xE9;") "\x65;\x301;")
(test (string-normalize-nfc "\xE9;") "\xE9;")
(test (string-normalize-nfd "\x65;\x301;") "\x65;\x301;")
(test (string-normalize-nfc "\x65;\x301;") "\xE9;")
;;
))