|
1
|
+;; Tests of string functions
|
|
2
|
+
|
|
3
|
+(defpackage :string-tests
|
|
4
|
+ (:use :cl :lisp-unit))
|
|
5
|
+
|
|
6
|
+(in-package "STRING-TESTS")
|
|
7
|
+
|
|
8
|
+(define-test string-upcase
|
|
9
|
+ (:tag :issues)
|
|
10
|
+ (let ((s (coerce (mapcar #'code-char
|
|
11
|
+ ;; Some special characters for testing.
|
|
12
|
+ ;; Micro_Sign shouldn't upcase. #x1c5 and
|
|
13
|
+ ;; #x1c8 have a unicode category of Lt so
|
|
14
|
+ ;; they shouldn't upcase either.
|
|
15
|
+ '(#xb5 #x1c5 #x1c8))
|
|
16
|
+ 'string)))
|
|
17
|
+ ;; Verify that string-upcase returns the same characters as if we
|
|
18
|
+ ;; did char-upcase on each one. (This only works if we don't have
|
|
19
|
+ ;; surrogate characters in the string!)
|
|
20
|
+ (assert-equal (map 'list #'(lambda (c)
|
|
21
|
+ (char-name (char-upcase c)))
|
|
22
|
+ s)
|
|
23
|
+ (map 'list #'char-name
|
|
24
|
+ (string-upcase s)))))
|
|
25
|
+
|
|
26
|
+(define-test string-downcase
|
|
27
|
+ (:tag :issues)
|
|
28
|
+ (let ((s (coerce (mapcar #'code-char
|
|
29
|
+ ;; Some special characters for testing.
|
|
30
|
+ ;; Micro_Sign shouldn't upcase. #x1c5 and
|
|
31
|
+ ;; #x1c8 have a unicode category of Lt so
|
|
32
|
+ ;; they shouldn't upcase either.
|
|
33
|
+ '(#xb5 #x1c5 #x1c8))
|
|
34
|
+ 'string)))
|
|
35
|
+ ;; Verify that string-downcase returns the same characters as if we
|
|
36
|
+ ;; did char-downcase on each one. (This only works if we don't have
|
|
37
|
+ ;; surrogate characters in the string!)
|
|
38
|
+ (assert-equal (map 'list #'(lambda (c)
|
|
39
|
+ (char-name (char-downcase c)))
|
|
40
|
+ s)
|
|
41
|
+ (map 'list #'char-name (string-downcase s))))) |