1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-22 12:30:32 +02:00

Tests for locale-specific case conversion

* test-suite/tests/i18n.test: add tests for case conversion of Turkish
  letters 'i' to verify that the language is being honored.
This commit is contained in:
Michael Gran 2009-09-24 08:10:03 -07:00
parent 2c48e4d5b7
commit bcccf04158

View file

@ -85,6 +85,9 @@
(define %french-utf8-locale-name (define %french-utf8-locale-name
"fr_FR.UTF-8") "fr_FR.UTF-8")
(define %turkish-utf8-locale-name
"tr_TR.UTF-8")
(define %french-locale (define %french-locale
(false-if-exception (false-if-exception
(make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME) (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME)
@ -95,6 +98,11 @@
(make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME) (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME)
%french-utf8-locale-name))) %french-utf8-locale-name)))
(define %turkish-utf8-locale
(false-if-exception
(make-locale LC_ALL
%turkish-utf8-locale-name)))
(define (under-locale-or-unresolved locale thunk) (define (under-locale-or-unresolved locale thunk)
;; On non-GNU systems, an exception may be raised only when the locale is ;; On non-GNU systems, an exception may be raised only when the locale is
;; actually used rather than at `make-locale'-time. Thus, we must guard ;; actually used rather than at `make-locale'-time. Thus, we must guard
@ -113,6 +121,8 @@
(define (under-french-utf8-locale-or-unresolved thunk) (define (under-french-utf8-locale-or-unresolved thunk)
(under-locale-or-unresolved %french-utf8-locale thunk)) (under-locale-or-unresolved %french-utf8-locale thunk))
(define (under-turkish-utf8-locale-or-unresolved thunk)
(under-locale-or-unresolved %turkish-utf8-locale thunk))
(with-test-prefix "text collation (French)" (with-test-prefix "text collation (French)"
@ -190,7 +200,38 @@
(pass-if "char-locale-upcase" (pass-if "char-locale-upcase"
(and (eq? #\Z (char-locale-upcase #\z)) (and (eq? #\Z (char-locale-upcase #\z))
(eq? #\Z (char-locale-upcase #\z (make-locale LC_ALL "C")))))) (eq? #\Z (char-locale-upcase #\z (make-locale LC_ALL "C")))))
(pass-if "char-locale-upcase Turkish"
(under-turkish-utf8-locale-or-unresolved
(lambda ()
(eq? #\İ (char-locale-upcase #\i %turkish-utf8-locale)))))
(pass-if "char-locale-downcase Turkish"
(under-turkish-utf8-locale-or-unresolved
(lambda ()
(eq? #\i (char-locale-downcase #\İ %turkish-utf8-locale))))))
(with-test-prefix "string mapping"
(pass-if "string-locale-downcase"
(and (string=? "a" (string-locale-downcase "A"))
(string=? "a" (string-locale-downcase "A" (make-locale LC_ALL "C")))))
(pass-if "string-locale-upcase"
(and (string=? "Z" (string-locale-upcase "z"))
(string=? "Z" (string-locale-upcase "z" (make-locale LC_ALL "C")))))
(pass-if "string-locale-upcase Turkish"
(under-turkish-utf8-locale-or-unresolved
(lambda ()
(string=? "İI" (string-locale-upcase "iı" %turkish-utf8-locale)))))
(pass-if "string-locale-downcase Turkish"
(under-turkish-utf8-locale-or-unresolved
(lambda ()
(string=? "iı" (string-locale-downcase "İI" %turkish-utf8-locale))))))
(with-test-prefix "number parsing" (with-test-prefix "number parsing"