file-namestring.lsp 1.15 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- 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
sds's avatar
sds committed
10 11
                (file-namestring "file-namestring.lsp")))
         (s (first vals)))
12
    (if (and (null (cdr vals))
sds's avatar
sds committed
13 14 15
             (stringp s)
             (equal (file-namestring s) s))
        :good
16 17 18 19 20 21 22 23 24 25 26 27 28
      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")
sds's avatar
sds committed
29 30 31 32
         (pn (merge-pathnames (pathname name)))
         (name2 (with-open-file (s pn :direction :input)
                                (file-namestring s)))
         (name3 (file-namestring pn)))
33 34 35 36 37 38 39 40 41 42 43 44
    (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)