X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fstring.pure.lisp;h=5d7fd11480ecbac7ff53f7845e657f0997517a58;hb=a18f0a95bc9a457e4d2d00c702b746f29c2662b1;hp=c44ffb37bfabda2a0a8ecbbbf5073940155128db;hpb=f35f00839f0966ec7e0064603a9c82aa042ecb5a;p=sbcl.git diff --git a/tests/string.pure.lisp b/tests/string.pure.lisp index c44ffb3..5d7fd11 100644 --- a/tests/string.pure.lisp +++ b/tests/string.pure.lisp @@ -13,6 +13,7 @@ (in-package "CL-USER") +;;; basic non-destructive case operations (assert (string= (string-upcase "This is a test.") "THIS IS A TEST.")) (assert (string= (string-downcase "This is a test.") "this is a test.")) (assert (string= (string-capitalize "This is a test.") "This Is A Test.")) @@ -23,3 +24,24 @@ "Is this 900-sex-hott, please?")) (assert (string= (string-capitalize "Is this 900-Sex-hott, please?") "Is This 900-Sex-Hott, Please?")) + +;;; The non-destructive case operations accept string designators, not +;;; just strings. +(assert (string= (string-upcase '|String designator|) "STRING DESIGNATOR")) +(assert (string= (string-downcase #\S) "s")) +(assert (string= (string-downcase #\.) ".")) +(assert (string= (string-capitalize 'ya-str-desig :end 5) "Ya-StR-DESIG")) + +;;; basic destructive case operations +(let ((nstring (make-array 5 :element-type 'character :fill-pointer 0))) + (vector-push-extend #\c nstring) + (vector-push-extend #\a nstring) + (vector-push-extend #\t nstring) + (nstring-upcase nstring) + (assert (string= nstring "CAT")) + (setf (fill-pointer nstring) 2) + (nstring-downcase nstring :start 1) + (setf (fill-pointer nstring) 3) + (assert (string= nstring "CaT")) + (nstring-capitalize nstring) + (assert (string= nstring "Cat")))