file-author.lsp 2.13 KB
Newer Older
1
2
3
4
5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan  6 05:41:06 2004
;;;; Contains: Tests of FILE-AUTHOR

Daniel Kochmański's avatar
Daniel Kochmański committed
6

7
8
9

(deftest file-author.1
  (loop for pn in
sds's avatar
sds committed
10
11
12
13
14
        (directory (make-pathname :name :wild :type :wild
                                  :defaults *default-pathname-defaults*))
        for author = (file-author pn)
        unless (or (null author) (stringp author))
        collect (list pn author))
15
16
17
  nil)

(deftest file-author.2
18
  (let ((author (file-author "file-author.txt")))
19
    (if (or (null author) (stringp author))
sds's avatar
sds committed
20
        nil
21
22
23
24
      author))
  nil)

(deftest file-author.3
25
  (let ((author (file-author #p"file-author.txt")))
26
    (if (or (null author) (stringp author))
sds's avatar
sds committed
27
        nil
28
29
30
31
      author))
  nil)

(deftest file-author.4
32
  (let ((author (file-author (truename "file-author.txt"))))
33
    (if (or (null author) (stringp author))
sds's avatar
sds committed
34
        nil
35
36
37
38
      author))
  nil)

(deftest file-author.5
39
  (let ((author (with-open-file (s "file-author.txt" :direction :input)
sds's avatar
sds committed
40
                                (file-author s))))
41
    (if (or (null author) (stringp author))
sds's avatar
sds committed
42
        nil
43
44
45
46
      author))
  nil)

(deftest file-author.6
47
  (let ((author (let ((s (open "file-author.txt" :direction :input)))
sds's avatar
sds committed
48
49
                  (close s)
                  (file-author s))))
50
    (if (or (null author) (stringp author))
sds's avatar
sds committed
51
        nil
52
53
54
      author))
  nil)

55
56
57
58
;;; Specialized string tests

(deftest file-author.7
  (do-special-strings
59
60
   (s "file-author.txt" nil)
   (assert (equal (file-author s) (file-author "file-author.txt"))))
61
62
  nil)

63
64
65
;;; FIXME
;;; Add LPN test

66
67
68
;;; Error tests

(deftest file-author.error.1
69
70
  (signals-error (file-author) program-error)
  t)
71
72

(deftest file-author.error.2
73
  (signals-error (file-author "file-author.txt" nil) program-error)
74
  t)
75
76

(deftest file-author.error.3
77
  (signals-error-always
78
   (file-author (make-pathname :name :wild :type "lsp"
sds's avatar
sds committed
79
                               :defaults *default-pathname-defaults*))
80
   file-error)
81
  t t)
82
83

(deftest file-author.error.4
84
  (signals-error-always
85
   (file-author (make-pathname :name "file-author" :type :wild
sds's avatar
sds committed
86
                               :defaults *default-pathname-defaults*))
87
   file-error)
88
  t t)