directory-namestring.lsp 1.59 KB
Newer Older
1
                                        ;-*- Mode:     Lisp -*-
2 3 4 5
;;;; Author:   Paul Dietz
;;;; Created:  Sun Sep 12 06:21:42 2004
;;;; Contains: Tests for DIRECTORY-NAMESTRING

6

7 8

(deftest directory-namestring.1
9
    (let* ((vals (multiple-value-list
10
                  (directory-namestring "directory-namestring.txt")))
11 12 13 14 15 16
           (s (first vals)))
      (if (and (null (cdr vals))
               (stringp s)
               (equal (directory-namestring s) s))
          :good
          vals))
17 18 19
  :good)

(deftest directory-namestring.2
20
    (do-special-strings
21
        (s "directory-namestring.txt" nil)
22 23 24
      (let ((ns (directory-namestring s)))
        (assert (stringp ns))
        (assert (string= (directory-namestring ns) ns))))
25 26
  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
(deftest directory-namestring.3
34
    (let* ((name "directory-namestring.txt")
35 36 37 38 39
           (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)))
40 41 42 43 44
  t)

;;; Error tests

(deftest directory-namestring.error.1
45
    (signals-error (directory-namestring) program-error)
46 47 48
  t)

(deftest directory-namestring.error.2
49
    (signals-error
50
     (directory-namestring "directory-namestring.txt" nil)
51
     program-error)
52
  t)