libpath-ruby 0.2.2 → 0.2.2.1
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 +71 -71
- data/lib/libpath/constants/windows.rb +72 -72
- data/lib/libpath/constants.rb +18 -19
- data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
- data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +104 -103
- data/lib/libpath/form/windows.rb +200 -199
- data/lib/libpath/form.rb +18 -18
- data/lib/libpath/internal_/array.rb +53 -53
- data/lib/libpath/internal_/platform.rb +24 -24
- data/lib/libpath/internal_/string.rb +18 -18
- data/lib/libpath/internal_/unix/form.rb +116 -116
- data/lib/libpath/internal_/windows/drive.rb +59 -59
- data/lib/libpath/internal_/windows/form.rb +189 -189
- data/lib/libpath/libpath.rb +3 -0
- data/lib/libpath/path/unix.rb +114 -112
- data/lib/libpath/path/windows.rb +120 -118
- data/lib/libpath/path.rb +18 -20
- data/lib/libpath/util/unix.rb +258 -258
- data/lib/libpath/util/windows.rb +400 -400
- data/lib/libpath/util.rb +18 -19
- data/lib/libpath/version.rb +23 -24
- 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
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'libpath/path/windows'
|
6
7
|
|
7
8
|
require 'test/unit'
|
@@ -10,621 +11,625 @@ require 'xqsr3/extensions/test/unit'
|
|
10
11
|
|
11
12
|
require 'libpath/internal_/platform'
|
12
13
|
|
14
|
+
|
13
15
|
class Test_existence_of_namespace_LibPath_Path_Windows < Test::Unit::TestCase
|
14
16
|
|
15
|
-
|
17
|
+
def test_LibPath_module_exists
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
assert defined?(::LibPath)
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
def test_LibPath_Path_module_exists
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
assert defined?(::LibPath::Path)
|
25
|
+
end
|
24
26
|
|
25
|
-
|
27
|
+
def test_LibPath_Path_Windows_module_exists
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
assert defined?(::LibPath::Path::Windows)
|
30
|
+
end
|
29
31
|
|
30
|
-
|
32
|
+
def test_LibPath_Path_Windows_ParsedPath_class_exists
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
assert defined?(::LibPath::Path::Windows::ParsedPath)
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
class Test_LibPath_Path_Windows_ParsedPath < Test::Unit::TestCase
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
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
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
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
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
40
|
+
include ::LibPath::Path::Windows
|
41
|
+
|
42
|
+
def test_nil
|
43
|
+
|
44
|
+
assert_raise(::ArgumentError) { ParsedPath.new(nil) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_empty
|
48
|
+
|
49
|
+
assert_raise(::ArgumentError) { ParsedPath.new('') }
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_root
|
53
|
+
|
54
|
+
pp = ParsedPath.new('C:\\')
|
55
|
+
|
56
|
+
assert_equal 'C:\\', pp.given_path
|
57
|
+
assert_equal 'C:\\', pp.absolute_path
|
58
|
+
assert_equal 'C:\\', pp.compare_path
|
59
|
+
assert_equal 'C:', pp.volume
|
60
|
+
assert_equal '\\', pp.directory
|
61
|
+
assert_equal 'C:\\', pp.directory_path
|
62
|
+
assert_equal 'C:\\', pp.dirname
|
63
|
+
assert_equal [ '\\' ], pp.directory_parts
|
64
|
+
assert_nil pp.file_full_name
|
65
|
+
assert_nil pp.basename
|
66
|
+
assert_nil pp.file_name_only
|
67
|
+
assert_nil pp.stem
|
68
|
+
assert_nil pp.file_extension
|
69
|
+
assert_nil pp.extension
|
70
|
+
assert_nil pp.search_directory
|
71
|
+
assert_nil pp.search_relative_path
|
72
|
+
assert_nil pp.search_relative_directory_path
|
73
|
+
assert_nil pp.search_relative_directory_parts
|
74
|
+
|
75
|
+
assert_equal pp.directory, pp.directory_parts.join
|
76
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_root_lower_drive_letter
|
80
|
+
|
81
|
+
pp = ParsedPath.new('c:\\')
|
82
|
+
|
83
|
+
assert_equal 'c:\\', pp.given_path
|
84
|
+
assert_equal 'c:\\', pp.absolute_path
|
85
|
+
assert_equal 'C:\\', pp.compare_path
|
86
|
+
assert_equal 'c:', pp.volume
|
87
|
+
assert_equal '\\', pp.directory
|
88
|
+
assert_equal 'c:\\', pp.directory_path
|
89
|
+
assert_equal 'c:\\', pp.dirname
|
90
|
+
assert_equal [ '\\' ], pp.directory_parts
|
91
|
+
assert_nil pp.file_full_name
|
92
|
+
assert_nil pp.basename
|
93
|
+
assert_nil pp.file_name_only
|
94
|
+
assert_nil pp.stem
|
95
|
+
assert_nil pp.file_extension
|
96
|
+
assert_nil pp.extension
|
97
|
+
assert_nil pp.search_directory
|
98
|
+
assert_nil pp.search_relative_path
|
99
|
+
assert_nil pp.search_relative_directory_path
|
100
|
+
assert_nil pp.search_relative_directory_parts
|
101
|
+
|
102
|
+
assert_equal pp.directory, pp.directory_parts.join
|
103
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_root_from_srd_1
|
107
|
+
|
108
|
+
srd = 'C:/dir-1/dir-2'
|
109
|
+
|
110
|
+
pp = ParsedPath.new('C:\\', srd)
|
111
|
+
|
112
|
+
assert_equal 'C:\\', pp.given_path
|
113
|
+
assert_equal 'C:\\', pp.absolute_path
|
114
|
+
assert_equal 'C:\\', pp.compare_path
|
115
|
+
assert_equal 'C:', pp.volume
|
116
|
+
assert_equal '\\', pp.directory
|
117
|
+
assert_equal 'C:\\', pp.directory_path
|
118
|
+
assert_equal 'C:\\', pp.dirname
|
119
|
+
assert_equal [ '\\' ], pp.directory_parts
|
120
|
+
assert_nil pp.file_full_name
|
121
|
+
assert_nil pp.basename
|
122
|
+
assert_nil pp.file_name_only
|
123
|
+
assert_nil pp.stem
|
124
|
+
assert_nil pp.file_extension
|
125
|
+
assert_nil pp.extension
|
126
|
+
assert_equal 'C:\\dir-1\\dir-2\\', pp.search_directory
|
127
|
+
assert_equal '..\\..\\', pp.search_relative_path
|
128
|
+
assert_equal '..\\..\\', pp.search_relative_directory_path
|
129
|
+
assert_equal [ '..\\', '..\\' ], pp.search_relative_directory_parts
|
130
|
+
|
131
|
+
assert_equal pp.directory, pp.directory_parts.join
|
132
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_root_UNC_form2
|
136
|
+
|
137
|
+
pp = ParsedPath.new('\\\\server\\share\\')
|
138
|
+
|
139
|
+
assert_equal '\\\\server\\share\\', pp.given_path
|
140
|
+
assert_equal '\\\\server\\share\\', pp.absolute_path
|
141
|
+
assert_equal '\\\\server\\share\\', pp.compare_path
|
142
|
+
assert_equal '\\\\server\\share', pp.volume
|
143
|
+
assert_equal '\\', pp.directory
|
144
|
+
assert_equal '\\\\server\\share\\', pp.directory_path
|
145
|
+
assert_equal '\\\\server\\share\\', pp.dirname
|
146
|
+
assert_equal [ '\\' ], pp.directory_parts
|
147
|
+
assert_nil pp.file_full_name
|
148
|
+
assert_nil pp.basename
|
149
|
+
assert_nil pp.file_name_only
|
150
|
+
assert_nil pp.stem
|
151
|
+
assert_nil pp.file_extension
|
152
|
+
assert_nil pp.extension
|
153
|
+
assert_nil pp.search_directory
|
154
|
+
assert_nil pp.search_relative_path
|
155
|
+
assert_nil pp.search_relative_directory_path
|
156
|
+
assert_nil pp.search_relative_directory_parts
|
157
|
+
|
158
|
+
assert_equal pp.directory, pp.directory_parts.join
|
159
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_root_UNC_form3
|
163
|
+
|
164
|
+
pp = ParsedPath.new('\\\\?\\C:\\')
|
165
|
+
|
166
|
+
assert_equal '\\\\?\\C:\\', pp.given_path
|
167
|
+
assert_equal '\\\\?\\C:\\', pp.absolute_path
|
168
|
+
assert_equal '\\\\?\\C:\\', pp.compare_path
|
169
|
+
assert_equal '\\\\?\\C:', pp.volume
|
170
|
+
assert_equal '\\', pp.directory
|
171
|
+
assert_equal '\\\\?\\C:\\', pp.directory_path
|
172
|
+
assert_equal '\\\\?\\C:\\', pp.dirname
|
173
|
+
assert_equal [ '\\' ], pp.directory_parts
|
174
|
+
assert_nil pp.file_full_name
|
175
|
+
assert_nil pp.basename
|
176
|
+
assert_nil pp.file_name_only
|
177
|
+
assert_nil pp.stem
|
178
|
+
assert_nil pp.file_extension
|
179
|
+
assert_nil pp.extension
|
180
|
+
assert_nil pp.search_directory
|
181
|
+
assert_nil pp.search_relative_path
|
182
|
+
assert_nil pp.search_relative_directory_path
|
183
|
+
assert_nil pp.search_relative_directory_parts
|
184
|
+
|
185
|
+
assert_equal pp.directory, pp.directory_parts.join
|
186
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_root_UNC_form4
|
190
|
+
|
191
|
+
pp = ParsedPath.new('\\\\?\\server\\share\\')
|
192
|
+
|
193
|
+
assert_equal '\\\\?\\server\\share\\', pp.given_path
|
194
|
+
assert_equal '\\\\?\\server\\share\\', pp.absolute_path
|
195
|
+
assert_equal '\\\\?\\server\\share\\', pp.compare_path
|
196
|
+
assert_equal '\\\\?\\server\\share', pp.volume
|
197
|
+
assert_equal '\\', pp.directory
|
198
|
+
assert_equal '\\\\?\\server\\share\\', pp.directory_path
|
199
|
+
assert_equal '\\\\?\\server\\share\\', pp.dirname
|
200
|
+
assert_equal [ '\\' ], pp.directory_parts
|
201
|
+
assert_nil pp.file_full_name
|
202
|
+
assert_nil pp.basename
|
203
|
+
assert_nil pp.file_name_only
|
204
|
+
assert_nil pp.stem
|
205
|
+
assert_nil pp.file_extension
|
206
|
+
assert_nil pp.extension
|
207
|
+
assert_nil pp.search_directory
|
208
|
+
assert_nil pp.search_relative_path
|
209
|
+
assert_nil pp.search_relative_directory_path
|
210
|
+
assert_nil pp.search_relative_directory_parts
|
211
|
+
|
212
|
+
assert_equal pp.directory, pp.directory_parts.join
|
213
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_root_UNC_form5
|
217
|
+
|
218
|
+
pp = ParsedPath.new('\\\\?\\UNC\\server\\share\\')
|
219
|
+
|
220
|
+
assert_equal '\\\\?\\UNC\\server\\share\\', pp.given_path
|
221
|
+
assert_equal '\\\\?\\UNC\\server\\share\\', pp.absolute_path
|
222
|
+
assert_equal '\\\\?\\UNC\\server\\share\\', pp.compare_path
|
223
|
+
assert_equal '\\\\?\\UNC\\server\\share', pp.volume
|
224
|
+
assert_equal '\\', pp.directory
|
225
|
+
assert_equal '\\\\?\\UNC\\server\\share\\', pp.directory_path
|
226
|
+
assert_equal '\\\\?\\UNC\\server\\share\\', pp.dirname
|
227
|
+
assert_equal [ '\\' ], pp.directory_parts
|
228
|
+
assert_nil pp.file_full_name
|
229
|
+
assert_nil pp.basename
|
230
|
+
assert_nil pp.file_name_only
|
231
|
+
assert_nil pp.stem
|
232
|
+
assert_nil pp.file_extension
|
233
|
+
assert_nil pp.extension
|
234
|
+
assert_nil pp.search_directory
|
235
|
+
assert_nil pp.search_relative_path
|
236
|
+
assert_nil pp.search_relative_directory_path
|
237
|
+
assert_nil pp.search_relative_directory_parts
|
238
|
+
|
239
|
+
assert_equal pp.directory, pp.directory_parts.join
|
240
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_root_UNC_form6
|
244
|
+
|
245
|
+
pp = ParsedPath.new('\\\\.\\{some-device-id}\\')
|
246
|
+
|
247
|
+
assert_equal '\\\\.\\{some-device-id}\\', pp.given_path
|
248
|
+
assert_equal '\\\\.\\{some-device-id}\\', pp.absolute_path
|
249
|
+
assert_equal '\\\\.\\{some-device-id}\\', pp.compare_path
|
250
|
+
assert_equal '\\\\.\\{some-device-id}', pp.volume
|
251
|
+
assert_equal '\\', pp.directory
|
252
|
+
assert_equal '\\\\.\\{some-device-id}\\', pp.directory_path
|
253
|
+
assert_equal '\\\\.\\{some-device-id}\\', pp.dirname
|
254
|
+
assert_equal [ '\\' ], pp.directory_parts
|
255
|
+
assert_nil pp.file_full_name
|
256
|
+
assert_nil pp.basename
|
257
|
+
assert_nil pp.file_name_only
|
258
|
+
assert_nil pp.stem
|
259
|
+
assert_nil pp.file_extension
|
260
|
+
assert_nil pp.extension
|
261
|
+
assert_nil pp.search_directory
|
262
|
+
assert_nil pp.search_relative_path
|
263
|
+
assert_nil pp.search_relative_directory_path
|
264
|
+
assert_nil pp.search_relative_directory_parts
|
265
|
+
|
266
|
+
assert_equal pp.directory, pp.directory_parts.join
|
267
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_rooted_one_dir
|
271
|
+
|
272
|
+
pp = ParsedPath.new('G:\\\\abc\\\\')
|
273
|
+
|
274
|
+
assert_equal 'G:\\\\abc\\\\', pp.given_path
|
275
|
+
assert_equal 'G:\\abc\\', pp.absolute_path
|
276
|
+
assert_equal 'G:\\ABC\\', pp.compare_path
|
277
|
+
assert_equal '\\abc\\', pp.directory
|
278
|
+
assert_equal 'G:', pp.volume
|
279
|
+
assert_equal 'G:\\abc\\', pp.directory_path
|
280
|
+
assert_equal 'G:\\abc\\', pp.dirname
|
281
|
+
assert_equal [ '\\', 'abc\\' ], pp.directory_parts
|
282
|
+
assert_nil pp.file_full_name
|
283
|
+
assert_nil pp.basename
|
284
|
+
assert_nil pp.file_name_only
|
285
|
+
assert_nil pp.stem
|
286
|
+
assert_nil pp.file_extension
|
287
|
+
assert_nil pp.extension
|
288
|
+
assert_nil pp.search_directory
|
289
|
+
assert_nil pp.search_relative_path
|
290
|
+
assert_nil pp.search_relative_directory_path
|
291
|
+
assert_nil pp.search_relative_directory_parts
|
292
|
+
|
293
|
+
assert_equal pp.directory, pp.directory_parts.join
|
294
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_rooted_one_dir_with_trailing_dot
|
298
|
+
|
299
|
+
pp = ParsedPath.new('G:\\abc\\.')
|
300
|
+
|
301
|
+
assert_equal 'G:\\abc\\.', pp.given_path
|
302
|
+
assert_equal 'G:\\abc\\', pp.absolute_path
|
303
|
+
assert_equal 'G:\\ABC\\', pp.compare_path
|
304
|
+
assert_equal 'G:', pp.volume
|
305
|
+
assert_equal '\\abc\\', pp.directory
|
306
|
+
assert_equal 'G:\\abc\\', pp.directory_path
|
307
|
+
assert_equal 'G:\\abc\\', pp.dirname
|
308
|
+
assert_equal [ '\\', 'abc\\' ], pp.directory_parts
|
309
|
+
assert_nil pp.file_full_name
|
310
|
+
assert_nil pp.basename
|
311
|
+
assert_nil pp.file_name_only
|
312
|
+
assert_nil pp.stem
|
313
|
+
assert_nil pp.file_extension
|
314
|
+
assert_nil pp.extension
|
315
|
+
assert_nil pp.search_directory
|
316
|
+
assert_nil pp.search_relative_path
|
317
|
+
assert_nil pp.search_relative_directory_path
|
318
|
+
assert_nil pp.search_relative_directory_parts
|
319
|
+
|
320
|
+
assert_equal pp.directory, pp.directory_parts.join
|
321
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_rooted_one_file
|
325
|
+
|
326
|
+
pp = ParsedPath.new('G:\\file.ext')
|
327
|
+
|
328
|
+
assert_equal 'G:\\file.ext', pp.given_path
|
329
|
+
assert_equal 'G:\\file.ext', pp.absolute_path
|
330
|
+
assert_equal 'G:\\FILE.EXT', pp.compare_path
|
331
|
+
assert_equal 'G:', pp.volume
|
332
|
+
assert_equal '\\', pp.directory
|
333
|
+
assert_equal 'G:\\', pp.directory_path
|
334
|
+
assert_equal 'G:\\', pp.dirname
|
335
|
+
assert_equal [ '\\' ], pp.directory_parts
|
336
|
+
assert_equal 'file.ext', pp.file_full_name
|
337
|
+
assert_equal 'file.ext', pp.basename
|
338
|
+
assert_equal 'file', pp.file_name_only
|
339
|
+
assert_equal 'file', pp.stem
|
340
|
+
assert_equal '.ext', pp.file_extension
|
341
|
+
assert_equal '.ext', pp.extension
|
342
|
+
assert_nil pp.search_directory
|
343
|
+
assert_nil pp.search_relative_path
|
344
|
+
assert_nil pp.search_relative_directory_path
|
345
|
+
assert_nil pp.search_relative_directory_parts
|
346
|
+
|
347
|
+
assert_equal pp.directory, pp.directory_parts.join
|
348
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_rooted_one_file_without_extension
|
352
|
+
|
353
|
+
pp = ParsedPath.new('G:\\file')
|
354
|
+
|
355
|
+
assert_equal 'G:\\file', pp.given_path
|
356
|
+
assert_equal 'G:\\file', pp.absolute_path
|
357
|
+
assert_equal 'G:\\FILE', pp.compare_path
|
358
|
+
assert_equal 'G:', pp.volume
|
359
|
+
assert_equal '\\', pp.directory
|
360
|
+
assert_equal 'G:\\', pp.directory_path
|
361
|
+
assert_equal 'G:\\', pp.dirname
|
362
|
+
assert_equal [ '\\' ], pp.directory_parts
|
363
|
+
assert_equal 'file', pp.file_full_name
|
364
|
+
assert_equal 'file', pp.basename
|
365
|
+
assert_equal 'file', pp.file_name_only
|
366
|
+
assert_equal 'file', pp.stem
|
367
|
+
assert_nil pp.file_extension
|
368
|
+
assert_nil pp.extension
|
369
|
+
assert_nil pp.search_directory
|
370
|
+
assert_nil pp.search_relative_path
|
371
|
+
assert_nil pp.search_relative_directory_path
|
372
|
+
assert_nil pp.search_relative_directory_parts
|
373
|
+
|
374
|
+
assert_equal pp.directory, pp.directory_parts.join
|
375
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
376
|
+
end
|
377
|
+
|
378
|
+
def test_rooted_one_file_without_stem
|
379
|
+
|
380
|
+
pp = ParsedPath.new('H:\\.ext')
|
381
|
+
|
382
|
+
assert_equal 'H:\\.ext', pp.given_path
|
383
|
+
assert_equal 'H:\\.ext', pp.absolute_path
|
384
|
+
assert_equal 'H:\\.EXT', pp.compare_path
|
385
|
+
assert_equal 'H:', pp.volume
|
386
|
+
assert_equal '\\', pp.directory
|
387
|
+
assert_equal 'H:\\', pp.directory_path
|
388
|
+
assert_equal 'H:\\', pp.dirname
|
389
|
+
assert_equal [ '\\' ], pp.directory_parts
|
390
|
+
assert_equal '.ext', pp.file_full_name
|
391
|
+
assert_equal '.ext', pp.basename
|
392
|
+
assert_nil pp.file_name_only
|
393
|
+
assert_nil pp.stem
|
394
|
+
assert_equal '.ext', pp.file_extension
|
395
|
+
assert_equal '.ext', pp.extension
|
396
|
+
assert_nil pp.search_directory
|
397
|
+
assert_nil pp.search_relative_path
|
398
|
+
assert_nil pp.search_relative_directory_path
|
399
|
+
assert_nil pp.search_relative_directory_parts
|
400
|
+
|
401
|
+
assert_equal pp.directory, pp.directory_parts.join
|
402
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
403
|
+
end
|
404
|
+
|
405
|
+
def test_rooted_one_long_path
|
406
|
+
|
407
|
+
pp = ParsedPath.new('C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext')
|
408
|
+
|
409
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pp.given_path
|
410
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.absolute_path
|
411
|
+
assert_equal 'C:/DIR-1/DIR-2/DIR-3/DIR-4/DIR-5/FILE.EXT', pp.compare_path
|
412
|
+
assert_equal 'C:', pp.volume
|
413
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory
|
414
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory_path
|
415
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.dirname
|
416
|
+
assert_equal [ '/', 'dir-1/', 'dir-2/', 'dir-3/', 'dir-4/', 'dir-5/' ], pp.directory_parts
|
417
|
+
assert_equal 'file.ext', pp.file_full_name
|
418
|
+
assert_equal 'file.ext', pp.basename
|
419
|
+
assert_equal 'file', pp.file_name_only
|
420
|
+
assert_equal 'file', pp.stem
|
421
|
+
assert_equal '.ext', pp.file_extension
|
422
|
+
assert_equal '.ext', pp.extension
|
423
|
+
assert_nil pp.search_directory
|
424
|
+
assert_nil pp.search_relative_path
|
425
|
+
assert_nil pp.search_relative_directory_path
|
426
|
+
assert_nil pp.search_relative_directory_parts
|
427
|
+
|
428
|
+
assert_equal pp.directory, pp.directory_parts.join
|
429
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_rooted_one_long_path_from_srd1
|
433
|
+
|
434
|
+
srd = 'C:\\dir-1\\dir-2\\dir-C\\dir-D'
|
435
|
+
pp = ParsedPath.new('C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', srd)
|
436
|
+
|
437
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pp.given_path
|
438
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.absolute_path
|
439
|
+
assert_equal 'C:/DIR-1/DIR-2/DIR-3/DIR-4/DIR-5/FILE.EXT', pp.compare_path
|
440
|
+
assert_equal 'C:', pp.volume
|
441
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory
|
442
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory_path
|
443
|
+
assert_equal 'C:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.dirname
|
444
|
+
assert_equal [ '/', 'dir-1/', 'dir-2/', 'dir-3/', 'dir-4/', 'dir-5/' ], pp.directory_parts
|
445
|
+
assert_equal 'file.ext', pp.file_full_name
|
446
|
+
assert_equal 'file.ext', pp.basename
|
447
|
+
assert_equal 'file', pp.file_name_only
|
448
|
+
assert_equal 'file', pp.stem
|
449
|
+
assert_equal '.ext', pp.file_extension
|
450
|
+
assert_equal '.ext', pp.extension
|
451
|
+
assert_equal 'C:\\dir-1\\dir-2\\dir-C\\dir-D\\', pp.search_directory
|
452
|
+
assert_equal '..\\..\\dir-3\\dir-4\\dir-5\\file.ext', pp.search_relative_path
|
453
|
+
assert_equal '..\\..\\dir-3\\dir-4\\dir-5\\', pp.search_relative_directory_path
|
454
|
+
assert_equal [ '..\\', '..\\', 'dir-3\\', 'dir-4\\', 'dir-5\\' ], pp.search_relative_directory_parts
|
455
|
+
|
456
|
+
assert_equal pp.directory, pp.directory_parts.join
|
457
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
458
|
+
end
|
459
|
+
|
460
|
+
def test_rooted_one_long_path_missing_volume
|
461
|
+
|
462
|
+
pp = ParsedPath.new('/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pwd: 'D:\\')
|
463
|
+
|
464
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/./dir-5/dir-6/../file.ext', pp.given_path
|
465
|
+
assert_equal 'D:/dir-1/dir-2/dir-3/dir-4/dir-5/file.ext', pp.absolute_path
|
466
|
+
assert_equal 'D:/DIR-1/DIR-2/DIR-3/DIR-4/DIR-5/FILE.EXT', pp.compare_path
|
467
|
+
assert_equal 'D:', pp.volume
|
468
|
+
assert_equal '/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory
|
469
|
+
assert_equal 'D:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.directory_path
|
470
|
+
assert_equal 'D:/dir-1/dir-2/dir-3/dir-4/dir-5/', pp.dirname
|
471
|
+
assert_equal [ '/', 'dir-1/', 'dir-2/', 'dir-3/', 'dir-4/', 'dir-5/' ], pp.directory_parts
|
472
|
+
assert_equal 'file.ext', pp.file_full_name
|
473
|
+
assert_equal 'file.ext', pp.basename
|
474
|
+
assert_equal 'file', pp.file_name_only
|
475
|
+
assert_equal 'file', pp.stem
|
476
|
+
assert_equal '.ext', pp.file_extension
|
477
|
+
assert_equal '.ext', pp.extension
|
478
|
+
assert_nil pp.search_directory
|
479
|
+
assert_nil pp.search_relative_path
|
480
|
+
assert_nil pp.search_relative_directory_path
|
481
|
+
assert_nil pp.search_relative_directory_parts
|
482
|
+
|
483
|
+
assert_equal pp.directory, pp.directory_parts.join
|
484
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_rooted_one_long_path_with_short_directory_names
|
488
|
+
|
489
|
+
pp = ParsedPath.new('C:/1/2/3/4/./5/6/../file.ext')
|
490
|
+
|
491
|
+
assert_equal 'C:/1/2/3/4/./5/6/../file.ext', pp.given_path
|
492
|
+
assert_equal 'C:/1/2/3/4/5/file.ext', pp.absolute_path
|
493
|
+
assert_equal 'C:/1/2/3/4/5/FILE.EXT', pp.compare_path
|
494
|
+
assert_equal 'C:', pp.volume
|
495
|
+
assert_equal '/1/2/3/4/5/', pp.directory
|
496
|
+
assert_equal 'C:/1/2/3/4/5/', pp.directory_path
|
497
|
+
assert_equal 'C:/1/2/3/4/5/', pp.dirname
|
498
|
+
assert_equal [ '/', '1/', '2/', '3/', '4/', '5/' ], pp.directory_parts
|
499
|
+
assert_equal 'file.ext', pp.file_full_name
|
500
|
+
assert_equal 'file.ext', pp.basename
|
501
|
+
assert_equal 'file', pp.file_name_only
|
502
|
+
assert_equal 'file', pp.stem
|
503
|
+
assert_equal '.ext', pp.file_extension
|
504
|
+
assert_equal '.ext', pp.extension
|
505
|
+
assert_nil pp.search_directory
|
506
|
+
assert_nil pp.search_relative_path
|
507
|
+
assert_nil pp.search_relative_directory_path
|
508
|
+
assert_nil pp.search_relative_directory_parts
|
509
|
+
|
510
|
+
assert_equal pp.directory, pp.directory_parts.join
|
511
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
512
|
+
end
|
513
|
+
|
514
|
+
def test_unrooted_one_file
|
515
|
+
|
516
|
+
pwd = '/some-directory'
|
517
|
+
|
518
|
+
pp = ParsedPath.new('file.ext', pwd: pwd)
|
519
|
+
|
520
|
+
assert_equal 'file.ext', pp.given_path
|
521
|
+
assert_equal '/some-directory\\file.ext', pp.absolute_path
|
522
|
+
assert_equal '/SOME-DIRECTORY\\FILE.EXT', pp.compare_path
|
523
|
+
assert_nil pp.volume
|
524
|
+
assert_equal '/some-directory\\', pp.directory
|
525
|
+
assert_equal '/some-directory\\', pp.directory_path
|
526
|
+
assert_equal '/some-directory\\', pp.dirname
|
527
|
+
assert_equal [ '/', 'some-directory\\' ], pp.directory_parts
|
528
|
+
assert_equal 'file.ext', pp.file_full_name
|
529
|
+
assert_equal 'file.ext', pp.basename
|
530
|
+
assert_equal 'file', pp.file_name_only
|
531
|
+
assert_equal 'file', pp.stem
|
532
|
+
assert_equal '.ext', pp.file_extension
|
533
|
+
assert_equal '.ext', pp.extension
|
534
|
+
assert_nil pp.search_directory
|
535
|
+
assert_nil pp.search_relative_path
|
536
|
+
assert_nil pp.search_relative_directory_path
|
537
|
+
assert_nil pp.search_relative_directory_parts
|
538
|
+
|
539
|
+
assert_equal pp.directory, pp.directory_parts.join
|
540
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_unrooted_dir_file
|
544
|
+
|
545
|
+
pwd = '/some-directory'
|
546
|
+
|
547
|
+
pp = ParsedPath.new('sub-dir/file.ext', pwd: pwd)
|
548
|
+
|
549
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
550
|
+
assert_equal '/some-directory\\sub-dir/file.ext', pp.absolute_path
|
551
|
+
assert_equal '/SOME-DIRECTORY\\SUB-DIR/FILE.EXT', pp.compare_path
|
552
|
+
assert_nil pp.volume
|
553
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory
|
554
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory_path
|
555
|
+
assert_equal '/some-directory\\sub-dir/', pp.dirname
|
556
|
+
assert_equal [ '/', 'some-directory\\', 'sub-dir/' ], pp.directory_parts
|
557
|
+
assert_equal 'file.ext', pp.file_full_name
|
558
|
+
assert_equal 'file.ext', pp.basename
|
559
|
+
assert_equal 'file', pp.file_name_only
|
560
|
+
assert_equal 'file', pp.stem
|
561
|
+
assert_equal '.ext', pp.file_extension
|
562
|
+
assert_equal '.ext', pp.extension
|
563
|
+
assert_nil pp.search_directory
|
564
|
+
assert_nil pp.search_relative_path
|
565
|
+
assert_nil pp.search_relative_directory_path
|
566
|
+
assert_nil pp.search_relative_directory_parts
|
567
|
+
|
568
|
+
assert_equal pp.directory, pp.directory_parts.join
|
569
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_unrooted_dir_file_2
|
573
|
+
|
574
|
+
locator = Object.new
|
575
|
+
|
576
|
+
locator.define_singleton_method(:pwd) { '/some-directory' }
|
577
|
+
|
578
|
+
pp = ParsedPath.new('sub-dir/file.ext', locator: locator)
|
579
|
+
|
580
|
+
assert_equal 'sub-dir/file.ext', pp.given_path
|
581
|
+
assert_equal '/some-directory\\sub-dir/file.ext', pp.absolute_path
|
582
|
+
assert_equal '/SOME-DIRECTORY\\SUB-DIR/FILE.EXT', pp.compare_path
|
583
|
+
assert_nil pp.volume
|
584
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory
|
585
|
+
assert_equal '/some-directory\\sub-dir/', pp.directory_path
|
586
|
+
assert_equal '/some-directory\\sub-dir/', pp.dirname
|
587
|
+
assert_equal [ '/', 'some-directory\\', 'sub-dir/' ], pp.directory_parts
|
588
|
+
assert_equal 'file.ext', pp.file_full_name
|
589
|
+
assert_equal 'file.ext', pp.basename
|
590
|
+
assert_equal 'file', pp.file_name_only
|
591
|
+
assert_equal 'file', pp.stem
|
592
|
+
assert_equal '.ext', pp.file_extension
|
593
|
+
assert_equal '.ext', pp.extension
|
594
|
+
assert_nil pp.search_directory
|
595
|
+
assert_nil pp.search_relative_path
|
596
|
+
assert_nil pp.search_relative_directory_path
|
597
|
+
assert_nil pp.search_relative_directory_parts
|
598
|
+
|
599
|
+
assert_equal pp.directory, pp.directory_parts.join
|
600
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
601
|
+
end
|
602
|
+
|
603
|
+
def test_rooted_UNC_form_5
|
604
|
+
|
605
|
+
gp = '\\\\?\\UNC\\127.0.0.1:3000\\shared-stuff\\dir-1\\dir-1.2\\file.ext'
|
606
|
+
|
607
|
+
pp = ParsedPath.new(gp)
|
608
|
+
|
609
|
+
assert_equal gp, pp.given_path
|
610
|
+
assert_equal gp, pp.absolute_path
|
611
|
+
assert_equal '\\\\?\\UNC\\127.0.0.1:3000\\shared-stuff\\DIR-1\\DIR-1.2\\FILE.EXT', pp.compare_path
|
612
|
+
assert_equal '\\\\?\\UNC\\127.0.0.1:3000\\shared-stuff', pp.volume
|
613
|
+
assert_equal '\\dir-1\\dir-1.2\\', pp.directory
|
614
|
+
assert_equal '\\\\?\\UNC\\127.0.0.1:3000\\shared-stuff\\dir-1\\dir-1.2\\', pp.directory_path
|
615
|
+
assert_equal '\\\\?\\UNC\\127.0.0.1:3000\\shared-stuff\\dir-1\\dir-1.2\\', pp.dirname
|
616
|
+
assert_equal [ '\\', 'dir-1\\', 'dir-1.2\\' ], pp.directory_parts
|
617
|
+
assert_equal 'file.ext', pp.file_full_name
|
618
|
+
assert_equal 'file.ext', pp.basename
|
619
|
+
assert_equal 'file', pp.file_name_only
|
620
|
+
assert_equal 'file', pp.stem
|
621
|
+
assert_equal '.ext', pp.file_extension
|
622
|
+
assert_equal '.ext', pp.extension
|
623
|
+
assert_nil pp.search_directory
|
624
|
+
assert_nil pp.search_relative_path
|
625
|
+
assert_nil pp.search_relative_directory_path
|
626
|
+
assert_nil pp.search_relative_directory_parts
|
627
|
+
|
628
|
+
assert_equal pp.directory, pp.directory_parts.join
|
629
|
+
assert_equal pp.absolute_path, "#{pp.volume}#{pp.directory_parts.join}#{pp.basename}"
|
630
|
+
end
|
629
631
|
end
|
630
632
|
|
633
|
+
|
634
|
+
# ############################## end of file ############################# #
|
635
|
+
|