Initial commit of newLISP.
[newlisp.git] / qa-utf16path.lsp
blobd749a6e3c4336801f21016c2fd59d416b2d8d20f
1 ;; qa-utf16path - check WIN_32 file and directory routines on
2 ;; UTF-16 encoded paths
4 (if (not (= ostype "Win32"))
5 (println "This test is lengthy and normally only used on"
6 " the Win32 UTF8 enabled versions.")
9 (setq Yuki "\230\162\182\230\181\166\231\148\177\232\168\152")
10 (setq InvalidUTF8 "\xC0\xC1")
12 (setq UnicodeStr Yuki)
14 (setq h 1) ; pre allocate mem so changes should be minimal
15 (setq sRand
16 (join (map char (map (curry + 32)
17 (rand
18 (- 127 32)
19 (+ 10 90);(rand 100))
22 )))
23 (setq buff sRand)
26 (define-macro (assert any)
27 (local (result)
28 (unless (setq result (eval any))
29 (throw-error (string "Expression failed! " any))
31 result
35 (println "Check memory - hit <enter>.")
36 (read-line)
38 (println "Step 1")
40 (println (time
41 (begin
42 (assert (make-dir UnicodeStr))
43 (assert (remove-dir UnicodeStr))
45 1000
48 (println "Step 2")
50 (assert (make-dir UnicodeStr))
51 (println (time (assert (directory? UnicodeStr)) 100000))
52 (println (time (assert (file? UnicodeStr)) 100000))
53 (println (time (begin
54 (assert (directory))
55 (assert (real-path UnicodeStr))
56 (assert (change-dir UnicodeStr))
57 (assert (real-path))
58 (assert (directory))
59 (assert (change-dir ".."))
60 ) 5000))
61 (assert (remove-dir UnicodeStr))
63 (println "Step 3")
66 (println (time
67 (begin
68 (assert (write-file UnicodeStr sRand))
69 (assert (= (read-file UnicodeStr) sRand))
70 (assert (append-file UnicodeStr (reverse sRand)))
71 (assert (delete-file UnicodeStr))
73 5000 ))
75 (println "Step 4")
77 (assert (write-file UnicodeStr sRand))
79 (println (time (assert (not (directory? UnicodeStr))) 100000))
80 (println (time (assert (file? UnicodeStr)) 100000))
82 (println (time (assert (file-info UnicodeStr)) 100000))
84 (println "Step 5")
86 (println (time (begin
87 (assert (setq h (open UnicodeStr "w")))
88 (assert (write-buffer h sRand))
89 (assert (close h))
90 (assert (setq h (open UnicodeStr "a")))
91 (assert (write-buffer h (reverse sRand)))
92 (assert (close h))
93 (assert (setq h (open UnicodeStr "r")))
94 (assert (read-buffer h 'buff 1024))
95 (assert (close h))
96 (assert (rename-file UnicodeStr "foo"))
97 (assert (rename-file "foo" UnicodeStr))
98 ) 10000))
100 (assert (delete-file UnicodeStr))
102 (println "Step 6")
104 (println (time (save UnicodeStr) 10000))
106 (assert (delete-file UnicodeStr))