source: project/release/3/filepath/trunk/tests/run.scm @ 12288

Last change on this file since 12288 was 12288, checked in by Ivan Raikov, 13 years ago

Some bug fixes and added file with test cases.

File size: 1.5 KB
Line 
1(require-extension srfi-1)
2(require-extension filepath)
3(require-extension test)
4
5;; test cases from Haskell implementation
6
7(test-group "split-search-path"
8            (let ((ex (list "File1" "File2" "File3")))
9              (let ((p "File1;File2;File3"))
10                (filepath:posix #f)
11                (test  (sprintf "(split-search-path ~S) => ~S (Windows)" p ex)
12                      ex (filepath:split-search-path p)))
13              (filepath:posix #t)
14              (let ((p "File1:File2:File3"))
15                (test (sprintf "(split-search-path ~S) => ~S (POSIX)" p ex)
16                      ex (filepath:split-search-path p)))))
17#|
18-- > splitExtension "file.txt" == ("file",".txt")
19-- > splitExtension "file" == ("file","")
20-- > splitExtension "file/file.txt" == ("file/file",".txt")
21-- > splitExtension "file.txt/boris" == ("file.txt/boris","")
22-- > splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext")
23-- > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")
24-- > splitExtension "file/path.txt/" == ("file/path.txt/","")
25|#
26
27(define split-extension-tests
28 `(("file.txt"  ("file" ".txt"))
29   ("file"  ("file" ""))
30   ("file/file.txt"  ("file/file" ".txt"))
31   ("file.txt/boris"  ("file.txt/boris" ""))
32   ("file.txt/boris.ext"  ("file.txt/boris" ".ext"))
33   ("file/path.txt.bob.fred"  ("file/path.txt.bob" ".fred"))
34   ("file/path.txt/"  ("file/path.txt/" ""))))
35 
36
37(test-group "split-extension"
38            (for-each (lambda (pr)
39                        (let ((p (first pr)) (res (second pr)))
40                          (test (sprintf "(split-extension ~S) => ~S" p res)
41                                res (filepath:split-extension p))))
42                      split-extension-tests))
43
44
45
Note: See TracBrowser for help on using the repository browser.