X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fstring.pure.lisp;h=82ccc94005964254065949625c4b1f9e0e5acd89;hb=b8f49ceae4a3b513de21f385bb784729d2ddff3f;hp=15e7afd1cee2f982b699bb787f9d051404571b3f;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/tests/string.pure.lisp b/tests/string.pure.lisp index 15e7afd..82ccc94 100644 --- a/tests/string.pure.lisp +++ b/tests/string.pure.lisp @@ -87,3 +87,35 @@ :start1 a)) 9) 9)) + +;; String trimming. + +(flet ((make-test (string left right both) + (macrolet ((check (fun wanted) + `(let ((result (,fun " " string))) + (assert (equal result ,wanted)) + (when (equal string ,wanted) + ;; Check that the original string is + ;; returned when no changes are needed. Not + ;; required by the spec, but a desireable + ;; feature for performance. + (assert (eql result string)))))) + ;; Check the functional implementations + (locally + (declare (notinline string-left-trim string-right-trim + string-trim)) + (check string-left-trim left) + (check string-right-trim right) + (check string-trim both)) + ;; Check the transforms + (locally + (declare (type simple-string string)) + (check string-left-trim left) + (check string-right-trim right) + (check string-trim both))))) + (make-test "x " "x " "x" "x") + (make-test " x" "x" " x" "x") + (make-test " x " "x " " x" "x") + (make-test " x x " "x x " " x x" "x x")) + +