![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-316-support-roundtrip-char-casing at cmucl / cmucl Commits: 1e72a851 by Raymond Toy at 2024-05-16T15:27:44-07:00 Add string casing tests Add a couple of simple tests to check that string-upcase/downcase produces the same results as if we did char-upcase/downcase on each character individually. We only do a few characters. (Should we do more?) - - - - - 1 changed file: - + tests/string.lisp Changes: ===================================== tests/string.lisp ===================================== @@ -0,0 +1,41 @@ +;; Tests of string functions + +(defpackage :string-tests + (:use :cl :lisp-unit)) + +(in-package "STRING-TESTS") + +(define-test string-upcase + (:tag :issues) + (let ((s (coerce (mapcar #'code-char + ;; Some special characters for testing. + ;; Micro_Sign shouldn't upcase. #x1c5 and + ;; #x1c8 have a unicode category of Lt so + ;; they shouldn't upcase either. + '(#xb5 #x1c5 #x1c8)) + 'string))) + ;; Verify that string-upcase returns the same characters as if we + ;; did char-upcase on each one. (This only works if we don't have + ;; surrogate characters in the string!) + (assert-equal (map 'list #'(lambda (c) + (char-name (char-upcase c))) + s) + (map 'list #'char-name + (string-upcase s))))) + +(define-test string-downcase + (:tag :issues) + (let ((s (coerce (mapcar #'code-char + ;; Some special characters for testing. + ;; Micro_Sign shouldn't upcase. #x1c5 and + ;; #x1c8 have a unicode category of Lt so + ;; they shouldn't upcase either. + '(#xb5 #x1c5 #x1c8)) + 'string))) + ;; Verify that string-downcase returns the same characters as if we + ;; did char-downcase on each one. (This only works if we don't have + ;; surrogate characters in the string!) + (assert-equal (map 'list #'(lambda (c) + (char-name (char-downcase c))) + s) + (map 'list #'char-name (string-downcase s))))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/1e72a851ecfc3dfed349d809... -- This project does not include diff previews in email notifications. View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/1e72a851ecfc3dfed349d809... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)