Commit 98e66fbb authored by pfdietz's avatar pfdietz

More specialized string tests, added TODO for checking slots of standardized errors.

parent bc136c62
......@@ -103,3 +103,5 @@ Got: 0
30. Add more pathname equality tests to equal.lsp
31. Add tests for GENTEMP
32. Check that the fields of standardized error conditions are set properly
......@@ -159,6 +159,19 @@
(copy-seq (make-array '(0) :element-type nil))
"")
;;; Specialized string tests
(deftest copy-seq.20
(do-special-strings
(s "abcde" nil)
(let ((s2 (copy-seq s)))
(assert (typep s2 'simple-array))
(assert (string= s s2))
(assert (equal (array-element-type s) (array-element-type s2)))))
nil)
;;; Order of evaluation test
(deftest copy-seq.order.1
(let ((i 0))
(values (copy-seq (progn (incf i) "abc")) i))
......
......@@ -418,6 +418,12 @@
(count-if-not #'%onep a :from-end t)))))
2 3 2 3)
(deftest count-if-not-string.18
(do-special-strings
(s "a1ha^%&%#( 873ff83nfa!" nil)
(assert (= (count-if-not #'alpha-char-p s) 14)))
nil)
;;; Argument order tests
(deftest count-if-not.order.1
......
......@@ -417,6 +417,12 @@
(count-if #'digit-char-p s :start 1 :end 2)))
3 3 2 2 1)
(deftest count-if-string.18
(do-special-strings
(s "1abC3!?deZ" nil)
(assert (= (count-if #'alpha-char-p s) 6)))
nil)
;;; Argument order tests
(deftest count-if.order.1
......
......@@ -535,6 +535,12 @@
(count #\1 "00001100100" :test-not #'char>)
3)
(deftest count-string.23
(do-special-strings
(s "a1a3abcda" nil)
(assert (= (count #\a s) 4)))
nil)
(defharmless count-string.test-and-test-not.1
(count #\0 "0011010101100010000" :test #'eql :test-not #'eql))
......
......@@ -369,6 +369,18 @@
type-error)
t)
;;; Specialized strings
(deftest elt.special-strings.1
(do-special-strings
(s "abcde" nil)
(assert (char= (elt s 0) #\a))
(assert (char= (elt s 3) #\d))
(assert (char= (elt s 4) #\e)))
nil)
;;; Error tests
(deftest elt.error.1
(signals-error (elt) program-error)
t)
......
......@@ -534,3 +534,37 @@
:start (progn (setf w (incf i)) 0))
i x y z p q r s w))
#(a z z a) 8 1 2 3 4 5 6 7 8)
;;; Specialized strings
(deftest fill.specialized-strings.1
(do-special-strings
(s (copy-seq "abcde") nil)
(assert (string= s "abcde"))
(assert (eq s (fill s #\x)))
(assert (string= s "xxxxx")))
nil)
(deftest fill.specialized-strings.2
(do-special-strings
(s (copy-seq "abcde") nil)
(assert (string= s "abcde"))
(assert (eq s (fill s #\x :start 2)))
(assert (string= s "abxxx")))
nil)
(deftest fill.specialized-strings.3
(do-special-strings
(s (copy-seq "abcde") nil)
(assert (string= s "abcde"))
(assert (eq s (fill s #\x :end 3)))
(assert (string= s "xxxde")))
nil)
(deftest fill.specialized-strings.4
(do-special-strings
(s (copy-seq "abcde") nil)
(assert (string= s "abcde"))
(assert (eq s (fill s #\x :start 1 :end 4)))
(assert (string= s "axxxe")))
nil)
No preview for this file type
......@@ -19,14 +19,12 @@
(load "find-if.lsp")
(load "find-if-not.lsp")
(load "position.lsp")
(compile-and-load "search-aux.lsp")
(load "search-list.lsp")
(load "search-vector.lsp")
(load "search-bitvector.lsp")
(load "search-string.lsp")
(load "mismatch.lsp")
(load "replace.lsp")
(compile-and-load "subseq-aux.lsp")
(load "subseq.lsp")
(load "substitute.lsp")
(load "substitute-if.lsp")
......@@ -36,7 +34,5 @@
(load "nsubstitute-if-not.lsp")
(load "concatenate.lsp")
(load "merge.lsp")
(compile-and-load "remove-aux.lsp")
(load "remove.lsp") ;; also related funs
(compile-and-load "remove-duplicates-aux.lsp")
(load "remove-duplicates.lsp") ;; also delete-duplicates
......@@ -286,3 +286,5 @@
:foo (setf e (incf i)))
i a b c d e))
(a a a a a) 5 1 2 3 4 5)
;;; FIXME: Add tests for upgrading of character subtypes
......@@ -267,6 +267,23 @@
6
"abcdef")
(deftest map-into-string.13
(do-special-strings
(s (copy-seq "12345") nil)
(let ((s2 (map-into s #'identity "abcde")))
(assert (eq s s2))
(assert (string= s2 "abcde"))))
nil)
(deftest map-into-string.14
(do-special-strings
(s "abcde" nil)
(let* ((s1 (copy-seq "123456"))
(s2 (map-into s1 #'identity s)))
(assert (eq s1 s2))
(assert (string= s2 "abcde6"))))
nil)
;;; Tests on bit vectors
(deftest map-into.bit-vector.1
......@@ -356,7 +373,7 @@
;;; the 'should be prepared' notation for the error checking
;;; means that error checking may be skipped.
(deftest map-into.error.2
(and (locally (declare (safety 3))
(and (locally (declare (optimize (safety 3)))
(handler-case (eval '(map-into nil #'identity 'a))
(type-error () nil)))
:bad)
......
......@@ -245,6 +245,30 @@
(map 'list #'(lambda (x y) x) '(1 2 3 4 5 6 7 8 9 10) s1))
(1 2 3 4 5 6 7 8))
;;; Specialized string tests
(deftest map.specialized-string.1
(do-special-strings
(s "abcde" nil)
(let ((s2 (map 'list #'identity s)))
(assert (equal s2 '(#\a #\b #\c #\d #\e)))))
nil)
(deftest map.specialized-string.2
(do-special-strings
(s "abcde" nil)
(let ((s2 (map 'list #'(lambda (x y) y) '(1 2 3 4 5) s)))
(assert (equal s2 '(#\a #\b #\c #\d #\e)))))
nil)
(deftest map.specialized-string.3
(let ((s (map 'base-string #'identity '(#\a #\b #\c))))
(assert (typep s 'base-string))
s)
"abc")
;;; FIXME: Add tests for building strings of other character types
;;; Order of evaluation tests
(deftest map.order.1
......
......@@ -86,6 +86,15 @@
y)
"edcba")
(deftest nreverse-string.5
(do-special-strings
(s (copy-seq "12345") nil)
(let ((s2 (nreverse s)))
(assert (stringp s2))
(assert (string= s2 "54321"))
(assert (equal (array-element-type s) (array-element-type s2)))))
nil)
(deftest nreverse.order.1
(let ((i 0))
(values
......
......@@ -299,6 +299,27 @@
'string))
"dcba")
(deftest reduce-string.18
(do-special-strings
(s "12345" nil)
(let ((x (reduce #'(lambda (x y) (cons y x)) s)))
(assert (equal x '(#\5 #\4 #\3 #\2 . #\1)))))
nil)
(deftest reduce-string.19
(do-special-strings
(s "54321" nil)
(let ((x (reduce #'cons s :from-end t)))
(assert (equal x '(#\5 #\4 #\3 #\2 . #\1)))))
nil)
(deftest reduce-string.20
(do-special-strings
(s "12345" nil)
(let ((x (reduce #'(lambda (x y) (cons y x)) s :initial-value nil)))
(assert (equal x '(#\5 #\4 #\3 #\2 #\1)))))
nil)
;;;;;;;;
(deftest reduce-bitstring.1
......
......@@ -5,6 +5,8 @@
(in-package :cl-test)
(compile-and-load "remove-duplicates-aux.lsp")
(deftest random-remove-duplicates
(loop for i from 1 to 5000
always (random-test-remove-dups 20))
......
......@@ -89,6 +89,18 @@
y)
"edcba")
;;; Specialized string tests
(deftest reverse-string.5
(do-special-strings
(s (copy-seq "12345") nil)
(let ((s2 (reverse s)))
(assert (typep s2 'simple-array))
(assert (equal (array-element-type s) (array-element-type s2)))
(assert (string= "12345" s))
(assert (string= "54321" s2))))
nil)
(deftest reverse.order.1
(let ((i 0))
(values
......
......@@ -112,6 +112,14 @@
(sort a #'char<))
"00111")
(deftest sort-string.4
(do-special-strings
(s "aebdc" nil)
(let ((s2 (sort s #'char<)))
(assert (eq s s2))
(assert (string= s2 "abcde"))))
nil)
;;; Order of evaluation tests
(deftest sort.order.1
......
......@@ -91,6 +91,14 @@
(stable-sort a #'char<))
"00111")
(deftest stable-sort-string.4
(do-special-strings
(s "aebdc" nil)
(let ((s2 (stable-sort s #'char<)))
(assert (eq s s2))
(assert (string= s2 "abcde"))))
nil)
;;; Order of evaluation tests
(deftest stable-sort.order.1
......
......@@ -5,6 +5,8 @@
(in-package :cl-test)
(compile-and-load "subseq-aux.lsp")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; subseq, on lists
......@@ -160,6 +162,23 @@
(subseq-string.3-body)
t)
;;; Specialized string tests
(deftest subseq.specialized-string.1
(let* ((s0 "abcde")
(len (length s0)))
(do-special-strings
(s "abcde" nil)
(loop for i from 0 below len
for s1 = (subseq s i)
do (assert (typep s1 'simple-array))
do (assert (string= (subseq s i) (subseq s0 i)))
do (loop for j from i to len
for s2 = (subseq s i j)
do (assert (typep s2 'simple-array))
(assert (string= s2 (subseq s0 i j)))))))
nil)
;;; Tests on bit vectors
(deftest subseq-bit-vector.1
......
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