Commit 96fd5972 authored by pfdietz's avatar pfdietz

Many more specialized string tests, or at least comments indicating they're

needed.
parent 3de4efc6
......@@ -51,7 +51,20 @@
(probe-file pn))))
t (t) nil)
;;;
;;; Specialized string tests
(deftest delete-file.5
(do-special-strings
(pn "scratchfile.txt" nil)
(unless (probe-file pn)
(with-open-file (s pn :direction :output)
(format s "Contents~%")))
(assert (probe-file pn))
(assert (equal (multiple-value-list (delete-file pn)) '(t)))
(assert (not (probe-file pn))))
nil)
;;; Error tests
(deftest delete-file.error.1
(signals-error (delete-file) program-error)
......
......@@ -56,6 +56,16 @@
(if (< len 500) len nil))
nil)
;;; Specialized string tests
(deftest directory.9
(do-special-strings
(s "nonexistent" nil)
(assert (null (directory s))))
nil)
;;; Error tests
(deftest directory.error.1
(signals-error (directory) program-error)
t)
......@@ -106,7 +106,6 @@
verbosity))
2 t nil "")
;;; Case where directory shouldn't exist
;; The directort ansi-tests/scratch must not exist before this
......@@ -139,6 +138,17 @@
)))
2 t t t "")
;;; Specialized string tests
(deftest ensure-directories-exist.9
(do-special-strings
(str "ensure-directories-exist.lsp" nil)
(let* ((results (multiple-value-list (ensure-directories-exist str))))
(assert (eql (length results) 2))
(assert (equalt (truename (first results)) (truename str)))
(assert (null (second results)))))
nil)
;; FIXME
;; Need to add a LPN test
......
......@@ -52,6 +52,14 @@
author))
nil)
;;; Specialized string tests
(deftest file-author.7
(do-special-strings
(s "file-author.lsp" nil)
(assert (equal (file-author s) (file-author "file-author.lsp"))))
nil)
;;; FIXME
;;; Add LPN test
......
......@@ -33,6 +33,17 @@
(assert (= (+ pos1 len) pos2)))))))
nil)
(deftest file-string-length.3
(with-open-file
(stream "tmp.dat" :direction :output
:if-exists :supersede)
(let* ((s1 "abcde")
(n (file-string-length stream s1)))
(do-special-strings
(s2 s1 nil)
(assert (= (file-string-length stream s2) n)))))
nil)
;;; Error tests
(deftest file-string-length.error.1
......
......@@ -50,10 +50,20 @@
(length (multiple-value-list (file-write-date "file-write-date.lsp")))
1)
;;; Specialized string tests
(deftest file-write-date.6
(let* ((str "file-write-date.lsp")
(date (file-write-date str)))
(do-special-strings
(s str nil)
(assert (equal (file-write-date s) date))))
nil)
;;; FIXME
;;; Add LPN test
;;;
;;; Error tests
(deftest file-write-date.error.1
(signals-error (file-write-date) program-error)
......
......@@ -1233,4 +1233,6 @@
t t)
;;; FIXME -- add tests for :element-type :default
\ No newline at end of file
;;; FIXME -- add tests for :element-type :default
;;; FIXME -- add tests for filespec being a specialized string
......@@ -49,6 +49,23 @@
(not (pathname-match-p pn1 pn2))))
nil)
;;; Specialized string tests
(deftest pathname-match-p.7
(let ((wpn (parse-namestring "CLTEST:*.LSP")))
(assert (wild-pathname-p wpn))
(do-special-strings
(s "CLTEST:FOO.LSP" nil)
(assert (pathname-match-p s wpn))))
nil)
(deftest pathname-match-p.8
(do-special-strings
(s "CLTEST:*.LSP" nil)
(assert (pathname-match-p "CLTEST:FOO.LSP" s)))
nil)
;;; Add more tests here
;;; Here are error tests
......
......@@ -29,6 +29,18 @@
(probe-file "CLTEST:probe-file.lsp"))
t)
;;; Specialized string tests
(deftest probe-file.5
(do-special-strings
(str "probe-file.lsp" nil)
(let ((s (open str :direction :input)))
(assert (equalpt (truename #p"probe-file.lsp") (probe-file s)))
(close s)))
nil)
;;; Error tests
(deftest probe-file.error.1
(signals-error (probe-file) program-error)
t)
......
......@@ -131,7 +131,65 @@
))))
t nil t (t t t nil nil) t nil t t)
;;;
;;; Specialized string tests
(deftest rename-file.6
(do-special-strings
(s "file-to-be-renamed.txt" nil)
(let ((pn1 s)
(pn2 "file-that-was-renamed.txt"))
(delete-all-versions pn1)
(delete-all-versions pn2)
(with-open-file (s pn1 :direction :output) (format s "Whatever~%"))
(let ((results (multiple-value-list (rename-file pn1 pn2))))
(destructuring-bind (defaulted-new-name old-truename new-truename)
results
(assert
(equal
(list
(=t (length results) 3)
(probe-file pn1)
(notnot (probe-file pn2))
(list (notnot (pathnamep defaulted-new-name))
(notnot (pathnamep old-truename))
(notnot (pathnamep new-truename))
(typep old-truename 'logical-pathname)
(typep new-truename 'logical-pathname))
(notnot (probe-file defaulted-new-name))
(probe-file old-truename)
(notnot (probe-file new-truename)))
'(t nil t (t t t nil nil) t nil t)))))))
nil)
(deftest rename-file.7
(do-special-strings
(s "file-that-was-renamed.txt" nil)
(let ((pn1 "file-to-be-renamed.txt")
(pn2 s))
(delete-all-versions pn1)
(delete-all-versions pn2)
(with-open-file (s pn1 :direction :output) (format s "Whatever~%"))
(let ((results (multiple-value-list (rename-file pn1 pn2))))
(destructuring-bind (defaulted-new-name old-truename new-truename)
results
(assert
(equal
(list
(=t (length results) 3)
(probe-file pn1)
(notnot (probe-file pn2))
(list (notnot (pathnamep defaulted-new-name))
(notnot (pathnamep old-truename))
(notnot (pathnamep new-truename))
(typep old-truename 'logical-pathname)
(typep new-truename 'logical-pathname))
(notnot (probe-file defaulted-new-name))
(probe-file old-truename)
(notnot (probe-file new-truename)))
'(t nil t (t t t nil nil) t nil t)))))))
nil)
;;; Error tests
(deftest rename-file.error.1
(signals-error (rename-file) program-error)
......
......@@ -69,7 +69,15 @@
)))
t t t)
;;;
;;; Specialized string tests
(deftest truename.6
(do-special-strings
(s "truename.lsp" nil)
(assert (equalp (truename s) (truename "truename.lsp"))))
nil)
;;; Error tests
(deftest truename.error.1
(signals-error (truename) program-error)
......
......@@ -200,6 +200,15 @@
(wild-pathname-p "CLTEST:FOO.LISP")
nil)
;;; Odd strings
(deftest wild-pathname-p.32
(do-special-strings
(s "CLTEST:FOO.LISP" nil)
(let ((vals (multiple-value-list (wild-pathname-p s))))
(assert (equal vals '(nil)))))
nil)
;;;
(deftest wild-pathname-p.error.1
......
......@@ -169,3 +169,6 @@
1
(return-from done :good)))
:good)
;;; FIXME: Add more tests on specialized strings.
......@@ -130,6 +130,18 @@
(write-line "-=|!" nil))
#.(concatenate 'string "-=|!" (string #\Newline)))
;;; Specialized string tests
(deftest write-line.13
(do-special-strings
(s "abcde" nil)
(assert (equal
(with-output-to-string
(*standard-output*)
(multiple-value-list (write-line "abcde")))
#.(concatenate 'string "abcde" (string #\Newline)))))
nil)
;;; Error tests
(deftest write-line.error.1
......
......@@ -36,7 +36,20 @@
(:start 1 :end 4 :start 2 :end 3) "bcd")
(def-write-sequence-test write-sequence.string.13 "" () "")
;;; (Add base-string tests?)
(defmacro def-write-sequence-special-test (name string args expected)
`(deftest ,name
(let ((str ,string)
(expected ,expected))
(do-special-strings
(s str nil)
(let ((out (with-output-to-string
(os)
(assert (eq (write-sequence s os ,@args) s)))))
(assert (equal out expected)))))
nil))
(def-write-sequence-special-test write-sequence.string.14 "12345" () "12345")
(def-write-sequence-special-test write-sequence.string.15 "12345" (:start 1 :end 3) "23")
;;; on lists
......
......@@ -120,6 +120,20 @@
(write-string "-=|!" nil))
"-=|!")
;;; Specialized string tests
(deftest write-string.13
(let (result)
(do-special-strings
(s "abcde" nil)
(assert (equal
(with-output-to-string
(*standard-output*)
(setq result (multiple-value-list (write-string "abcde"))))
"abcde"))
(assert (equal result '("abcde")))))
nil)
;;; Error tests
(deftest write-string.error.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