libpath-ruby 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +61 -0
- data/examples/path_from_arg0.md +99 -0
- data/examples/path_from_arg0.rb +55 -0
- data/lib/libpath.rb +12 -0
- data/lib/libpath/constants.rb +42 -0
- data/lib/libpath/constants/unix.rb +146 -0
- data/lib/libpath/constants/windows.rb +147 -0
- data/lib/libpath/diagnostics.rb +6 -0
- data/lib/libpath/diagnostics/parameter_checking.rb +46 -0
- data/lib/libpath/exceptions.rb +7 -0
- data/lib/libpath/exceptions/libpath_base_exception.rb +77 -0
- data/lib/libpath/exceptions/malformed_name_exception.rb +85 -0
- data/lib/libpath/form.rb +42 -0
- data/lib/libpath/form/unix.rb +215 -0
- data/lib/libpath/form/windows.rb +358 -0
- data/lib/libpath/internal_/array.rb +96 -0
- data/lib/libpath/internal_/platform.rb +53 -0
- data/lib/libpath/internal_/string.rb +33 -0
- data/lib/libpath/internal_/unix/form.rb +160 -0
- data/lib/libpath/internal_/windows/drive.rb +84 -0
- data/lib/libpath/internal_/windows/form.rb +281 -0
- data/lib/libpath/libpath.rb +6 -0
- data/lib/libpath/path.rb +43 -0
- data/lib/libpath/path/unix.rb +170 -0
- data/lib/libpath/path/windows.rb +176 -0
- data/lib/libpath/util.rb +42 -0
- data/lib/libpath/util/unix.rb +414 -0
- data/lib/libpath/util/windows.rb +636 -0
- data/lib/libpath/version.rb +73 -0
- data/test/performance/benchmark_drive_letter.rb +31 -0
- data/test/performance/benchmark_gsub_string_or_regex.rb +45 -0
- data/test/performance/benchmark_rindex2.rb +109 -0
- data/test/performance/benchmark_split.rb +32 -0
- data/test/unit/compare/ts_all.rb +22 -0
- data/test/unit/equate/ts_all.rb +22 -0
- data/test/unit/equate/unix/ts_all.rb +22 -0
- data/test/unit/equate/windows/ts_all.rb +22 -0
- data/test/unit/exceptions/tc_libpath_base_exception.rb +27 -0
- data/test/unit/exceptions/tc_malformed_name_exception.rb +31 -0
- data/test/unit/exceptions/ts_all.rb +22 -0
- data/test/unit/form/tc_absolute_functions.rb +369 -0
- data/test/unit/form/ts_all.rb +22 -0
- data/test/unit/form/unix/tc_absolute_functions.rb +269 -0
- data/test/unit/form/unix/ts_all.rb +22 -0
- data/test/unit/form/windows/tc_absolute_functions.rb +854 -0
- data/test/unit/form/windows/ts_all.rb +22 -0
- data/test/unit/internal_/tc_array.rb +62 -0
- data/test/unit/internal_/ts_all.rb +22 -0
- data/test/unit/internal_/unix/form/tc_slash_functions.rb +60 -0
- data/test/unit/internal_/unix/form/ts_all.rb +22 -0
- data/test/unit/internal_/unix/tc_split_path.rb +396 -0
- data/test/unit/internal_/unix/ts_all.rb +22 -0
- data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +220 -0
- data/test/unit/internal_/windows/form/tc_slash_functions.rb +61 -0
- data/test/unit/internal_/windows/form/ts_all.rb +22 -0
- data/test/unit/internal_/windows/tc_split_path.rb +881 -0
- data/test/unit/internal_/windows/ts_all.rb +22 -0
- data/test/unit/parse/ts_all.rb +22 -0
- data/test/unit/path/tc_path.rb +778 -0
- data/test/unit/path/ts_all.rb +22 -0
- data/test/unit/path/unix/tc_path.rb +565 -0
- data/test/unit/path/unix/ts_all.rb +22 -0
- data/test/unit/path/windows/tc_path.rb +630 -0
- data/test/unit/path/windows/ts_all.rb +22 -0
- data/test/unit/tc_version.rb +47 -0
- data/test/unit/ts_all.rb +22 -0
- data/test/unit/util/tc_combine_paths.rb +179 -0
- data/test/unit/util/tc_derive_relative_path.rb +19 -0
- data/test/unit/util/tc_make_path_canonical.rb +228 -0
- data/test/unit/util/ts_all.rb +22 -0
- data/test/unit/util/unix/tc_combine_paths.rb +65 -0
- data/test/unit/util/unix/tc_derive_relative_path.rb +123 -0
- data/test/unit/util/unix/tc_make_path_absolute.rb +117 -0
- data/test/unit/util/unix/tc_make_path_canonical.rb +139 -0
- data/test/unit/util/unix/ts_all.rb +22 -0
- data/test/unit/util/windows/tc_combine_paths.rb +131 -0
- data/test/unit/util/windows/tc_derive_relative_path.rb +155 -0
- data/test/unit/util/windows/tc_make_path_absolute.rb +163 -0
- data/test/unit/util/windows/tc_make_path_canonical.rb +220 -0
- data/test/unit/util/windows/ts_all.rb +22 -0
- metadata +144 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# executes all other tests
|
4
|
+
|
5
|
+
this_dir = File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
# all tc_*rb in current directory
|
8
|
+
Dir[File.join(this_dir, 'tc_*rb')].each do |file|
|
9
|
+
|
10
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
11
|
+
|
12
|
+
require file
|
13
|
+
end
|
14
|
+
|
15
|
+
# all ts_*rb in immediate sub-directories
|
16
|
+
Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
|
17
|
+
|
18
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
19
|
+
|
20
|
+
require file
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,854 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
4
|
+
|
5
|
+
require 'libpath/form/windows'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
require 'xqsr3/extensions/test/unit'
|
10
|
+
|
11
|
+
class Test_existence_of_namespace_LibPath_Form_Windows < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_LibPath_module_exists
|
14
|
+
|
15
|
+
assert defined?(::LibPath)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_LibPath_Form_module_exists
|
19
|
+
|
20
|
+
assert defined?(::LibPath::Form)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_LibPath_Form_Windows_module_exists
|
24
|
+
|
25
|
+
assert defined?(::LibPath::Form::Windows)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Test_classify_path_Windows < Test::Unit::TestCase
|
30
|
+
|
31
|
+
include ::LibPath::Form::Windows
|
32
|
+
|
33
|
+
def test_with_nil
|
34
|
+
|
35
|
+
if $DEBUG
|
36
|
+
|
37
|
+
assert_raise(::ArgumentError) { classify_path(nil) }
|
38
|
+
else
|
39
|
+
|
40
|
+
assert_nil classify_path(nil)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_empty
|
45
|
+
|
46
|
+
assert_nil classify_path('')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_drived
|
50
|
+
|
51
|
+
assert_equal :drived, classify_path('C:abc')
|
52
|
+
assert_equal :drived, classify_path('C:abc/')
|
53
|
+
assert_equal :drived, classify_path('C:abc\\')
|
54
|
+
|
55
|
+
assert_equal :drived, classify_path('\\\\?\\C:abc')
|
56
|
+
assert_equal :drived, classify_path('\\\\?\\C:abc/')
|
57
|
+
assert_equal :drived, classify_path('\\\\?\\C:abc\\')
|
58
|
+
|
59
|
+
assert_equal :drived, classify_path('\\\\server\\share')
|
60
|
+
|
61
|
+
assert_equal :drived, classify_path('\\\\?\\server\\share')
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_absolute
|
65
|
+
|
66
|
+
assert_equal :absolute, classify_path('C:/')
|
67
|
+
assert_equal :absolute, classify_path('C:\\')
|
68
|
+
|
69
|
+
assert_equal :absolute, classify_path('C:/abc')
|
70
|
+
assert_equal :absolute, classify_path('C:\\abc')
|
71
|
+
|
72
|
+
|
73
|
+
assert_equal :absolute, classify_path('\\\\server\\share/')
|
74
|
+
assert_equal :absolute, classify_path('\\\\server\\share\\')
|
75
|
+
|
76
|
+
assert_equal :absolute, classify_path('\\\\server\\share/abc')
|
77
|
+
assert_equal :absolute, classify_path('\\\\server\\share\\abc')
|
78
|
+
|
79
|
+
|
80
|
+
assert_equal :absolute, classify_path('\\\\?\\C:/')
|
81
|
+
assert_equal :absolute, classify_path('\\\\?\\C:\\')
|
82
|
+
|
83
|
+
assert_equal :absolute, classify_path('\\\\?\\C:/abc')
|
84
|
+
assert_equal :absolute, classify_path('\\\\?\\C:\\abc')
|
85
|
+
|
86
|
+
|
87
|
+
assert_equal :absolute, classify_path('\\\\?\\server\\share/')
|
88
|
+
assert_equal :absolute, classify_path('\\\\?\\server\\share\\')
|
89
|
+
|
90
|
+
assert_equal :absolute, classify_path('\\\\?\\server\\share/abc')
|
91
|
+
assert_equal :absolute, classify_path('\\\\?\\server\\share\\abc')
|
92
|
+
|
93
|
+
|
94
|
+
assert_equal :absolute, classify_path('\\\\?\\UNC\\server\\share/')
|
95
|
+
assert_equal :absolute, classify_path('\\\\?\\UNC\\server\\share\\')
|
96
|
+
|
97
|
+
assert_equal :absolute, classify_path('\\\\?\\UNC\\server\\share/abc')
|
98
|
+
assert_equal :absolute, classify_path('\\\\?\\UNC\\server\\share\\abc')
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_rooted
|
102
|
+
|
103
|
+
assert_equal :rooted, classify_path('/')
|
104
|
+
assert_equal :rooted, classify_path('\\')
|
105
|
+
|
106
|
+
assert_equal :rooted, classify_path('/abc')
|
107
|
+
assert_equal :rooted, classify_path('\\abc')
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_homed
|
111
|
+
|
112
|
+
assert_equal :homed, classify_path('~')
|
113
|
+
|
114
|
+
assert_equal :homed, classify_path('~/')
|
115
|
+
assert_equal :homed, classify_path('~\\')
|
116
|
+
|
117
|
+
assert_equal :homed, classify_path('~/abc')
|
118
|
+
assert_equal :homed, classify_path('~\\abc')
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_relative
|
122
|
+
|
123
|
+
assert_equal :relative, classify_path('abc')
|
124
|
+
|
125
|
+
assert_equal :relative, classify_path('~~')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
class Test_name_is_malformed_Windows < Test::Unit::TestCase
|
130
|
+
|
131
|
+
include ::LibPath::Form::Windows
|
132
|
+
|
133
|
+
def test_with_nil
|
134
|
+
|
135
|
+
assert name_is_malformed?(nil)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_empty
|
139
|
+
|
140
|
+
assert_false name_is_malformed?('')
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_absolute_paths_from_root
|
144
|
+
|
145
|
+
assert_false name_is_malformed?('/')
|
146
|
+
assert_false name_is_malformed?('//')
|
147
|
+
assert_false name_is_malformed?('/abc')
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_absolute_paths_from_home
|
151
|
+
|
152
|
+
assert_false name_is_malformed?('~')
|
153
|
+
assert_false name_is_malformed?('~/')
|
154
|
+
assert_false name_is_malformed?('~/abc')
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_relative_paths
|
158
|
+
|
159
|
+
assert_false name_is_malformed?('abc')
|
160
|
+
assert_false name_is_malformed?('abc/')
|
161
|
+
assert_false name_is_malformed?('a/')
|
162
|
+
|
163
|
+
assert_false name_is_malformed?('~abc')
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_innate_invalid_characters
|
167
|
+
|
168
|
+
assert name_is_malformed?("\0")
|
169
|
+
assert name_is_malformed?("a\0")
|
170
|
+
assert name_is_malformed?("\0a")
|
171
|
+
|
172
|
+
assert name_is_malformed?("\0", reject_shell_characters: true)
|
173
|
+
assert name_is_malformed?("a\0", reject_shell_characters: true)
|
174
|
+
assert name_is_malformed?("\0a", reject_shell_characters: true)
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_shell_invalid_characters
|
178
|
+
|
179
|
+
assert_false name_is_malformed?('*')
|
180
|
+
assert_false name_is_malformed?('?')
|
181
|
+
assert_false name_is_malformed?('|')
|
182
|
+
|
183
|
+
assert name_is_malformed?('*', reject_shell_characters: true)
|
184
|
+
assert name_is_malformed?('?', reject_shell_characters: true)
|
185
|
+
assert name_is_malformed?('|', reject_shell_characters: true)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_path_name_separators
|
189
|
+
|
190
|
+
assert_false name_is_malformed?('/')
|
191
|
+
assert_false name_is_malformed?('\\')
|
192
|
+
|
193
|
+
assert name_is_malformed?('/', reject_path_name_separators: true)
|
194
|
+
assert name_is_malformed?('\\', reject_path_name_separators: true)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_path_separators
|
198
|
+
|
199
|
+
assert_false name_is_malformed?(';')
|
200
|
+
|
201
|
+
assert name_is_malformed?(';', reject_path_separators: true)
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_partial_UNC
|
205
|
+
|
206
|
+
assert_false name_is_malformed?('\\')
|
207
|
+
assert name_is_malformed?('\\\\')
|
208
|
+
assert name_is_malformed?('\\\\server')
|
209
|
+
assert name_is_malformed?('\\\\server\\')
|
210
|
+
assert_false name_is_malformed?('\\\\server\\share')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class Test_path_is_absolute_Windows < Test::Unit::TestCase
|
215
|
+
|
216
|
+
include ::LibPath::Form::Windows
|
217
|
+
|
218
|
+
if $DEBUG
|
219
|
+
|
220
|
+
def test_with_nil
|
221
|
+
|
222
|
+
assert_raise(::ArgumentError) { path_is_absolute?(nil) }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_empty
|
227
|
+
|
228
|
+
assert_false path_is_absolute?('')
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_absolute_paths_from_UNC
|
232
|
+
|
233
|
+
assert_false path_is_absolute?('\\\\')
|
234
|
+
|
235
|
+
assert_false path_is_absolute?('\\\\server')
|
236
|
+
assert_false path_is_absolute?('\\\\server\\')
|
237
|
+
|
238
|
+
# form 2
|
239
|
+
|
240
|
+
assert_false path_is_absolute?('\\\\server\\share')
|
241
|
+
assert path_is_absolute?('\\\\server\\share\\')
|
242
|
+
assert path_is_absolute?('\\\\server\\share/')
|
243
|
+
|
244
|
+
assert_false path_is_absolute?('\\\\server\\the-share_name')
|
245
|
+
assert path_is_absolute?('\\\\server\\the-share_name/')
|
246
|
+
assert path_is_absolute?('\\\\server\\the-share_name\\')
|
247
|
+
assert path_is_absolute?('\\\\server\\the-share_name\\\\')
|
248
|
+
assert path_is_absolute?('\\\\server\\the-share_name\\dir')
|
249
|
+
assert path_is_absolute?('\\\\server\\the-share_name\\dir\\')
|
250
|
+
|
251
|
+
assert_false path_is_absolute?('\\\\101.2.303.4\\the-share_name')
|
252
|
+
assert path_is_absolute?('\\\\101.2.303.4\\the-share_name/')
|
253
|
+
assert path_is_absolute?('\\\\101.2.303.4\\the-share_name\\')
|
254
|
+
assert path_is_absolute?('\\\\101.2.303.4\\the-share_name\\\\')
|
255
|
+
assert path_is_absolute?('\\\\101.2.303.4\\the-share_name\\dir')
|
256
|
+
assert path_is_absolute?('\\\\101.2.303.4\\the-share_name\\dir\\')
|
257
|
+
|
258
|
+
assert_false path_is_absolute?('\\\\::1/128\\the-share_name')
|
259
|
+
assert path_is_absolute?('\\\\::1/128\\the-share_name/')
|
260
|
+
assert path_is_absolute?('\\\\::1/128\\the-share_name\\')
|
261
|
+
assert path_is_absolute?('\\\\::1/128\\the-share_name\\\\')
|
262
|
+
assert path_is_absolute?('\\\\::1/128\\the-share_name\\dir')
|
263
|
+
assert path_is_absolute?('\\\\::1/128\\the-share_name\\dir\\')
|
264
|
+
|
265
|
+
# form 4
|
266
|
+
|
267
|
+
assert_false path_is_absolute?('\\\\?\\server\\the-share_name')
|
268
|
+
assert path_is_absolute?('\\\\?\\server\\the-share_name/')
|
269
|
+
assert path_is_absolute?('\\\\?\\server\\the-share_name\\')
|
270
|
+
assert path_is_absolute?('\\\\?\\server\\the-share_name\\\\')
|
271
|
+
assert path_is_absolute?('\\\\?\\server\\the-share_name\\dir')
|
272
|
+
assert path_is_absolute?('\\\\?\\server\\the-share_name\\dir\\')
|
273
|
+
|
274
|
+
assert_false path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name')
|
275
|
+
assert path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name/')
|
276
|
+
assert path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name\\')
|
277
|
+
assert path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name\\\\')
|
278
|
+
assert path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name\\dir')
|
279
|
+
assert path_is_absolute?('\\\\?\\101.2.303.4\\the-share_name\\dir\\')
|
280
|
+
|
281
|
+
assert_false path_is_absolute?('\\\\?\\::1/128\\the-share_name')
|
282
|
+
assert path_is_absolute?('\\\\?\\::1/128\\the-share_name/')
|
283
|
+
assert path_is_absolute?('\\\\?\\::1/128\\the-share_name\\')
|
284
|
+
assert path_is_absolute?('\\\\?\\::1/128\\the-share_name\\\\')
|
285
|
+
assert path_is_absolute?('\\\\?\\::1/128\\the-share_name\\dir')
|
286
|
+
assert path_is_absolute?('\\\\?\\::1/128\\the-share_name\\dir\\')
|
287
|
+
|
288
|
+
# form 5
|
289
|
+
|
290
|
+
assert_false path_is_absolute?('\\\\?\\UNC\\server\\the-share_name')
|
291
|
+
assert path_is_absolute?('\\\\?\\UNC\\server\\the-share_name/')
|
292
|
+
assert path_is_absolute?('\\\\?\\UNC\\server\\the-share_name\\')
|
293
|
+
assert path_is_absolute?('\\\\?\\UNC\\server\\the-share_name\\\\')
|
294
|
+
assert path_is_absolute?('\\\\?\\UNC\\server\\the-share_name\\dir')
|
295
|
+
assert path_is_absolute?('\\\\?\\UNC\\server\\the-share_name\\dir\\')
|
296
|
+
|
297
|
+
assert_false path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name')
|
298
|
+
assert path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name/')
|
299
|
+
assert path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\')
|
300
|
+
assert path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\\\')
|
301
|
+
assert path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir')
|
302
|
+
assert path_is_absolute?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir\\')
|
303
|
+
|
304
|
+
assert_false path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name')
|
305
|
+
assert path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name/')
|
306
|
+
assert path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name\\')
|
307
|
+
assert path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name\\\\')
|
308
|
+
assert path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name\\dir')
|
309
|
+
assert path_is_absolute?('\\\\?\\UNC\\::1/128\\the-share_name\\dir\\')
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_absolute_paths_from_drive
|
313
|
+
|
314
|
+
# form 1
|
315
|
+
|
316
|
+
assert path_is_absolute?('C:\\')
|
317
|
+
assert path_is_absolute?('C:\\abc')
|
318
|
+
assert path_is_absolute?('C:\\abc\\')
|
319
|
+
|
320
|
+
assert_false path_is_absolute?('C:')
|
321
|
+
assert_false path_is_absolute?('C:abc')
|
322
|
+
assert_false path_is_absolute?('C:abc\\')
|
323
|
+
|
324
|
+
# form 3
|
325
|
+
|
326
|
+
assert path_is_absolute?('\\\\?\\C:\\')
|
327
|
+
assert path_is_absolute?('\\\\?\\C:\\abc')
|
328
|
+
assert path_is_absolute?('\\\\?\\C:\\abc\\')
|
329
|
+
|
330
|
+
assert_false path_is_absolute?('\\\\?\\C:')
|
331
|
+
assert_false path_is_absolute?('\\\\?\\C:abc')
|
332
|
+
assert_false path_is_absolute?('\\\\?\\C:abc\\')
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_absolute_paths_from_device
|
336
|
+
|
337
|
+
# form 6
|
338
|
+
|
339
|
+
assert_false path_is_absolute?('\\\\.\\')
|
340
|
+
assert_false path_is_absolute?('\\\\.\\{device-id}')
|
341
|
+
assert_false path_is_absolute?('\\\\.\\{device-id}/')
|
342
|
+
assert path_is_absolute?('\\\\.\\{device-id}\\')
|
343
|
+
assert path_is_absolute?('\\\\.\\{device-id}\\\\')
|
344
|
+
assert path_is_absolute?('\\\\.\\{device-id}\\dir')
|
345
|
+
assert path_is_absolute?('\\\\.\\{device-id}\\dir\\')
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_absolute_paths_from_root
|
349
|
+
|
350
|
+
assert_false path_is_absolute?('\\')
|
351
|
+
assert_false path_is_absolute?('\\\\')
|
352
|
+
assert_false path_is_absolute?('\\abc')
|
353
|
+
|
354
|
+
assert_false path_is_absolute?('/')
|
355
|
+
assert_false path_is_absolute?('//')
|
356
|
+
assert_false path_is_absolute?('/abc')
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_absolute_paths_from_home
|
360
|
+
|
361
|
+
assert path_is_absolute?('~')
|
362
|
+
assert path_is_absolute?('~/')
|
363
|
+
assert path_is_absolute?('~/abc')
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_relative_paths
|
367
|
+
|
368
|
+
assert_false path_is_absolute?('abc')
|
369
|
+
assert_false path_is_absolute?('abc/')
|
370
|
+
assert_false path_is_absolute?('a/')
|
371
|
+
|
372
|
+
assert_false path_is_absolute?('~abc')
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
class Test_path_is_homed_Windows < Test::Unit::TestCase
|
377
|
+
|
378
|
+
include ::LibPath::Form::Windows
|
379
|
+
|
380
|
+
if $DEBUG
|
381
|
+
|
382
|
+
def test_with_nil
|
383
|
+
|
384
|
+
assert_raise(::ArgumentError) { path_is_homed?(nil) }
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
def test_empty
|
389
|
+
|
390
|
+
assert_false path_is_homed?('')
|
391
|
+
end
|
392
|
+
|
393
|
+
def test_absolute_paths_from_UNC
|
394
|
+
|
395
|
+
assert_false path_is_homed?('\\\\')
|
396
|
+
assert_false path_is_homed?('\\\\server')
|
397
|
+
assert_false path_is_homed?('\\\\server\\')
|
398
|
+
assert_false path_is_homed?('\\\\server\\share')
|
399
|
+
|
400
|
+
assert_false path_is_homed?('\\\\server\\the-share_name\\')
|
401
|
+
assert_false path_is_homed?('\\\\server\\the-share_name\\\\')
|
402
|
+
assert_false path_is_homed?('\\\\server\\the-share_name\\dir')
|
403
|
+
assert_false path_is_homed?('\\\\server\\the-share_name\\dir\\')
|
404
|
+
|
405
|
+
assert_false path_is_homed?('\\\\101.2.303.4\\the-share_name\\')
|
406
|
+
assert_false path_is_homed?('\\\\101.2.303.4\\the-share_name\\\\')
|
407
|
+
assert_false path_is_homed?('\\\\101.2.303.4\\the-share_name\\dir')
|
408
|
+
assert_false path_is_homed?('\\\\101.2.303.4\\the-share_name\\dir\\')
|
409
|
+
|
410
|
+
assert_false path_is_homed?('\\\\::1/128\\the-share_name\\')
|
411
|
+
assert_false path_is_homed?('\\\\::1/128\\the-share_name\\\\')
|
412
|
+
assert_false path_is_homed?('\\\\::1/128\\the-share_name\\dir')
|
413
|
+
assert_false path_is_homed?('\\\\::1/128\\the-share_name\\dir\\')
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_absolute_paths_from_drive
|
417
|
+
|
418
|
+
assert_false path_is_homed?('C:\\')
|
419
|
+
assert_false path_is_homed?('C:\\abc')
|
420
|
+
assert_false path_is_homed?('C:\\abc\\')
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_absolute_paths_from_root
|
424
|
+
|
425
|
+
assert_false path_is_homed?('\\')
|
426
|
+
assert_false path_is_homed?('\\\\')
|
427
|
+
assert_false path_is_homed?('\\abc')
|
428
|
+
|
429
|
+
assert_false path_is_homed?('/')
|
430
|
+
assert_false path_is_homed?('//')
|
431
|
+
assert_false path_is_homed?('/abc')
|
432
|
+
end
|
433
|
+
|
434
|
+
def test_absolute_paths_from_home
|
435
|
+
|
436
|
+
assert path_is_homed?('~')
|
437
|
+
assert path_is_homed?('~/')
|
438
|
+
assert path_is_homed?('~/abc')
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_relative_paths
|
442
|
+
|
443
|
+
assert_false path_is_homed?('abc')
|
444
|
+
assert_false path_is_homed?('abc/')
|
445
|
+
assert_false path_is_homed?('a/')
|
446
|
+
|
447
|
+
assert_false path_is_homed?('~abc')
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
class Test_path_is_rooted_Windows < Test::Unit::TestCase
|
452
|
+
|
453
|
+
include ::LibPath::Form::Windows
|
454
|
+
|
455
|
+
if $DEBUG
|
456
|
+
|
457
|
+
def test_with_nil
|
458
|
+
|
459
|
+
assert_raise(::ArgumentError) { path_is_rooted?(nil) }
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_empty
|
464
|
+
|
465
|
+
assert_false path_is_rooted?('')
|
466
|
+
end
|
467
|
+
|
468
|
+
def test_absolute_paths_from_UNC
|
469
|
+
|
470
|
+
assert_false path_is_rooted?('\\\\')
|
471
|
+
|
472
|
+
assert_false path_is_rooted?('\\\\server')
|
473
|
+
assert_false path_is_rooted?('\\\\server\\')
|
474
|
+
|
475
|
+
# form 2
|
476
|
+
|
477
|
+
assert_false path_is_rooted?('\\\\server\\share')
|
478
|
+
assert path_is_rooted?('\\\\server\\share\\')
|
479
|
+
assert path_is_rooted?('\\\\server\\share/')
|
480
|
+
|
481
|
+
assert_false path_is_rooted?('\\\\server\\the-share_name')
|
482
|
+
assert path_is_rooted?('\\\\server\\the-share_name/')
|
483
|
+
assert path_is_rooted?('\\\\server\\the-share_name\\')
|
484
|
+
assert path_is_rooted?('\\\\server\\the-share_name\\\\')
|
485
|
+
assert path_is_rooted?('\\\\server\\the-share_name\\dir')
|
486
|
+
assert path_is_rooted?('\\\\server\\the-share_name\\dir\\')
|
487
|
+
|
488
|
+
assert_false path_is_rooted?('\\\\101.2.303.4\\the-share_name')
|
489
|
+
assert path_is_rooted?('\\\\101.2.303.4\\the-share_name/')
|
490
|
+
assert path_is_rooted?('\\\\101.2.303.4\\the-share_name\\')
|
491
|
+
assert path_is_rooted?('\\\\101.2.303.4\\the-share_name\\\\')
|
492
|
+
assert path_is_rooted?('\\\\101.2.303.4\\the-share_name\\dir')
|
493
|
+
assert path_is_rooted?('\\\\101.2.303.4\\the-share_name\\dir\\')
|
494
|
+
|
495
|
+
assert_false path_is_rooted?('\\\\::1/128\\the-share_name')
|
496
|
+
assert path_is_rooted?('\\\\::1/128\\the-share_name/')
|
497
|
+
assert path_is_rooted?('\\\\::1/128\\the-share_name\\')
|
498
|
+
assert path_is_rooted?('\\\\::1/128\\the-share_name\\\\')
|
499
|
+
assert path_is_rooted?('\\\\::1/128\\the-share_name\\dir')
|
500
|
+
assert path_is_rooted?('\\\\::1/128\\the-share_name\\dir\\')
|
501
|
+
|
502
|
+
# form 4
|
503
|
+
|
504
|
+
assert_false path_is_rooted?('\\\\?\\server\\the-share_name')
|
505
|
+
assert path_is_rooted?('\\\\?\\server\\the-share_name/')
|
506
|
+
assert path_is_rooted?('\\\\?\\server\\the-share_name\\')
|
507
|
+
assert path_is_rooted?('\\\\?\\server\\the-share_name\\\\')
|
508
|
+
assert path_is_rooted?('\\\\?\\server\\the-share_name\\dir')
|
509
|
+
assert path_is_rooted?('\\\\?\\server\\the-share_name\\dir\\')
|
510
|
+
|
511
|
+
assert_false path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name')
|
512
|
+
assert path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name/')
|
513
|
+
assert path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name\\')
|
514
|
+
assert path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name\\\\')
|
515
|
+
assert path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name\\dir')
|
516
|
+
assert path_is_rooted?('\\\\?\\101.2.303.4\\the-share_name\\dir\\')
|
517
|
+
|
518
|
+
assert_false path_is_rooted?('\\\\?\\::1/128\\the-share_name')
|
519
|
+
assert path_is_rooted?('\\\\?\\::1/128\\the-share_name/')
|
520
|
+
assert path_is_rooted?('\\\\?\\::1/128\\the-share_name\\')
|
521
|
+
assert path_is_rooted?('\\\\?\\::1/128\\the-share_name\\\\')
|
522
|
+
assert path_is_rooted?('\\\\?\\::1/128\\the-share_name\\dir')
|
523
|
+
assert path_is_rooted?('\\\\?\\::1/128\\the-share_name\\dir\\')
|
524
|
+
|
525
|
+
# form 5
|
526
|
+
|
527
|
+
assert_false path_is_rooted?('\\\\?\\UNC\\server\\the-share_name')
|
528
|
+
assert path_is_rooted?('\\\\?\\UNC\\server\\the-share_name/')
|
529
|
+
assert path_is_rooted?('\\\\?\\UNC\\server\\the-share_name\\')
|
530
|
+
assert path_is_rooted?('\\\\?\\UNC\\server\\the-share_name\\\\')
|
531
|
+
assert path_is_rooted?('\\\\?\\UNC\\server\\the-share_name\\dir')
|
532
|
+
assert path_is_rooted?('\\\\?\\UNC\\server\\the-share_name\\dir\\')
|
533
|
+
|
534
|
+
assert_false path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name')
|
535
|
+
assert path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name/')
|
536
|
+
assert path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\')
|
537
|
+
assert path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\\\')
|
538
|
+
assert path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir')
|
539
|
+
assert path_is_rooted?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir\\')
|
540
|
+
|
541
|
+
assert_false path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name')
|
542
|
+
assert path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name/')
|
543
|
+
assert path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name\\')
|
544
|
+
assert path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name\\\\')
|
545
|
+
assert path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name\\dir')
|
546
|
+
assert path_is_rooted?('\\\\?\\UNC\\::1/128\\the-share_name\\dir\\')
|
547
|
+
end
|
548
|
+
|
549
|
+
def test_absolute_paths_from_drive
|
550
|
+
|
551
|
+
# form 1
|
552
|
+
|
553
|
+
assert path_is_rooted?('C:\\')
|
554
|
+
assert path_is_rooted?('C:\\abc')
|
555
|
+
assert path_is_rooted?('C:\\abc\\')
|
556
|
+
|
557
|
+
assert_false path_is_rooted?('C:')
|
558
|
+
assert_false path_is_rooted?('C:abc')
|
559
|
+
assert_false path_is_rooted?('C:abc\\')
|
560
|
+
|
561
|
+
# form 3
|
562
|
+
|
563
|
+
assert path_is_rooted?('\\\\?\\C:\\')
|
564
|
+
assert path_is_rooted?('\\\\?\\C:\\abc')
|
565
|
+
assert path_is_rooted?('\\\\?\\C:\\abc\\')
|
566
|
+
|
567
|
+
assert_false path_is_rooted?('\\\\?\\C:')
|
568
|
+
assert_false path_is_rooted?('\\\\?\\C:abc')
|
569
|
+
assert_false path_is_rooted?('\\\\?\\C:abc\\')
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_absolute_paths_from_device
|
573
|
+
|
574
|
+
# form 6
|
575
|
+
|
576
|
+
assert_false path_is_rooted?('\\\\.\\')
|
577
|
+
assert_false path_is_rooted?('\\\\.\\{device-id}')
|
578
|
+
assert_false path_is_rooted?('\\\\.\\{device-id}/')
|
579
|
+
assert path_is_rooted?('\\\\.\\{device-id}\\')
|
580
|
+
assert path_is_rooted?('\\\\.\\{device-id}\\\\')
|
581
|
+
assert path_is_rooted?('\\\\.\\{device-id}\\dir')
|
582
|
+
assert path_is_rooted?('\\\\.\\{device-id}\\dir\\')
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_absolute_paths_from_root
|
586
|
+
|
587
|
+
assert path_is_rooted?('\\')
|
588
|
+
assert_false path_is_rooted?('\\\\')
|
589
|
+
assert path_is_rooted?('\\abc')
|
590
|
+
|
591
|
+
assert path_is_rooted?('/')
|
592
|
+
assert path_is_rooted?('//')
|
593
|
+
assert path_is_rooted?('/abc')
|
594
|
+
end
|
595
|
+
|
596
|
+
def test_absolute_paths_from_home
|
597
|
+
|
598
|
+
assert_false path_is_rooted?('~')
|
599
|
+
assert_false path_is_rooted?('~/')
|
600
|
+
assert_false path_is_rooted?('~/abc')
|
601
|
+
end
|
602
|
+
|
603
|
+
def test_relative_paths
|
604
|
+
|
605
|
+
assert_false path_is_rooted?('abc')
|
606
|
+
assert_false path_is_rooted?('abc/')
|
607
|
+
assert_false path_is_rooted?('a/')
|
608
|
+
|
609
|
+
assert_false path_is_rooted?('~abc')
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
613
|
+
class Test_path_is_UNC_Windows < Test::Unit::TestCase
|
614
|
+
|
615
|
+
include ::LibPath::Form::Windows
|
616
|
+
|
617
|
+
if $DEBUG
|
618
|
+
|
619
|
+
def test_with_nil
|
620
|
+
|
621
|
+
assert_raise(::ArgumentError) { path_is_UNC?(nil) }
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
def test_empty
|
626
|
+
|
627
|
+
assert_false path_is_UNC?('')
|
628
|
+
end
|
629
|
+
|
630
|
+
def test_absolute_paths_from_drive
|
631
|
+
|
632
|
+
assert_false path_is_UNC?('C:\\')
|
633
|
+
assert_false path_is_UNC?('C:\\\\')
|
634
|
+
assert_false path_is_UNC?('C:\\abc\\')
|
635
|
+
end
|
636
|
+
|
637
|
+
def test_absolute_paths_from_UNC
|
638
|
+
|
639
|
+
assert_false path_is_UNC?('\\\\')
|
640
|
+
|
641
|
+
# form 3
|
642
|
+
|
643
|
+
assert_false path_is_UNC?('\\\\?\\C')
|
644
|
+
assert path_is_UNC?('\\\\?\\C:')
|
645
|
+
assert path_is_UNC?('\\\\?\\C:\\')
|
646
|
+
assert path_is_UNC?('\\\\?\\C:\\\\')
|
647
|
+
assert path_is_UNC?('\\\\?\\C:\\abc\\')
|
648
|
+
assert path_is_UNC?('\\\\?\\C:\\abc/')
|
649
|
+
|
650
|
+
# form 2
|
651
|
+
|
652
|
+
assert_false path_is_UNC?('\\\\server')
|
653
|
+
assert_false path_is_UNC?('\\\\server\\')
|
654
|
+
|
655
|
+
assert path_is_UNC?('\\\\server\\share')
|
656
|
+
|
657
|
+
assert path_is_UNC?('\\\\server\\the-share_name')
|
658
|
+
assert path_is_UNC?('\\\\server\\the-share_name/')
|
659
|
+
assert path_is_UNC?('\\\\server\\the-share_name\\')
|
660
|
+
assert path_is_UNC?('\\\\server\\the-share_name\\\\')
|
661
|
+
assert path_is_UNC?('\\\\server\\the-share_name\\dir')
|
662
|
+
assert path_is_UNC?('\\\\server\\the-share_name\\dir\\')
|
663
|
+
|
664
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name')
|
665
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name/')
|
666
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name\\')
|
667
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name\\\\')
|
668
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name\\dir')
|
669
|
+
assert path_is_UNC?('\\\\101.2.303.4\\the-share_name\\dir\\')
|
670
|
+
|
671
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name')
|
672
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name/')
|
673
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name\\')
|
674
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name\\\\')
|
675
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name\\dir')
|
676
|
+
assert path_is_UNC?('\\\\::1/128\\the-share_name\\dir\\')
|
677
|
+
|
678
|
+
# form 4
|
679
|
+
|
680
|
+
assert_false path_is_UNC?('\\\\?\\server')
|
681
|
+
assert_false path_is_UNC?('\\\\?\\server\\')
|
682
|
+
|
683
|
+
assert path_is_UNC?('\\\\?\\server\\share')
|
684
|
+
|
685
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name')
|
686
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name/')
|
687
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name\\')
|
688
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name\\\\')
|
689
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name\\dir')
|
690
|
+
assert path_is_UNC?('\\\\?\\server\\the-share_name\\dir\\')
|
691
|
+
|
692
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name')
|
693
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name/')
|
694
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name\\')
|
695
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name\\\\')
|
696
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name\\dir')
|
697
|
+
assert path_is_UNC?('\\\\?\\101.2.303.4\\the-share_name\\dir\\')
|
698
|
+
|
699
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name')
|
700
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name/')
|
701
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name\\')
|
702
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name\\\\')
|
703
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name\\dir')
|
704
|
+
assert path_is_UNC?('\\\\?\\::1/128\\the-share_name\\dir\\')
|
705
|
+
|
706
|
+
# form 5
|
707
|
+
|
708
|
+
assert_false path_is_UNC?('\\\\?\\UNC\\server')
|
709
|
+
assert_false path_is_UNC?('\\\\?\\UNC\\server\\')
|
710
|
+
|
711
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\share')
|
712
|
+
|
713
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name')
|
714
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name/')
|
715
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name\\')
|
716
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name\\\\')
|
717
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name\\dir')
|
718
|
+
assert path_is_UNC?('\\\\?\\UNC\\server\\the-share_name\\dir\\')
|
719
|
+
|
720
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name')
|
721
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name/')
|
722
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\')
|
723
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\\\')
|
724
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir')
|
725
|
+
assert path_is_UNC?('\\\\?\\UNC\\101.2.303.4\\the-share_name\\dir\\')
|
726
|
+
|
727
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name')
|
728
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name/')
|
729
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name\\')
|
730
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name\\\\')
|
731
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name\\dir')
|
732
|
+
assert path_is_UNC?('\\\\?\\UNC\\::1/128\\the-share_name\\dir\\')
|
733
|
+
|
734
|
+
# form 6
|
735
|
+
|
736
|
+
assert_false path_is_UNC?('\\\\.\\')
|
737
|
+
|
738
|
+
assert path_is_UNC?('\\\\.\\{device-id}\\')
|
739
|
+
assert path_is_UNC?('\\\\.\\{device-id}\\\\')
|
740
|
+
assert path_is_UNC?('\\\\.\\{device-id}\\dir')
|
741
|
+
assert path_is_UNC?('\\\\.\\{device-id}\\dir\\')
|
742
|
+
end
|
743
|
+
|
744
|
+
def test_absolute_paths_from_root
|
745
|
+
|
746
|
+
assert_false path_is_UNC?('\\')
|
747
|
+
assert_false path_is_UNC?('\\\\')
|
748
|
+
assert_false path_is_UNC?('\\abc')
|
749
|
+
|
750
|
+
assert_false path_is_UNC?('/')
|
751
|
+
assert_false path_is_UNC?('//')
|
752
|
+
assert_false path_is_UNC?('/abc')
|
753
|
+
end
|
754
|
+
|
755
|
+
def test_absolute_paths_from_home
|
756
|
+
|
757
|
+
assert_false path_is_UNC?('~')
|
758
|
+
assert_false path_is_UNC?('~/')
|
759
|
+
assert_false path_is_UNC?('~/abc')
|
760
|
+
end
|
761
|
+
|
762
|
+
def test_relative_paths
|
763
|
+
|
764
|
+
assert_false path_is_UNC?('abc')
|
765
|
+
assert_false path_is_UNC?('abc/')
|
766
|
+
assert_false path_is_UNC?('a/')
|
767
|
+
|
768
|
+
assert_false path_is_UNC?('~abc')
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
class Test_path_is_letter_drived_Windows < Test::Unit::TestCase
|
773
|
+
|
774
|
+
include ::LibPath::Form::Windows
|
775
|
+
|
776
|
+
if $DEBUG
|
777
|
+
|
778
|
+
def test_with_nil
|
779
|
+
|
780
|
+
assert_raise(::ArgumentError) { path_is_letter_drived?(nil) }
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
784
|
+
def test_empty
|
785
|
+
|
786
|
+
assert_nil path_is_letter_drived?('')
|
787
|
+
end
|
788
|
+
|
789
|
+
def test_absolute_paths_from_drive
|
790
|
+
|
791
|
+
assert_equal 2, path_is_letter_drived?('C:')
|
792
|
+
assert_equal 3, path_is_letter_drived?('C:\\')
|
793
|
+
assert_equal 3, path_is_letter_drived?('C:/')
|
794
|
+
assert_equal 3, path_is_letter_drived?('C:\\\\')
|
795
|
+
assert_equal 3, path_is_letter_drived?('C:\\abc\\')
|
796
|
+
|
797
|
+
assert_equal 6, path_is_letter_drived?('\\\\?\\C:')
|
798
|
+
assert_equal 7, path_is_letter_drived?('\\\\?\\C:\\')
|
799
|
+
assert_equal 7, path_is_letter_drived?('\\\\?\\C:/')
|
800
|
+
assert_equal 7, path_is_letter_drived?('\\\\?\\C:\\\\')
|
801
|
+
assert_equal 7, path_is_letter_drived?('\\\\?\\C:\\abc\\')
|
802
|
+
end
|
803
|
+
|
804
|
+
def test_absolute_paths_from_other_UNC
|
805
|
+
|
806
|
+
assert_nil path_is_letter_drived?('\\\\')
|
807
|
+
assert_nil path_is_letter_drived?('\\\\server')
|
808
|
+
assert_nil path_is_letter_drived?('\\\\server\\')
|
809
|
+
assert_nil path_is_letter_drived?('\\\\server\\share')
|
810
|
+
|
811
|
+
assert_nil path_is_letter_drived?('\\\\server\\the-share_name\\')
|
812
|
+
assert_nil path_is_letter_drived?('\\\\server\\the-share_name\\\\')
|
813
|
+
assert_nil path_is_letter_drived?('\\\\server\\the-share_name\\dir')
|
814
|
+
assert_nil path_is_letter_drived?('\\\\server\\the-share_name\\dir\\')
|
815
|
+
|
816
|
+
assert_nil path_is_letter_drived?('\\\\101.2.303.4\\the-share_name\\')
|
817
|
+
assert_nil path_is_letter_drived?('\\\\101.2.303.4\\the-share_name\\\\')
|
818
|
+
assert_nil path_is_letter_drived?('\\\\101.2.303.4\\the-share_name\\dir')
|
819
|
+
assert_nil path_is_letter_drived?('\\\\101.2.303.4\\the-share_name\\dir\\')
|
820
|
+
|
821
|
+
assert_nil path_is_letter_drived?('\\\\::1/128\\the-share_name\\')
|
822
|
+
assert_nil path_is_letter_drived?('\\\\::1/128\\the-share_name\\\\')
|
823
|
+
assert_nil path_is_letter_drived?('\\\\::1/128\\the-share_name\\dir')
|
824
|
+
assert_nil path_is_letter_drived?('\\\\::1/128\\the-share_name\\dir\\')
|
825
|
+
end
|
826
|
+
|
827
|
+
def test_absolute_paths_from_root
|
828
|
+
|
829
|
+
assert_nil path_is_letter_drived?('\\')
|
830
|
+
assert_nil path_is_letter_drived?('\\\\')
|
831
|
+
assert_nil path_is_letter_drived?('\\abc')
|
832
|
+
|
833
|
+
assert_nil path_is_letter_drived?('/')
|
834
|
+
assert_nil path_is_letter_drived?('//')
|
835
|
+
assert_nil path_is_letter_drived?('/abc')
|
836
|
+
end
|
837
|
+
|
838
|
+
def test_absolute_paths_from_home
|
839
|
+
|
840
|
+
assert_nil path_is_letter_drived?('~')
|
841
|
+
assert_nil path_is_letter_drived?('~/')
|
842
|
+
assert_nil path_is_letter_drived?('~/abc')
|
843
|
+
end
|
844
|
+
|
845
|
+
def test_relative_paths
|
846
|
+
|
847
|
+
assert_nil path_is_letter_drived?('abc')
|
848
|
+
assert_nil path_is_letter_drived?('abc/')
|
849
|
+
assert_nil path_is_letter_drived?('a/')
|
850
|
+
|
851
|
+
assert_nil path_is_letter_drived?('~abc')
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|