author | Claus Gittinger <cg@exept.de> |
Tue, 25 Feb 2020 17:19:49 +0100 | |
changeset 2586 | 7dc7be5a6f3d |
parent 2398 | d6896f5dc88a |
permissions | -rw-r--r-- |
2398 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1447 | 3 |
"{ Package: 'stx:goodies/regression' }" |
822 | 4 |
|
5 |
"{ NameSpace: RegressionTests }" |
|
6 |
||
7 |
TestCase subclass:#FilenameTests |
|
8 |
instanceVariableNames:'filename' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
869
32dea6c8b627
class: RegressionTests::FilenameTests
Claus Gittinger <cg@exept.de>
parents:
822
diff
changeset
|
11 |
category:'tests-Regression' |
822 | 12 |
! |
13 |
||
14 |
||
2161 | 15 |
!FilenameTests methodsFor:'initialize / release'! |
822 | 16 |
|
17 |
tearDown |
|
18 |
filename notNil ifTrue:[ |
|
1447 | 19 |
filename exists ifTrue:[ |
20 |
filename remove |
|
21 |
] |
|
822 | 22 |
]. |
23 |
||
24 |
"Created: / 21-02-2013 / 17:56:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
25 |
! ! |
|
26 |
||
27 |
!FilenameTests methodsFor:'tests'! |
|
28 |
||
29 |
test_01 |
|
30 |
" |
|
31 |
Tests whether filenames are properly encoded before |
|
32 |
passed to an operating system (i.e. whether paths |
|
33 |
are string-type transparent) |
|
34 |
" |
|
35 |
||
36 |
| path | |
|
37 |
||
38 |
filename := 'abcd' asFilename. |
|
39 |
"Create the file" |
|
1447 | 40 |
filename writingFileDo:[:s|]. |
822 | 41 |
|
42 |
path := filename pathName. |
|
43 |
"Make sure it is all ascii" |
|
44 |
self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
45 |
||
46 |
self assert: path asFilename exists. |
|
47 |
self assert: path asUnicode16String asFilename exists. |
|
48 |
self assert: path asUnicode32String asFilename exists. |
|
49 |
||
50 |
"Created: / 21-02-2013 / 17:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
51 |
! |
|
52 |
||
53 |
test_01_unix |
|
54 |
" |
|
55 |
Tests whether filenames are properly encoded before |
|
56 |
passed to an operating system (i.e. whether paths |
|
57 |
are string-type transparent) |
|
58 |
||
59 |
This has been fixed in JV's stx:libbasic rev 7766f4524d50. |
|
60 |
||
61 |
See https://swing.fit.cvut.cz/hg/stx.libbasic/rev/7766f4524d50 |
|
62 |
||
63 |
" |
|
64 |
||
65 |
| path locale | |
|
66 |
||
67 |
OperatingSystem isUNIXlike ifFalse:[ ^ self ]. |
|
68 |
||
69 |
filename := 'unix' asFilename. |
|
70 |
"Create the file" |
|
1447 | 71 |
filename writingFileDo:[:s|]. |
822 | 72 |
|
73 |
path := filename pathName. |
|
74 |
"Make sure it is all ascii" |
|
75 |
self assert: (path allSatisfy:[:c|c codePoint <= 127]). |
|
76 |
||
77 |
"Now, pretend standard locale..." |
|
78 |
locale := OperatingSystem getEnvironment: 'LANG'. |
|
79 |
||
80 |
[ |
|
1447 | 81 |
OperatingSystem setEnvironment: 'LANG' to: 'C'. |
82 |
OperatingSystem initialize. "/reinitialize locale definitions |
|
822 | 83 |
|
1447 | 84 |
self assert: path asFilename exists. |
85 |
self assert: path asUnicode16String asFilename exists. |
|
86 |
self assert: path asUnicode32String asFilename exists. |
|
822 | 87 |
|
88 |
] ensure:[ |
|
1447 | 89 |
OperatingSystem setEnvironment: 'LANG' to: locale. |
90 |
OperatingSystem initialize. "/reinitialize locale definitions |
|
822 | 91 |
] |
92 |
||
93 |
"Created: / 21-02-2013 / 17:56:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2398 | 94 |
! |
95 |
||
96 |
test_02_parentDirectory |
|
97 |
| | |
|
98 |
||
99 |
OperatingSystem isUNIXlike ifTrue:[ |
|
100 |
self assert:('.' asFilename directoryName = '..'). |
|
101 |
self assert:('.' asFilename directory directoryName = '../..'). |
|
102 |
self assert:('./foo' asFilename directoryName = '.'). |
|
103 |
self assert:('./foo/bar' asFilename directoryName = './foo'). |
|
104 |
self assert:('./..' asFilename directoryName = './../..'). |
|
105 |
self assert:('../..' asFilename directoryName = '../../..'). |
|
106 |
self assert:('../foo/..' asFilename directoryName = '../foo/../..'). |
|
107 |
self assert:('../foo/../bar' asFilename directoryName = '../foo/..'). |
|
108 |
] ifFalse:[ |
|
109 |
self assert:('.' asFilename directoryName = '..'). |
|
110 |
self assert:('.' asFilename directory directoryName = '..\..'). |
|
111 |
self assert:('.\foo' asFilename directoryName = '.'). |
|
112 |
self assert:('.\foo\bar' asFilename directoryName = '.\foo'). |
|
113 |
self assert:('.\..' asFilename directoryName = '.\..\..'). |
|
114 |
self assert:('..\..' asFilename directoryName = '..\..\..'). |
|
115 |
self assert:('..\foo\..' asFilename directoryName = '..\foo\..\..'). |
|
116 |
self assert:('..\foo\..\bar' asFilename directoryName = '..\foo\..'). |
|
117 |
]. |
|
822 | 118 |
! ! |
119 |
||
120 |
!FilenameTests class methodsFor:'documentation'! |
|
121 |
||
122 |
version |
|
123 |
^ '$Header$' |
|
124 |
! |
|
125 |
||
126 |
version_CVS |
|
127 |
^ '$Header$' |
|
128 |
! ! |
|
129 |