Commit c04a3e22 authored by pfdietz's avatar pfdietz

Tests for the various namestring functions.

More error tests for LOGICAL-PATHNAME.
parent 04726cde
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Sep 12 06:21:42 2004
;;;; Contains: Tests for DIRECTORY-NAMESTRING
(in-package :cl-test)
(deftest directory-namestring.1
(let* ((vals (multiple-value-list
(directory-namestring "directory-namestring.lsp")))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (directory-namestring s) s))
:good
vals))
:good)
(deftest directory-namestring.2
(do-special-strings
(s "directory-namestring.lsp" nil)
(let ((ns (directory-namestring s)))
(assert (stringp ns))
(assert (string= (directory-namestring ns) ns))))
nil)
(deftest directory-namestring.3
(let* ((name "directory-namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (with-open-file (s pn :direction :input)
(directory-namestring s)))
(name3 (directory-namestring pn)))
(or (equalt name2 name3) (list name2 name3)))
t)
;;; Error tests
(deftest directory-namestring.error.1
(signals-error (directory-namestring) program-error)
t)
(deftest directory-namestring.error.2
(signals-error (directory-namestring "directory-namestring.lsp" nil) program-error)
t)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Sep 12 06:23:50 2004
;;;; Contains: Tests of ENOUGH-NAMESTRING
(in-package :cl-test)
(deftest enough-namestring.1
(let* ((vals (multiple-value-list (enough-namestring "enough-namestring.lsp")))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (enough-namestring s) s))
:good
vals))
:good)
(deftest enough-namestring.2
(do-special-strings
(s "enough-namestring.lsp" nil)
(let ((ns (enough-namestring s)))
(assert (stringp ns))
(assert (string= (enough-namestring ns) ns))))
nil)
(deftest enough-namestring.3
(let* ((name "enough-namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (enough-namestring pn))
(name3 (enough-namestring name)))
(or (equalt name2 name3) (list name2 name3)))
t)
(deftest enough-namestring.4
(let* ((name "enough-namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (with-open-file (s pn :direction :input) (enough-namestring s)))
(name3 (enough-namestring name)))
(or (equalt name2 name3) (list name2 name3)))
t)
(deftest enough-namestring.5
(let* ((vals (multiple-value-list (enough-namestring "enough-namestring.lsp"
*default-pathname-defaults*)))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (enough-namestring s) s))
:good
vals))
:good)
(deftest enough-namestring.6
(let* ((vals (multiple-value-list (enough-namestring "enough-namestring.lsp"
(namestring *default-pathname-defaults*))))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (enough-namestring s) s))
:good
vals))
:good)
(deftest enough-namestring.7
(do-special-strings
(s (namestring *default-pathname-defaults*) nil)
(let* ((vals (multiple-value-list (enough-namestring "enough-namestring.lsp" s)))
(s2 (first vals)))
(assert (null (cdr vals)))
(assert (stringp s2))
(assert (equal (enough-namestring s2) s2))))
nil)
;;; Error tests
(deftest enough-namestring.error.1
(signals-error (enough-namestring) program-error)
t)
(deftest enough-namestring.error.2
(signals-error
(enough-namestring "enough-namestring.lsp" *default-pathname-defaults* nil)
program-error)
t)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Sep 11 07:40:47 2004
;;;; Contains: Tests for FILE-NAMESTRING
(in-package :cl-test)
(deftest file-namestring.1
(let* ((vals (multiple-value-list
(file-namestring "file-namestring.lsp")))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (file-namestring s) s))
:good
vals))
:good)
(deftest file-namestring.2
(do-special-strings
(s "file-namestring.lsp" nil)
(let ((ns (file-namestring s)))
(assert (stringp ns))
(assert (string= (file-namestring ns) ns))))
nil)
(deftest file-namestring.3
(let* ((name "file-namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (with-open-file (s pn :direction :input)
(file-namestring s)))
(name3 (file-namestring pn)))
(or (equalt name2 name3) (list name2 name3)))
t)
;;; Error tests
(deftest file-namestring.error.1
(signals-error (file-namestring) program-error)
t)
(deftest file-namestring.error.2
(signals-error (file-namestring "file-namestring.lsp" nil) program-error)
t)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Sep 12 06:22:40 2004
;;;; Contains: Tests of HOST-NAMESTRING
(in-package :cl-test)
(deftest host-namestring.1
(let* ((vals (multiple-value-list
(host-namestring "host-namestring.lsp")))
(s (first vals)))
(if (and (null (cdr vals))
(stringp s)
(equal (host-namestring s) s))
:good
vals))
:good)
(deftest host-namestring.2
(do-special-strings
(s "host-namestring.lsp" nil)
(let ((ns (host-namestring s)))
(assert (stringp ns))
(assert (string= (host-namestring ns) ns))))
nil)
(deftest host-namestring.3
(let* ((name "host-namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (with-open-file (s pn :direction :input)
(host-namestring s)))
(name3 (host-namestring pn)))
(or (equalt name2 name3) (list name2 name3)))
t)
;;; Error tests
(deftest host-namestring.error.1
(signals-error (host-namestring) program-error)
t)
(deftest host-namestring.error.2
(signals-error (host-namestring "host-namestring.lsp" nil) program-error)
t)
......@@ -24,6 +24,10 @@
(load "translate-logical-pathname.lsp")
(load "namestring.lsp")
(load "file-namestring.lsp")
(load "directory-namestring.lsp")
(load "host-namestring.lsp")
(load "enough-namestring.lsp")
(load "wild-pathname-p.lsp")
(load "merge-pathnames.lsp")
......
......@@ -23,3 +23,15 @@
collect x)
nil)
(deftest logical-pathname.error.2
;; Doesn't specify a host
(signals-error (logical-pathname "FOO.TXT") type-error)
t)
(deftest logical-pathname.error.3
(signals-error
(with-open-file (s #p"logical-pathname.lsp" :direction :input)
(logical-pathname s))
type-error)
t)
......@@ -23,3 +23,28 @@
(assert (string= (namestring ns) ns))))
nil)
(deftest namestring.3
(let* ((name "namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (namestring pn))
(pn2 (pathname name2)))
(or (equalt pn pn2) (list pn pn2)))
t)
(deftest namestring.4
(let* ((name "namestring.lsp")
(pn (merge-pathnames (pathname name)))
(name2 (with-open-file (s pn :direction :input) (namestring s)))
(pn2 (pathname name2)))
(or (equalt pn pn2) (list pn pn2)))
t)
;;; Error tests
(deftest namestring.error.1
(signals-error (namestring) program-error)
t)
(deftest namestring.error.2
(signals-error (namestring "namestring.lsp" nil) program-error)
t)
......@@ -49,6 +49,8 @@
(not (pathname-match-p pn1 pn2))))
nil)
;;; Add more tests here
;;; Here are error tests
(deftest pathname-match-p.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