From bcccf04158bda5319776d45abd6cc748b794096b Mon Sep 17 00:00:00 2001 From: Michael Gran Date: Thu, 24 Sep 2009 08:10:03 -0700 Subject: [PATCH] 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. --- test-suite/tests/i18n.test | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test-suite/tests/i18n.test b/test-suite/tests/i18n.test index 6bfdbc78f..4f11a8a90 100644 --- a/test-suite/tests/i18n.test +++ b/test-suite/tests/i18n.test @@ -85,6 +85,9 @@ (define %french-utf8-locale-name "fr_FR.UTF-8") +(define %turkish-utf8-locale-name + "tr_TR.UTF-8") + (define %french-locale (false-if-exception (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) %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) ;; 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 @@ -113,6 +121,8 @@ (define (under-french-utf8-locale-or-unresolved 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)" @@ -190,7 +200,38 @@ (pass-if "char-locale-upcase" (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"