Commit | Line | Data |
---|---|---|
889975e5 MG |
1 | ;;;; strings.test --- test suite for Guile's string functions -*- mode: scheme; coding: iso-8859-1 -*- |
2 | ;;;; | |
3 | ;;;; Copyright (C) 2009 Free Software Foundation, Inc. | |
4 | ;;;; | |
5 | ;;;; This program is free software; you can redistribute it and/or modify | |
6 | ;;;; it under the terms of the GNU General Public License as published by | |
7 | ;;;; the Free Software Foundation; either version 2, or (at your option) | |
8 | ;;;; any later version. | |
9 | ;;;; | |
10 | ;;;; This program is distributed in the hope that it will be useful, | |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;;;; GNU General Public License for more details. | |
14 | ;;;; | |
15 | ;;;; You should have received a copy of the GNU General Public License | |
16 | ;;;; along with this software; see the file COPYING. If not, write to | |
17 | ;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
18 | ;;;; Boston, MA 02110-1301 USA | |
19 | ||
20 | (define-module (test-strings) | |
21 | #:use-module (test-suite lib) | |
22 | #:use-module (srfi srfi-1)) | |
23 | ||
24 | (define exception:conversion | |
25 | (cons 'misc-error "^cannot convert to output locale")) | |
26 | ||
27 | ;; Create a string from integer char values, eg. (string-ints 65) => "A" | |
28 | (define (string-ints . args) | |
29 | (apply string (map integer->char args))) | |
30 | ||
ce3ed012 MG |
31 | ;; Set locale to the environment's locale, so that the prints look OK. |
32 | (define oldlocale #f) | |
33 | (if (defined? 'setlocale) | |
34 | (set! oldlocale (setlocale LC_ALL ""))) | |
889975e5 | 35 | |
bda0d85f MG |
36 | (define ascii-a (integer->char 65)) ; LATIN CAPITAL LETTER A |
37 | (define a-acute (integer->char #x00c1)) ; LATIN CAPITAL LETTER A WITH ACUTE | |
38 | (define alpha (integer->char #x03b1)) ; GREEK SMALL LETTER ALPHA | |
39 | (define cherokee-a (integer->char #x13a0)) ; CHEROKEE LETTER A | |
40 | ||
41 | (with-test-prefix "characters" | |
42 | (pass-if "input A" | |
43 | (char=? ascii-a #\A)) | |
44 | ||
45 | (pass-if "input A acute" | |
46 |