1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
3 ;;; --- iolib.pathnames test suite.
6 (in-package :iolib-tests
)
8 (in-suite :iolib.pathnames
)
10 (defmacro is-file-path
(path (&rest components
))
14 (and (eql (file-path-host ,p
) :unspecific
)
15 (eql (file-path-device ,p
) :unspecific
)
16 (and (= (length ',components
)
17 (length (file-path-components ,p
)))
18 (every #'(lambda (x y
)
21 (string (string= x y
))))
22 (file-path-components ,p
)
26 (test (file-path.null
.1 :compile-at
:definition-time
)
27 (signals invalid-file-path
28 (parse-file-path "")))
30 (test (file-path.null
.2 :compile-at
:definition-time
)
31 (signals invalid-file-path
32 (parse-file-path "" :expand-user t
)))
35 (test (file-path.root
.1 :compile-at
:definition-time
)
36 (is-file-path (parse-file-path "/")
39 (test (file-path.root
.2 :compile-at
:definition-time
)
40 (is-file-path (parse-file-path "/" :expand-user t
)
44 (test (file-path.relative
.1 :compile-at
:definition-time
)
45 (is-file-path (parse-file-path "a")
48 (test (file-path.relative
.2 :compile-at
:definition-time
)
49 (is-file-path (parse-file-path "a" :expand-user t
)
52 (test (file-path.relative
.3 :compile-at
:definition-time
)
53 (is-file-path (parse-file-path "a/")
56 (test (file-path.relative
.4 :compile-at
:definition-time
)
57 (is-file-path (parse-file-path "a/" :expand-user t
)
60 (test (file-path.relative
.5 :compile-at
:definition-time
)
61 (is-file-path (parse-file-path "a/b")
64 (test (file-path.relative
.6 :compile-at
:definition-time
)
65 (is-file-path (parse-file-path "a/b" :expand-user t
)
69 (test (file-path.absolute
.1 :compile-at
:definition-time
)
70 (is-file-path (parse-file-path "/a")
73 (test (file-path.absolute
.2 :compile-at
:definition-time
)
74 (is-file-path (parse-file-path "/a" :expand-user t
)
77 (test (file-path.absolute
.3 :compile-at
:definition-time
)
78 (is-file-path (parse-file-path "/a/")
81 (test (file-path.absolute
.4 :compile-at
:definition-time
)
82 (is-file-path (parse-file-path "/a/" :expand-user t
)
85 (test (file-path.absolute
.5 :compile-at
:definition-time
)
86 (is-file-path (parse-file-path "/a/b")
89 (test (file-path.absolute
.6 :compile-at
:definition-time
)
90 (is-file-path (parse-file-path "/a/b" :expand-user t
)
94 (test (file-path.expand-user
.1 :compile-at
:definition-time
)
95 (is-file-path (parse-file-path "~root" :expand-user nil
)
98 (test (file-path.expand-user
.2 :compile-at
:definition-time
)
99 (is-file-path (parse-file-path "~root" :expand-user t
)
102 (test (file-path.expand-user
.3 :compile-at
:definition-time
)
103 (is-file-path (parse-file-path "/~root")
106 (test (file-path.expand-user
.4 :compile-at
:definition-time
)
107 (is-file-path (parse-file-path "/~root" :expand-user t
)
110 (test (file-path.expand-user
.5 :compile-at
:definition-time
)
111 (is-file-path (parse-file-path "~root/a" :expand-user nil
)
114 (test (file-path.expand-user
.6 :compile-at
:definition-time
)
115 (is-file-path (parse-file-path "~root/a" :expand-user t
)
119 (test (file-path.namestring
.1 :compile-at
:definition-time
)
120 (is (equal "/" (file-path-namestring (file-path "/")))))
122 (test (file-path.namestring
.2 :compile-at
:definition-time
)
123 (is (equal "/." (file-path-namestring (file-path "/.")))))
125 (test (file-path.namestring
.3 :compile-at
:definition-time
)
126 (is (equal "/.." (file-path-namestring (file-path "/..")))))
128 (test (file-path.namestring
.4 :compile-at
:definition-time
)
129 (is (equal "." (file-path-namestring (file-path ".")))))
131 (test (file-path.namestring
.5 :compile-at
:definition-time
)
132 (is (equal "." (file-path-namestring (file-path "./")))))
134 (test (file-path.namestring
.6 :compile-at
:definition-time
)
135 (is (equal "../." (file-path-namestring (file-path "../.")))))
137 (test (file-path.namestring
.7 :compile-at
:definition-time
)
138 (is (equal "../." (file-path-namestring (file-path ".././")))))
140 (test (file-path.namestring
.8 :compile-at
:definition-time
)
141 (is (equal "../.." (file-path-namestring (file-path "../..")))))
143 (test (file-path.namestring
.9 :compile-at
:definition-time
)
144 (is (equal "a/./b" (file-path-namestring (file-path "a/./b")))))
146 (test (file-path.namestring
.10 :compile-at
:definition-time
)
147 (is (equal "a/../b" (file-path-namestring (file-path "a/../b")))))
150 (test (file-path.directory
.1 :compile-at
:definition-time
)
151 (is (equal '(:root
) (file-path-directory (file-path "/")))))
153 (test (file-path.directory
.2 :compile-at
:definition-time
)
154 (is (equal '(:root
) (file-path-directory (file-path "/.")))))
156 (test (file-path.directory
.3 :compile-at
:definition-time
)
157 (is (equal '(:root
) (file-path-directory (file-path "/..")))))
159 (test (file-path.directory
.4 :compile-at
:definition-time
)
160 (is (equal '(".") (file-path-directory (file-path ".")))))
162 (test (file-path.directory
.5 :compile-at
:definition-time
)
163 (is (equal '(".") (file-path-directory (file-path "./")))))
165 (test (file-path.directory
.6 :compile-at
:definition-time
)
166 (is (equal '(".") (file-path-directory (file-path "..")))))
168 (test (file-path.directory
.7 :compile-at
:definition-time
)
169 (is (equal '(".") (file-path-directory (file-path "../")))))
171 (test (file-path.directory
.8 :compile-at
:definition-time
)
172 (is (equal '("..") (file-path-directory (file-path "../.")))))
174 (test (file-path.directory
.9 :compile-at
:definition-time
)
175 (is (equal '("..") (file-path-directory (file-path ".././")))))
177 (test (file-path.directory
.10 :compile-at
:definition-time
)
178 (is (equal '("..") (file-path-directory (file-path "../..")))))
180 (test (file-path.directory
.11 :compile-at
:definition-time
)
181 (is (equal '("..") (file-path-directory (file-path "../../")))))
183 (test (file-path.directory
.12 :compile-at
:definition-time
)
184 (is (equal '("a" ".") (file-path-directory (file-path "a/./b")))))
186 (test (file-path.directory
.13 :compile-at
:definition-time
)
187 (is (equal '("a" "..") (file-path-directory (file-path "a/../b")))))
190 (test (file-path.directory-namestring
.1 :compile-at
:definition-time
)
191 (is (equal "/" (file-path-directory (file-path "/") :namestring t
))))
193 (test (file-path.directory-namestring
.2 :compile-at
:definition-time
)
194 (is (equal "/" (file-path-directory (file-path "/.") :namestring t
))))
196 (test (file-path.directory-namestring
.3 :compile-at
:definition-time
)
197 (is (equal "/" (file-path-directory (file-path "/..") :namestring t
))))
199 (test (file-path.directory-namestring
.4 :compile-at
:definition-time
)
200 (is (equal "." (file-path-directory (file-path ".") :namestring t
))))
202 (test (file-path.directory-namestring
.5 :compile-at
:definition-time
)
203 (is (equal "." (file-path-directory (file-path "./") :namestring t
))))
205 (test (file-path.directory-namestring
.6 :compile-at
:definition-time
)
206 (is (equal "." (file-path-directory (file-path "..") :namestring t
))))
208 (test (file-path.directory-namestring
.7 :compile-at
:definition-time
)
209 (is (equal "." (file-path-directory (file-path "../") :namestring t
))))
211 (test (file-path.directory-namestring
.8 :compile-at
:definition-time
)
212 (is (equal ".." (file-path-directory (file-path "../.") :namestring t
))))
214 (test (file-path.directory-namestring
.9 :compile-at
:definition-time
)
215 (is (equal ".." (file-path-directory (file-path ".././") :namestring t
))))
217 (test (file-path.directory-namestring
.10 :compile-at
:definition-time
)
218 (is (equal ".." (file-path-directory (file-path "../..") :namestring t
))))
220 (test (file-path.directory-namestring
.11 :compile-at
:definition-time
)
221 (is (equal ".." (file-path-directory (file-path "../../") :namestring t
))))
223 (test (file-path.directory-namestring
.12 :compile-at
:definition-time
)
224 (is (equal "a/." (file-path-directory (file-path "a/./b") :namestring t
))))
226 (test (file-path.directory-namestring
.13 :compile-at
:definition-time
)
227 (is (equal "a/.." (file-path-directory (file-path "a/../b") :namestring t
))))
230 (test (file-path.file
.1 :compile-at
:definition-time
)
231 (is (equal "." (file-path-file (file-path "/")))))
233 (test (file-path.file
.2 :compile-at
:definition-time
)
234 (is (equal "." (file-path-file (file-path "/.")))))
236 (test (file-path.file
.3 :compile-at
:definition-time
)
237 (is (equal ".." (file-path-file (file-path "/..")))))
239 (test (file-path.file
.4 :compile-at
:definition-time
)
240 (is (equal "." (file-path-file (file-path ".")))))
242 (test (file-path.file
.5 :compile-at
:definition-time
)
243 (is (equal "." (file-path-file (file-path "./")))))
245 (test (file-path.file
.6 :compile-at
:definition-time
)
246 (is (equal ".." (file-path-file (file-path "..")))))
248 (test (file-path.file
.7 :compile-at
:definition-time
)
249 (is (equal ".." (file-path-file (file-path "../")))))
251 (test (file-path.file
.8 :compile-at
:definition-time
)
252 (is (equal "." (file-path-file (file-path "../.")))))
254 (test (file-path.file
.9 :compile-at
:definition-time
)
255 (is (equal "." (file-path-file (file-path ".././")))))
257 (test (file-path.file
.10 :compile-at
:definition-time
)
258 (is (equal ".." (file-path-file (file-path "../..")))))
260 (test (file-path.file
.11 :compile-at
:definition-time
)
261 (is (equal ".." (file-path-file (file-path "../../")))))
263 (test (file-path.file
.12 :compile-at
:definition-time
)
264 (is (equal "b" (file-path-file (file-path "a/./b")))))
266 (test (file-path.file
.13 :compile-at
:definition-time
)
267 (is (equal "b" (file-path-file (file-path "a/../b")))))
270 (test (file-path.file-name
.1 :compile-at
:definition-time
)
271 (is (equal "." (file-path-file-name (file-path "/")))))
273 (test (file-path.file-name
.2 :compile-at
:definition-time
)
274 (is (equal "." (file-path-file-name (file-path ".")))))
276 (test (file-path.file-name
.3 :compile-at
:definition-time
)
277 (is (equal "." (file-path-file-name (file-path "./")))))
279 (test (file-path.file-name
.4 :compile-at
:definition-time
)
280 (is (equal "." (file-path-file-name (file-path "..")))))
282 (test (file-path.file-name
.5 :compile-at
:definition-time
)
283 (is (equal "." (file-path-file-name (file-path "../")))))
285 (test (file-path.file-name
.6 :compile-at
:definition-time
)
286 (is (equal "a" (file-path-file-name (file-path "a")))))
288 (test (file-path.file-name
.7 :compile-at
:definition-time
)
289 (is (equal "a" (file-path-file-name (file-path "a.")))))
291 (test (file-path.file-name
.8 :compile-at
:definition-time
)
292 (is (equal ".a" (file-path-file-name (file-path ".a")))))
294 (test (file-path.file-name
.9 :compile-at
:definition-time
)
295 (is (equal "a" (file-path-file-name (file-path "a.b")))))
298 (test (file-path.file-type
.1 :compile-at
:definition-time
)
299 (is (eql nil
(file-path-file-type (file-path "/")))))
301 (test (file-path.file-type
.2 :compile-at
:definition-time
)
302 (is (eql nil
(file-path-file-type (file-path ".")))))
304 (test (file-path.file-type
.3 :compile-at
:definition-time
)
305 (is (eql nil
(file-path-file-type (file-path "./")))))
307 (test (file-path.file-type
.4 :compile-at
:definition-time
)
308 (is (eql nil
(file-path-file-type (file-path "..")))))
310 (test (file-path.file-type
.5 :compile-at
:definition-time
)
311 (is (eql nil
(file-path-file-type (file-path "../")))))
313 (test (file-path.file-type
.6 :compile-at
:definition-time
)
314 (is (eql nil
(file-path-file-type (file-path "a")))))
316 (test (file-path.file-type
.7 :compile-at
:definition-time
)
317 (is (eql nil
(file-path-file-type (file-path "a.")))))
319 (test (file-path.file-type
.8 :compile-at
:definition-time
)
320 (is (eql nil
(file-path-file-type (file-path ".a")))))
322 (test (file-path.file-type
.9 :compile-at
:definition-time
)
323 (is (equal "b" (file-path-file-type (file-path "a.b")))))