|
1 "{ Package: 'exept:regression' }" |
|
2 |
|
3 "{ NameSpace: RegressionTests }" |
|
4 |
|
5 TestCase subclass:#FilenameTests |
|
6 instanceVariableNames:'filename' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'System-Support' |
|
10 ! |
|
11 |
|
12 |
|
13 !FilenameTests methodsFor:'running'! |
|
14 |
|
15 tearDown |
|
16 filename notNil ifTrue:[ |
|
17 filename exists ifTrue:[ |
|
18 filename remove |
|
19 ] |
|
20 ]. |
|
21 |
|
22 "Created: / 21-02-2013 / 17:56:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
23 ! ! |
|
24 |
|
25 !FilenameTests methodsFor:'tests'! |
|
26 |
|
27 test_01 |
|
28 " |
|
29 Tests whether filenames are properly encoded before |
|
30 passed to an operating system (i.e. whether paths |
|
31 are string-type transparent) |
|
32 " |
|
33 |
|
34 | path | |
|
35 |
|
36 filename := 'abcd' asFilename. |
|
37 "Create the file" |
|
38 filename writingFileDo:[:s|]. |
|
39 |
|
40 path := filename pathName. |
|
41 "Make sure it is all ascii" |
|
42 self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
43 |
|
44 self assert: path asFilename exists. |
|
45 self assert: path asUnicode16String asFilename exists. |
|
46 self assert: path asUnicode32String asFilename exists. |
|
47 |
|
48 "Created: / 21-02-2013 / 17:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
49 ! |
|
50 |
|
51 test_01_unix |
|
52 " |
|
53 Tests whether filenames are properly encoded before |
|
54 passed to an operating system (i.e. whether paths |
|
55 are string-type transparent) |
|
56 |
|
57 This has been fixed in JV's stx:libbasic rev 7766f4524d50. |
|
58 |
|
59 See https://swing.fit.cvut.cz/hg/stx.libbasic/rev/7766f4524d50 |
|
60 |
|
61 " |
|
62 |
|
63 | path locale | |
|
64 |
|
65 OperatingSystem isUNIXlike ifFalse:[ ^ self ]. |
|
66 |
|
67 filename := 'unix' asFilename. |
|
68 "Create the file" |
|
69 filename writingFileDo:[:s|]. |
|
70 |
|
71 path := filename pathName. |
|
72 "Make sure it is all ascii" |
|
73 self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
74 |
|
75 "Now, pretend standard locale..." |
|
76 locale := OperatingSystem getEnvironment: 'LANG'. |
|
77 |
|
78 [ |
|
79 OperatingSystem setEnvironment: 'LANG' to: 'C'. |
|
80 OperatingSystem initialize. "/reinitialize locale definitions |
|
81 |
|
82 self assert: path asFilename exists. |
|
83 self assert: path asUnicode16String asFilename exists. |
|
84 self assert: path asUnicode32String asFilename exists. |
|
85 |
|
86 ] ensure:[ |
|
87 OperatingSystem setEnvironment: 'LANG' to: locale. |
|
88 OperatingSystem initialize. "/reinitialize locale definitions |
|
89 ] |
|
90 |
|
91 "Created: / 21-02-2013 / 17:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 ! ! |
|
93 |
|
94 !FilenameTests class methodsFor:'documentation'! |
|
95 |
|
96 version |
|
97 ^ '$Header$' |
|
98 ! |
|
99 |
|
100 version_CVS |
|
101 ^ '$Header$' |
|
102 ! ! |
|
103 |