directory-namestring.lsp 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- 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
sds's avatar
sds committed
10 11
                (directory-namestring "directory-namestring.lsp")))
         (s (first vals)))
12
    (if (and (null (cdr vals))
sds's avatar
sds committed
13 14 15
             (stringp s)
             (equal (directory-namestring s) s))
        :good
16 17 18 19 20 21 22 23 24 25 26
      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)

27 28 29 30 31 32
;;; Lispworks makes another assumption about filename normalization
;;; when using file streams as pathname designators, so this test
;;; doesn't work there.
;;; (This is another example of the difficulty of testing a feature
;;;  in which so much is left up to the implementation.)
#-lispworks
33 34
(deftest directory-namestring.3
  (let* ((name "directory-namestring.lsp")
sds's avatar
sds committed
35 36 37 38
         (pn (merge-pathnames (pathname name)))
         (name2 (with-open-file (s pn :direction :input)
                                (directory-namestring s)))
         (name3 (directory-namestring pn)))
39 40 41 42 43 44 45 46 47 48 49 50
    (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)