libpath-ruby 0.2.1

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