Raymond Toy pushed to branch issue-316-support-roundtrip-char-casing at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • tests/string.lisp
    ... ... @@ -5,37 +5,33 @@
    5 5
     
    
    6 6
     (in-package "STRING-TESTS")
    
    7 7
     
    
    8
    +(defun make-test-string ()
    
    9
    +  ;; Create a string consisting of all the code units EXCEPT for the
    
    10
    +  ;; surrogates because string casing handles that differently.
    
    11
    +  (coerce
    
    12
    +   (loop for code from 0 to #xffff
    
    13
    +         unless (lisp::surrogatep code)
    
    14
    +         collect (code-char code))
    
    15
    +   'string))
    
    16
    +
    
    8 17
     (define-test string-upcase
    
    9 18
         (: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)))))
    
    19
    +  (let* ((s (make-test-string))
    
    20
    +         (s-upcase (string-upcase s)))
    
    21
    +    (assert-false
    
    22
    +     (loop for expected across s
    
    23
    +           and actual across s-upcase
    
    24
    +           when (char/= actual (char-upcase expected))
    
    25
    +             collect (list (char-upcase (char-code expected))
    
    26
    +                           (char-code actual))))))
    
    25 27
     
    
    26 28
     (define-test string-downcase
    
    27 29
         (: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)))))
    30
    +  (let* ((s (make-test-string))
    
    31
    +         (s-downcase (string-downcase s)))
    
    32
    +    (assert-false
    
    33
    +     (loop for expected across s
    
    34
    +           and actual across s-downcase
    
    35
    +           when (char/= actual (char-downcase expected))
    
    36
    +             collect (list (char-downcase (char-code expected))
    
    37
    +                           (char-code actual))))))