source: project/chicken/trunk/tests/path-tests.scm @ 15119

Last change on this file since 15119 was 15119, checked in by felix winkelmann, 11 years ago

deprecated getenv and canonical-path; normalize-pathname does most of canonicalizations

File size: 2.5 KB
[13148]1(use files)
3(assert (equal? "/" (pathname-directory "/")))
4(assert (equal? "/" (pathname-directory "/abc")))
5(assert (equal? "abc" (pathname-directory "abc/")))
6(assert (equal? "abc" (pathname-directory "abc/def")))
7(assert (equal? "abc" (pathname-directory "abc/def.ghi")))
8(assert (equal? "abc" (pathname-directory "abc/.def.ghi")))
9(assert (equal? "abc" (pathname-directory "abc/.ghi")))
10(assert (equal? "/abc" (pathname-directory "/abc/")))
11(assert (equal? "/abc" (pathname-directory "/abc/def")))
12(assert (equal? "/abc" (pathname-directory "/abc/def.ghi")))
13(assert (equal? "/abc" (pathname-directory "/abc/.def.ghi")))
14(assert (equal? "/abc" (pathname-directory "/abc/.ghi")))
15(assert (equal? "q/abc" (pathname-directory "q/abc/")))
16(assert (equal? "q/abc" (pathname-directory "q/abc/def")))
17(assert (equal? "q/abc" (pathname-directory "q/abc/def.ghi")))
18(assert (equal? "q/abc" (pathname-directory "q/abc/.def.ghi")))
19(assert (equal? "q/abc" (pathname-directory "q/abc/.ghi")))
21(define-syntax test
22  (syntax-rules ()
23    ((_ expected exp)
24     (let ((result exp)
25           (expd expected))
26       (unless (equal? result expd)
27         (error "test failed" result expd 'exp))))))
29(test "./" (normalize-pathname "" 'unix))
30(test ".\\" (normalize-pathname "" 'windows))
31(test "./" (normalize-pathname "/" 'unix))
32(test "./" (normalize-pathname "./" 'unix))
33(test "a" (normalize-pathname "a"))
34(test "a/" (normalize-pathname "a/" 'unix))
35(test "a/b" (normalize-pathname "a/b" 'unix))
36(test "a/b" (normalize-pathname "a\\b" 'unix))
37(test "a\\b" (normalize-pathname "a\\b" 'windows))
38(test "a\\b" (normalize-pathname "a/b" 'windows))
39(test "a/b/" (normalize-pathname "a/b/" 'unix))
40(test "a/b/" (normalize-pathname "a/b//" 'unix))
41(test "a/b" (normalize-pathname "a//b" 'unix))
42(test "/a/b" (normalize-pathname "/a//b" 'unix))
43(test "/a/b" (normalize-pathname "///a//b" 'unix))
44(test "c:a\\b" (normalize-pathname "c:a/./b" 'windows))
45(test "c:/a/b" (normalize-pathname "c:/a/./b" 'unix))
46(test "c:a\\b" (normalize-pathname "c:a/./b" 'windows))
47(test "c:b" (normalize-pathname "c:a/../b" 'windows))
48(test "c:\\b" (normalize-pathname "c:\\a\\..\\b" 'windows))
49(test "a/b" (normalize-pathname "a/./././b" 'unix))
50(test "a/b" (normalize-pathname "a/b/c/d/../.." 'unix))
51(test "a/b/" (normalize-pathname "a/b/c/d/../../" 'unix))
53(define home (get-environment-variable "HOME"))
55(test (string-append home "/foo") (normalize-pathname "~/foo" 'unix))
56(test "c:~/foo" (normalize-pathname "c:~/foo" 'unix))
57(test (string-append home "\\foo") (normalize-pathname "c:~\\foo" 'windows))
Note: See TracBrowser for help on using the repository browser.