file-write-date.lsp 2.26 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan  6 06:01:35 2004
;;;; Contains: Tests for FILE-WRITE-DATE

(in-package :cl-test)

(deftest file-write-date.1
  (let* ((pn "file-write-date.lsp")
sds's avatar
sds committed
10 11
         (date (file-write-date pn))
         (time (get-universal-time)))
pfdietz's avatar
pfdietz committed
12
    (or (null date)
sds's avatar
sds committed
13 14 15
        (and (integerp date)
             (<= 0 date time)
             t)))
pfdietz's avatar
pfdietz committed
16 17 18 19
  t)

(deftest file-write-date.2
  (let* ((pn #p"file-write-date.lsp")
sds's avatar
sds committed
20 21
         (date (file-write-date pn))
         (time (get-universal-time)))
pfdietz's avatar
pfdietz committed
22
    (or (null date)
sds's avatar
sds committed
23 24 25
        (and (integerp date)
             (<= 0 date time)
             t)))
pfdietz's avatar
pfdietz committed
26
  t)
sds's avatar
sds committed
27

pfdietz's avatar
pfdietz committed
28 29
(deftest file-write-date.3
  (let* ((pn (truename "file-write-date.lsp"))
sds's avatar
sds committed
30 31
         (date (file-write-date pn))
         (time (get-universal-time)))
pfdietz's avatar
pfdietz committed
32
    (or (null date)
sds's avatar
sds committed
33 34 35
        (and (integerp date)
             (<= 0 date time)
             t)))
pfdietz's avatar
pfdietz committed
36 37 38 39
  t)

(deftest file-write-date.4
  (loop for pn in (directory
sds's avatar
sds committed
40 41 42 43 44 45 46
                   (make-pathname :name :wild :type :wild
                                  :defaults *default-pathname-defaults*))
        for date = (file-write-date pn)
        for time = (get-universal-time)
        unless (or (null date)
                   (<= 0 date time))
        collect (list pn date time))
pfdietz's avatar
pfdietz committed
47 48 49 50 51 52
  nil)

(deftest file-write-date.5
  (length (multiple-value-list (file-write-date "file-write-date.lsp")))
  1)

53 54 55 56
;;; Specialized string tests

(deftest file-write-date.6
  (let* ((str "file-write-date.lsp")
sds's avatar
sds committed
57
         (date (file-write-date str)))
58 59 60 61 62
    (do-special-strings
     (s str nil)
     (assert (equal (file-write-date s) date))))
  nil)

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

66
;;; Error tests
pfdietz's avatar
pfdietz committed
67 68

(deftest file-write-date.error.1
69 70
  (signals-error (file-write-date) program-error)
  t)
pfdietz's avatar
pfdietz committed
71 72

(deftest file-write-date.error.2
73
  (signals-error (file-write-date "file-write-date.lsp" nil)
sds's avatar
sds committed
74
                 program-error)
75
  t)
pfdietz's avatar
pfdietz committed
76 77

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

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