source: trunk/source/tests/ansi-tests/pathname-match-p.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Aug 15 07:46:22 2004
4;;;; Contains: Tests for PATHNAME-MATCH-P
5
6(in-package :cl-test)
7
8(compile-and-load "pathnames-aux.lsp")
9
10;;; Much of the behavior cannot be tested portably.
11
12(deftest pathname-match-p.1
13  (let ((pn1 (make-pathname :name :wild))
14        (pn2 (make-pathname :name "foo")))
15    (pathname-match-p pn1 pn2))
16  nil)
17
18(deftest pathname-match-p.2
19  (let ((pn1 (make-pathname :type :wild))
20        (pn2 (make-pathname :type "txt")))
21    (pathname-match-p pn1 pn2))
22  nil)
23
24(deftest pathname-match-p.3
25  (let ((pn1 (make-pathname :directory '(:absolute :wild)))
26        (pn2 (make-pathname :directory '(:absolute))))
27    (pathname-match-p pn1 pn2))
28  nil)
29
30(deftest pathname-match-p.4
31  (let ((pn1 (make-pathname :directory '(:relative :wild)))
32        (pn2 (make-pathname :directory '(:relative))))
33    (pathname-match-p pn1 pn2))
34  nil)
35
36(deftest pathname-match-p.5
37  (let ((pn1 (make-pathname :directory '(:relative :wild)))
38        (pn2 (make-pathname :directory nil)))
39    (and (wild-pathname-p pn1)
40         (not (pathname-directory pn2))
41         (not (pathname-match-p pn1 pn2))))
42  nil)
43
44(deftest pathname-match-p.6
45  (let ((pn1 (make-pathname :version :wild))
46        (pn2 (make-pathname)))
47    (and (wild-pathname-p pn1)
48         (not (pathname-version pn2))
49         (not (pathname-match-p pn1 pn2))))
50  nil)
51
52;;; Specialized string tests
53
54(deftest pathname-match-p.7
55  (let ((wpn (parse-namestring "CLTEST:*.LSP")))
56    (assert (wild-pathname-p wpn))
57    (do-special-strings
58     (s "CLTEST:FOO.LSP" nil)
59     (assert (pathname-match-p s wpn))))
60  nil)
61
62(deftest pathname-match-p.8
63  (do-special-strings
64   (s "CLTEST:*.LSP" nil)
65   (assert (pathname-match-p "CLTEST:FOO.LSP" s)))
66  nil)
67   
68
69;;; Add more tests here
70
71;;; Here are error tests
72
73(deftest pathname-match-p.error.1
74  (signals-error (pathname-match-p) program-error)
75  t)
76
77(deftest pathname-match-p.error.2
78  (signals-error (pathname-match-p #p"") program-error)
79  t)
80
81(deftest pathname-match-p.error.3
82  (signals-error (pathname-match-p #p"" #p"" nil) program-error)
83  t)
84
85(deftest pathname-match-p.error.4
86  (check-type-error #'(lambda (x) (pathname-match-p x #p""))
87                    #'could-be-pathname-designator)
88  nil)
89
90(deftest pathname-match-p.error.5
91  (check-type-error #'(lambda (x) (declare (optimize (safety 0))) (pathname-match-p x #p""))
92                    #'could-be-pathname-designator)
93  nil)
94
95(deftest pathname-match-p.error.6
96  (check-type-error #'(lambda (x) (pathname-match-p #p"" x))
97                    #'could-be-pathname-designator)
98  nil)
99
100(deftest pathname-match-p.error.7
101  (check-type-error #'(lambda (x) (declare (optimize (safety 0))) (pathname-match-p #p"" x))
102                    #'could-be-pathname-designator)
103  nil)
Note: See TracBrowser for help on using the repository browser.