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