1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Tests for display and writing of characters

* test-suite/tests/encoding-iso88591.test: tests for writing and display
  of characters

* test-suite/tests/encoding-iso88597.test: tests for writing and display
  of characters

* test-suite/tests/encoding-utf8.test: tests for writing and display
  of characters
This commit is contained in:
Michael Gran 2009-08-30 16:51:30 -07:00
parent 5f5920e012
commit bda0d85f0c
3 changed files with 202 additions and 0 deletions

View file

@ -33,6 +33,67 @@
(if (defined? 'setlocale)
(set! oldlocale (setlocale LC_ALL "")))
(define ascii-a (integer->char 65)) ; LATIN CAPITAL LETTER A
(define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
(define alpha (integer->char #x03b1)) ; GREEK SMALL LETTER ALPHA
(define cherokee-a (integer->char #x13a0)) ; CHEROKEE LETTER A
(with-test-prefix "characters"
(pass-if "input A"
(char=? ascii-a #\A))
(pass-if "input A acute"
(char=? a-acute #\Á))
(pass-if "display A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(display ascii-a pt)
(string=? "A"
(get-output-string pt))))
(pass-if "display A acute"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(display a-acute pt)
(string=? "Á"
(get-output-string pt))))
(pass-if "display alpha"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(display alpha pt)
(string-ci=? "\\u03b1"
(get-output-string pt))))
(pass-if "display Cherokee a"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(display cherokee-a pt)
(string-ci=? "\\u13a0"
(get-output-string pt))))
(pass-if "write A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(write ascii-a pt)
(string=? "#\\A"
(get-output-string pt))))
(pass-if "write A acute"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'escape)
(write a-acute pt)
(string=? "#\\Á"
(get-output-string pt)))))
(define s1 "última")
(define s2 "cédula")
(define s3 "años")

View file

@ -31,6 +31,65 @@
(define oldlocale #f)
(if (defined? 'setlocale)
(set! oldlocale (setlocale LC_ALL "")))
(define ascii-a (integer->char 65)) ; LATIN CAPITAL LETTER A
(define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
(define alpha (integer->char #x03b1)) ; GREEK SMALL LETTER ALPHA
(define cherokee-a (integer->char #x13a0)) ; CHEROKEE LETTER A
(with-test-prefix "characters"
(pass-if "input A"
(char=? ascii-a #\A))
(pass-if "input alpha"
(char=? alpha #\á))
(pass-if "display A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(display ascii-a pt)
(string=? "A"
(get-output-string pt))))
(pass-if "display A acute"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(display a-acute pt)
(string-ci=? "\\xc1"
(get-output-string pt))))
(pass-if "display alpha"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(display alpha pt)
(string-ci=? "á"
(get-output-string pt))))
(pass-if "display Cherokee A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(display cherokee-a pt)
(string-ci=? "\\u13a0"
(get-output-string pt))))
(pass-if "write A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(write ascii-a pt)
(string=? "#\\A"
(get-output-string pt))))
(pass-if "write alpha"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'escape)
(write alpha pt)
(string=? "#\\á"
(get-output-string pt)))))
(define s1 "Ðåñß")
(define s2 "ôçò")

View file

@ -32,6 +32,88 @@
(if (defined? 'setlocale)
(set! oldlocale (setlocale LC_ALL "")))
(define ascii-a (integer->char 65)) ; LATIN CAPITAL LETTER A
(define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE
(define alpha (integer->char #x03b1)) ; GREEK SMALL LETTER ALPHA
(define cherokee-a (integer->char #x13a0)) ; CHEROKEE LETTER A
(with-test-prefix "characters"
(pass-if "input A"
(char=? ascii-a #\A))
(pass-if "input A acute"
(char=? a-acute #\Á))
(pass-if "input alpha"
(char=? alpha #\α))
(pass-if "input Cherokee A"
(char=? cherokee-a #\))
(pass-if "display A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'substitute)
(display ascii-a pt)
(string=? "A"
(get-output-string pt))))
(pass-if "display A acute"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'substitute)
(display a-acute pt)
(string=? "Á"
(get-output-string pt))))
(pass-if "display alpha"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'substitute)
(display alpha pt)
(string-ci=? "α"
(get-output-string pt))))
(pass-if "display Cherokee A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'substitute)
(display cherokee-a pt)
(string-ci=? ""
(get-output-string pt))))
(pass-if "write A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'escape)
(write ascii-a pt)
(string=? "#\\A"
(get-output-string pt))))
(pass-if "write A acute"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'escape)
(write a-acute pt)
(string=? "#\\Á"
(get-output-string pt))))
(pass-if "write alpha"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'escape)
(write alpha pt)
(string=? "#\\α"
(get-output-string pt))))
(pass-if "write Cherokee A"
(let ((pt (open-output-string)))
(set-port-encoding! pt "UTF-8")
(set-port-conversion-strategy! pt 'escape)
(write cherokee-a pt)
(string=? "#\\"
(get-output-string pt)))))
(define s1 "última")
(define s2 "cédula")
(define s3 "años")