Commit 06034e3a authored by pfdietz's avatar pfdietz

Added more specialized string tests to (n)string-upcase/downcase/capitalize

parent 21f73df6
......@@ -69,6 +69,50 @@
(nstring-capitalize (make-array '(0) :element-type nil))
"")
(deftest nstring-capitalize.13
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list (copy-seq s)
(copy-seq (nstring-capitalize s))
(copy-seq s)
(progn (setf (fill-pointer s) 10) (copy-seq s))
))
(("aB0cD" "Ab0cd" "Ab0cd" "Ab0cdefGHi")
("aB0cD" "Ab0cd" "Ab0cd" "Ab0cdefGHi")
("aB0cD" "Ab0cd" "Ab0cd" "Ab0cdefGHi")))
(deftest nstring-capitalize.14
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list (copy-seq s)
(nstring-capitalize s)
(copy-seq s)
s0))
(("aB0cD" "Ab0cd" "Ab0cd" "zZAb0cdefG")
("aB0cD" "Ab0cd" "Ab0cd" "zZAb0cdefG")
("aB0cD" "Ab0cd" "Ab0cd" "zZAb0cdefG")))
(deftest nstring-capitalize.15
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list (copy-seq s)
(nstring-capitalize s)
(copy-seq s)))
(("aB0cD" "Ab0cd" "Ab0cd")
("aB0cD" "Ab0cd" "Ab0cd")
("aB0cD" "Ab0cd" "Ab0cd")))
;;; Order of evaluation tests
(deftest nstring-capitalize.order.1
(let ((i 0) a b c (s (copy-seq "abcdef")))
(values
......
......@@ -72,6 +72,49 @@
(nstring-downcase (make-array '(0) :element-type nil))
"")
(deftest nstring-downcase.12
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list (copy-seq s)
(copy-seq (nstring-downcase s))
(copy-seq s)
(progn (setf (fill-pointer s) 10) (copy-seq s))
))
(("aB0cD" "ab0cd" "ab0cd" "ab0cdefGHi")
("aB0cD" "ab0cd" "ab0cd" "ab0cdefGHi")
("aB0cD" "ab0cd" "ab0cd" "ab0cdefGHi")))
(deftest nstring-downcase.13
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list (copy-seq s)
(nstring-downcase s)
(copy-seq s)
s0))
(("aB0cD" "ab0cd" "ab0cd" "zZab0cdefG")
("aB0cD" "ab0cd" "ab0cd" "zZab0cdefG")
("aB0cD" "ab0cd" "ab0cd" "zZab0cdefG")))
(deftest nstring-downcase.14
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list (copy-seq s)
(nstring-downcase s)
(copy-seq s)))
(("aB0cD" "ab0cd" "ab0cd")
("aB0cD" "ab0cd" "ab0cd")
("aB0cD" "ab0cd" "ab0cd")))
;;; Order of evaluation tests
(deftest nstring-downcase.order.1
(let ((i 0) a b c (s (copy-seq "ABCDEF")))
(values
......
......@@ -71,6 +71,49 @@
(nstring-upcase (make-array '(0) :element-type nil))
"")
(deftest nstring-upcase.12
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list (copy-seq s)
(copy-seq (nstring-upcase s))
(copy-seq s)
(progn (setf (fill-pointer s) 10) (copy-seq s))
))
(("aB0cD" "AB0CD" "AB0CD" "AB0CDefGHi")
("aB0cD" "AB0CD" "AB0CD" "AB0CDefGHi")
("aB0cD" "AB0CD" "AB0CD" "AB0CDefGHi")))
(deftest nstring-upcase.13
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list (copy-seq s)
(nstring-upcase s)
(copy-seq s)
s0))
(("aB0cD" "AB0CD" "AB0CD" "zZAB0CDefG")
("aB0cD" "AB0CD" "AB0CD" "zZAB0CDefG")
("aB0cD" "AB0CD" "AB0CD" "zZAB0CDefG")))
(deftest nstring-upcase.14
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list (copy-seq s)
(nstring-upcase s)
(copy-seq s)))
(("aB0cD" "AB0CD" "AB0CD")
("aB0cD" "AB0CD" "AB0CD")
("aB0cD" "AB0CD" "AB0CD")))
;;; Order of evaluation tests
(deftest nstring-upcase.order.1
(let ((i 0) a b c (s (copy-seq "abcdef")))
(values
......
......@@ -89,6 +89,35 @@
(string-capitalize (make-array '(0) :element-type nil))
"")
(deftest string-capitalize.12
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list s (string-capitalize s)))
(("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd")))
(deftest string-capitalize.13
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list s (string-capitalize s)))
(("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd")))
(deftest string-capitalize.14
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list s (string-capitalize s)))
(("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd") ("aB0cD" "Ab0cd")))
;;; Order of evaluation tests
(deftest string-capitalize.order.1
(let ((i 0) a b c (s (copy-seq "abcdef")))
(values
......
......@@ -85,6 +85,35 @@
(string-downcase (make-array '(0) :element-type nil))
"")
(deftest string-downcase.12
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list s (string-downcase s)))
(("aB0cD" "ab0cd") ("aB0cD" "ab0cd") ("aB0cD" "ab0cd")))
(deftest string-downcase.13
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list s (string-downcase s)))
(("aB0cD" "ab0cd") ("aB0cD" "ab0cd") ("aB0cD" "ab0cd")))
(deftest string-downcase.14
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list s (string-downcase s)))
(("aB0cD" "ab0cd") ("aB0cD" "ab0cd") ("aB0cD" "ab0cd")))
;;; Order of evaluation tests
(deftest string-downcase.order.1
(let ((i 0) a b c (s (copy-seq "ABCDEF")))
(values
......
......@@ -85,6 +85,35 @@
(string-upcase (make-array '(0) :element-type nil))
"")
(deftest string-upcase.12
(loop for type in '(standard-char base-char character)
for s = (make-array '(10) :element-type type
:fill-pointer 5
:initial-contents "aB0cDefGHi")
collect (list s (string-upcase s)))
(("aB0cD" "AB0CD") ("aB0cD" "AB0CD") ("aB0cD" "AB0CD")))
(deftest string-upcase.13
(loop for type in '(standard-char base-char character)
for s0 = (make-array '(10) :element-type type
:initial-contents "zZaB0cDefG")
for s = (make-array '(5) :element-type type
:displaced-to s0
:displaced-index-offset 2)
collect (list s (string-upcase s)))
(("aB0cD" "AB0CD") ("aB0cD" "AB0CD") ("aB0cD" "AB0CD")))
(deftest string-upcase.14
(loop for type in '(standard-char base-char character)
for s = (make-array '(5) :element-type type
:adjustable t
:initial-contents "aB0cD")
collect (list s (string-upcase s)))
(("aB0cD" "AB0CD") ("aB0cD" "AB0CD") ("aB0cD" "AB0CD")))
;;; Order of evaluation tests
(deftest string-upcase.order.1
(let ((i 0) a b c (s (copy-seq "abcdef")))
(values
......@@ -104,9 +133,8 @@
:start (progn (setf c (incf i)) 1))
i a b c))
"aBCDef" 3 1 2 3)
;;; Error cases
;;; Error tests
(deftest string-upcase.error.1
(signals-error (string-upcase) program-error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment