Commit c5834c10 authored by pfdietz's avatar pfdietz

Fixed problem string-capitalize.2; added tests for nstring-upcase,...

Fixed problem string-capitalize.2; added tests for nstring-upcase, nstring-downcase, and nstring-capitalize.
parent 88af92bd
......@@ -118,3 +118,6 @@
(load "string-upcase.lsp")
(load "string-downcase.lsp")
(load "string-capitalize.lsp")
(load "nstring-upcase.lsp")
(load "nstring-downcase.lsp")
(load "nstring-capitalize.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 3 21:38:49 2002
;;;; Contains: Tests for NSTRING-CAPITALIZE
(in-package :cl-test)
(deftest nstring-capitalize.1
(let* ((s (copy-seq "abCd"))
(s2 (nstring-capitalize s)))
(values (eq s s2) s))
t "Abcd")
(deftest nstring-capitalize.2
(let* ((s (copy-seq "0adA2Cdd3wXy"))
(s2 (nstring-capitalize s)))
(values (eq s s2) s))
t "0ada2cdd3wxy")
(deftest nstring-capitalize.3
(let* ((s (copy-seq "1a"))
(s2 (nstring-capitalize s)))
(values (eq s s2) s))
t "1a")
(deftest nstring-capitalize.4
(let* ((s (copy-seq "a1a"))
(s2 (nstring-capitalize s)))
(values (eq s s2) s))
t "A1a")
(deftest nstring-capitalize.7
(let ((s "ABCDEF"))
(loop for i from 0 to 5
collect (nstring-capitalize (copy-seq s) :start i)))
("Abcdef" "ABcdef" "ABCdef" "ABCDef" "ABCDEf" "ABCDEF"))
(deftest nstring-capitalize.8
(let ((s "ABCDEF"))
(loop for i from 0 to 5
collect (nstring-capitalize (copy-seq s) :start i :end nil)))
("Abcdef" "ABcdef" "ABCdef" "ABCDef" "ABCDEf" "ABCDEF"))
(deftest nstring-capitalize.9
(let ((s "ABCDEF"))
(loop for i from 0 to 6
collect (nstring-capitalize (copy-seq s) :end i)))
("ABCDEF" "ABCDEF" "AbCDEF" "AbcDEF" "AbcdEF" "AbcdeF" "Abcdef"))
(deftest nstring-capitalize.10
(let ((s "ABCDEF"))
(loop for i from 0 to 5
collect (loop for j from i to 6
collect (nstring-capitalize (copy-seq s)
:start i :end j))))
(("ABCDEF" "ABCDEF" "AbCDEF" "AbcDEF" "AbcdEF" "AbcdeF" "Abcdef")
("ABCDEF" "ABCDEF" "ABcDEF" "ABcdEF" "ABcdeF" "ABcdef")
("ABCDEF" "ABCDEF" "ABCdEF" "ABCdeF" "ABCdef")
("ABCDEF" "ABCDEF" "ABCDeF" "ABCDef")
("ABCDEF" "ABCDEF" "ABCDEf")
("ABCDEF" "ABCDEF")))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 3 21:33:16 2002
;;;; Contains: Tests for NSTRING-DOWNCASE
(in-package :cl-test)
(deftest nstring-downcase.1
(let* ((s (copy-seq "A"))
(s2 (nstring-downcase s)))
(values (eq s s2) s))
t "a")
(deftest nstring-downcase.2
(let* ((s (copy-seq "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
(s2 (nstring-downcase s)))
(values (eq s s2) s))
t
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
(deftest nstring-downcase.3
(let* ((s (copy-seq "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ "))
(s2 (nstring-downcase s)))
(values (eq s s2) s))
t
"0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ ")
(deftest nstring-downcase.6
(let* ((s (make-array 6 :element-type 'character
:initial-contents '(#\A #\B #\C #\D #\E #\F)))
(s2 (nstring-downcase s)))
(values (eq s s2) s))
t "abcdef")
(deftest nstring-downcase.7
(let* ((s (make-array 6 :element-type 'standard-char
:initial-contents '(#\A #\B #\7 #\D #\E #\F)))
(s2 (nstring-downcase s)))
(values (eq s s2) s))
t
"ab7def")
;; Tests with :start, :end
(deftest nstring-downcase.8
(let ((s "ABCDEF"))
(loop for i from 0 to 6
collect (nstring-downcase (copy-seq s) :start i)))
("abcdef" "Abcdef" "ABcdef" "ABCdef" "ABCDef" "ABCDEf" "ABCDEF"))
(deftest nstring-downcase.9
(let ((s "ABCDEF"))
(loop for i from 0 to 6
collect (nstring-downcase (copy-seq s) :start i :end nil)))
("abcdef" "Abcdef" "ABcdef" "ABCdef" "ABCDef" "ABCDEf" "ABCDEF"))
(deftest nstring-downcase.10
(let ((s "ABCDE"))
(loop for i from 0 to 4
collect (loop for j from i to 5
collect (string-invertcase
(nstring-downcase (copy-seq s)
:start i :end j)))))
(("abcde" "Abcde" "ABcde" "ABCde" "ABCDe" "ABCDE")
("abcde" "aBcde" "aBCde" "aBCDe" "aBCDE")
("abcde" "abCde" "abCDe" "abCDE")
("abcde" "abcDe" "abcDE")
("abcde" "abcdE")))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 3 21:12:40 2002
;;;; Contains: Tests for NSTRING-UPCASE
(in-package :cl-test)
(deftest nstring-upcase.1
(let* ((s (copy-seq "a"))
(s2 (nstring-upcase s)))
(values (eq s s2) s))
t "A")
(deftest nstring-upcase.2
(let* ((s (copy-seq "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
(s2 (nstring-upcase s)))
(values (eq s s2) s))
t
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")
(deftest nstring-upcase.3
(let* ((s (copy-seq "0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ "))
(s2 (nstring-upcase s)))
(values (eq s s2) s))
t
"0123456789!@#$%^&*()_-+=|\\{}[]:\";'<>?,./ ")
(deftest nstring-upcase.6
(let* ((s (make-array 6 :element-type 'character
:initial-contents '(#\a #\b #\c #\d #\e #\f)))
(s2 (nstring-upcase s)))
(values (eq s s2) s))
t "ABCDEF")
(deftest nstring-upcase.7
(let* ((s (make-array 6 :element-type 'standard-char
:initial-contents '(#\a #\b #\7 #\d #\e #\f)))
(s2 (nstring-upcase s)))
(values (eq s s2) s))
t "AB7DEF")
;; Tests with :start, :end
(deftest nstring-upcase.8
(let ((s "abcdef"))
(loop for i from 0 to 6
collect (nstring-upcase (copy-seq s) :start i)))
("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))
(deftest nstring-upcase.9
(let ((s "abcdef"))
(loop for i from 0 to 6
collect
(nstring-upcase (copy-seq s) :start i :end nil)))
("ABCDEF" "aBCDEF" "abCDEF" "abcDEF" "abcdEF" "abcdeF" "abcdef"))
(deftest nstring-upcase.10
(let ((s "abcde"))
(loop for i from 0 to 4
collect (loop for j from i to 5
collect (nstring-upcase (copy-seq s)
:start i :end j))))
(("abcde" "Abcde" "ABcde" "ABCde" "ABCDe" "ABCDE")
("abcde" "aBcde" "aBCde" "aBCDe" "aBCDE")
("abcde" "abCde" "abCDe" "abCDE")
("abcde" "abcDe" "abcDE")
("abcde" "abcdE")))
......@@ -15,8 +15,8 @@
(deftest string-capitalize.2
(let ((s "0adA2Cdd3wXy"))
(values (string-capitalize s) s))
"0adA2Cdd3wXy"
"0ada2cdd3wxy")
"0ada2cdd3wxy"
"0adA2Cdd3wXy")
(deftest string-capitalize.3
(let ((s "1a"))
......@@ -83,6 +83,3 @@
("ABCDEF" "ABCDEF" "ABCDEf")
("ABCDEF" "ABCDEF"))
"ABCDEF")
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