win32-file 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
- ########################################################################
2
- # Miscellaneous tests for win32-file that didn't fit anywhere else.
3
- ########################################################################
4
- require 'win32/file'
5
- require 'test-unit'
6
-
7
- class TC_Win32_File_Misc < Test::Unit::TestCase
8
- test "version constant is set to expected value" do
9
- assert_equal('0.7.2', File::WIN32_FILE_VERSION)
10
- end
11
-
12
- test "ffi functions are private" do
13
- assert_not_respond_to(File, :CloseHandle)
14
- assert_not_respond_to(File, :CreateFileW)
15
- end
16
- end
1
+ ########################################################################
2
+ # Miscellaneous tests for win32-file that didn't fit anywhere else.
3
+ ########################################################################
4
+ require 'win32/file'
5
+ require 'test-unit'
6
+
7
+ class TC_Win32_File_Misc < Test::Unit::TestCase
8
+ test "version constant is set to expected value" do
9
+ assert_equal('0.7.3', File::WIN32_FILE_VERSION)
10
+ end
11
+
12
+ test "ffi functions are private" do
13
+ assert_not_respond_to(File, :CloseHandle)
14
+ assert_not_respond_to(File, :CreateFileW)
15
+ end
16
+ end
@@ -1,282 +1,282 @@
1
- #############################################################################
2
- # test_win32_file_path.rb
3
- #
4
- # Test case for the path related methods of win32-file. You should run this
5
- # test via the 'rake' or 'rake test:path' task.
6
- #############################################################################
7
- require 'test-unit'
8
- require 'win32/file'
9
- require 'pathname'
10
-
11
- class TC_Win32_File_Path < Test::Unit::TestCase
12
- def self.startup
13
- Dir.chdir(File.expand_path(File.dirname(__FILE__)))
14
- @@file = File.join(Dir.pwd, 'path_test.txt')
15
- File.open(@@file, 'w'){ |fh| fh.puts "This is a path test." }
16
- end
17
-
18
- def setup
19
- @long_file = File.join(Dir.pwd, 'path_test.txt').tr("/", "\\")
20
- @short_file = File.join(Dir.pwd, 'PATH_T~1.TXT').tr("/", "\\")
21
- end
22
-
23
- test "basename method basic functionality" do
24
- assert_respond_to(File, :basename)
25
- assert_nothing_raised{ File.basename("C:\\foo") }
26
- assert_kind_of(String, File.basename("C:\\foo"))
27
- end
28
-
29
- test "basename method handles standard paths" do
30
- assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt"))
31
- assert_equal("baz", File.basename("C:\\foo\\bar\\baz.txt", ".txt"))
32
- assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt", ".zip"))
33
- assert_equal("bar", File.basename("C:\\foo\\bar"))
34
- assert_equal("bar", File.basename("C:\\foo\\bar\\"))
35
- assert_equal("foo", File.basename("C:\\foo"))
36
- assert_equal("C:\\", File.basename("C:\\"))
37
- end
38
-
39
- test "basename method handles unc paths" do
40
- assert_equal("baz.txt", File.basename("\\\\foo\\bar\\baz.txt"))
41
- assert_equal("baz", File.basename("\\\\foo\\bar\\baz"))
42
- assert_equal("\\\\foo", File.basename("\\\\foo"))
43
- assert_equal("\\\\foo\\bar", File.basename("\\\\foo\\bar"))
44
- end
45
-
46
- test "basename method handles forward slashes in standard unix paths" do
47
- assert_equal("bar", File.basename("/foo/bar"))
48
- assert_equal("bar.txt", File.basename("/foo/bar.txt"))
49
- assert_equal("bar.txt", File.basename("bar.txt"))
50
- assert_equal("bar", File.basename("/bar"))
51
- assert_equal("bar", File.basename("/bar/"))
52
- assert_equal("baz", File.basename("//foo/bar/baz"))
53
- end
54
-
55
- test "basename method handles forward slashes in unc unix paths" do
56
- assert_equal("\\\\foo", File.basename("//foo"))
57
- assert_equal("\\\\foo\\bar", File.basename("//foo/bar"))
58
- end
59
-
60
- test "basename method handles forward slashes in windows paths" do
61
- assert_equal("bar", File.basename("C:/foo/bar"))
62
- assert_equal("bar", File.basename("C:/foo/bar/"))
63
- assert_equal("foo", File.basename("C:/foo"))
64
- assert_equal("C:\\", File.basename("C:/"))
65
- assert_equal("bar", File.basename("C:/foo/bar//"))
66
- end
67
-
68
- test "basename handles edge cases as expected" do
69
- assert_equal("", File.basename(""))
70
- assert_equal(".", File.basename("."))
71
- assert_equal("..", File.basename(".."))
72
- assert_equal("foo", File.basename("//foo/"))
73
- end
74
-
75
- test "basename handles path names with suffixes" do
76
- assert_equal("bar", File.basename("bar.txt", ".txt"))
77
- assert_equal("bar", File.basename("/foo/bar.txt", ".txt"))
78
- assert_equal("bar.txt", File.basename("bar.txt", ".exe"))
79
- assert_equal("bar.txt", File.basename("bar.txt.exe", ".exe"))
80
- assert_equal("bar.txt.exe", File.basename("bar.txt.exe", ".txt"))
81
- assert_equal("bar", File.basename("bar.txt", ".*"))
82
- assert_equal("bar.txt", File.basename("bar.txt.exe", ".*"))
83
- end
84
-
85
- test "basename method does not modify its argument" do
86
- path = "C:\\foo\\bar"
87
- assert_nothing_raised{ File.basename(path) }
88
- assert_equal("C:\\foo\\bar", path)
89
- end
90
-
91
- test "basename removes all trailing slashes" do
92
- assert_equal("foo.txt", File.basename("C:/foo.txt/"))
93
- assert_equal("foo.txt", File.basename("C:/foo.txt//"))
94
- assert_equal("foo.txt", File.basename("C:/foo.txt///"))
95
- assert_equal("foo.txt", File.basename("C:\\foo.txt\\"))
96
- assert_equal("foo.txt", File.basename("C:\\foo.txt\\\\"))
97
- assert_equal("foo.txt", File.basename("C:\\foo.txt\\\\\\"))
98
- assert_equal("foo.txt", File.basename("foo.txt\\\\\\"))
99
- end
100
-
101
- test "basename method handles arguments that honor to_str or to_path" do
102
- assert_equal("foo.txt", File.basename(Pathname.new("C:/blah/blah/foo.txt")))
103
- assert_equal("foo", File.basename(Pathname.new("C:/blah/blah/foo.txt"), Pathname.new(".*")))
104
- end
105
-
106
- test "dirname basic functionality" do
107
- assert_respond_to(File, :dirname)
108
- assert_nothing_raised{ File.dirname("C:\\foo") }
109
- assert_kind_of(String, File.dirname("C:\\foo"))
110
- end
111
-
112
- test "dirname handles standard windows paths as expected" do
113
- assert_equal("C:\\foo", File.dirname("C:\\foo\\bar.txt"))
114
- assert_equal("C:\\foo", File.dirname("C:\\foo\\bar"))
115
- assert_equal("C:\\", File.dirname("C:\\foo"))
116
- assert_equal("C:\\", File.dirname("C:\\"))
117
- assert_equal(".", File.dirname("foo"))
118
- end
119
-
120
- test "dirname handles unc windows paths as expected" do
121
- assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz"))
122
- assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar"))
123
- assert_equal("\\\\foo", File.dirname("\\\\foo"))
124
- assert_equal("\\\\", File.dirname("\\\\"))
125
- end
126
-
127
- test "dirname handles forward slashes in standard windows path names" do
128
- assert_equal("C:\\foo", File.dirname("C:/foo/bar.txt"))
129
- assert_equal("C:\\foo", File.dirname("C:/foo/bar"))
130
- assert_equal("C:\\", File.dirname("C:/foo"))
131
- assert_equal("C:\\", File.dirname("C:/"))
132
- end
133
-
134
- test "dirname handles forward slashes in unc windows path names" do
135
- assert_equal("\\\\foo\\bar", File.dirname("//foo/bar/baz"))
136
- assert_equal("\\\\foo\\bar", File.dirname("//foo/bar"))
137
- assert_equal("\\\\foo", File.dirname("//foo"))
138
- assert_equal("\\\\", File.dirname("//"))
139
- end
140
-
141
- test "dirname handles forward slashes in relative path names" do
142
- assert_equal(".", File.dirname("./foo"))
143
- assert_equal(".\\foo", File.dirname("./foo/bar"))
144
- end
145
-
146
- test "dirname handles various edge cases as expected" do
147
- assert_equal(".", File.dirname(""))
148
- assert_equal(".", File.dirname("."))
149
- assert_equal(".", File.dirname(".."))
150
- assert_equal(".", File.dirname("./"))
151
- end
152
-
153
- test "dirname method does not modify its argument" do
154
- path = "C:\\foo\\bar"
155
- assert_nothing_raised{ File.dirname(path) }
156
- assert_equal("C:\\foo\\bar", path)
157
- end
158
-
159
- test "dirname method ignores trailing slashes" do
160
- assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz/"))
161
- assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz//"))
162
- assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz///"))
163
- assert_equal("C:\\foo\\bar", File.dirname("C:\\foo\\bar\\baz\\"))
164
- assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz\\"))
165
- end
166
-
167
- test "argument to dirname must be a stringy object" do
168
- assert_raises(TypeError){ File.dirname(nil) }
169
- assert_raises(TypeError){ File.dirname(['foo', 'bar']) }
170
- end
171
-
172
- test "dirname method handles arguments that honor to_str or to_path" do
173
- assert_equal("C:\\blah\\blah", File.dirname(Pathname.new("C:/blah/blah/foo.txt")))
174
- end
175
-
176
- test "split method basic functionality" do
177
- assert_respond_to(File, :split)
178
- assert_nothing_raised{ File.split("C:\\foo\\bar") }
179
- assert_kind_of(Array, File.split("C:\\foo\\bar"))
180
- end
181
-
182
- test "split method handles standard windows path names" do
183
- assert_equal(["C:\\foo", "bar"], File.split("C:\\foo\\bar"))
184
- assert_equal([".", "foo"], File.split("foo"))
185
- end
186
-
187
- test "split method handles windows paths with forward slashes" do
188
- assert_equal(["C:\\foo", "bar"], File.split("C:/foo/bar"))
189
- assert_equal([".", "foo"], File.split("foo"))
190
- end
191
-
192
- test "split method handles standard unix paths as expected" do
193
- assert_equal(["\\foo","bar"], File.split("/foo/bar"))
194
- assert_equal(["\\", "foo"], File.split("/foo"))
195
- assert_equal([".", "foo"], File.split("foo"))
196
- end
197
-
198
- test "split method handles unc paths as expected" do
199
- assert_equal(["\\\\foo\\bar", "baz"], File.split("\\\\foo\\bar\\baz"))
200
- assert_equal(["\\\\foo\\bar", ""], File.split("\\\\foo\\bar"))
201
- assert_equal(["\\\\foo", ""], File.split("\\\\foo"))
202
- assert_equal(["\\\\", ""], File.split("\\\\"))
203
- end
204
-
205
- test "split method handles various edge cases as expected" do
206
- assert_equal(["C:\\", ""], File.split("C:\\"))
207
- assert_equal(["", ""], File.split(""))
208
- end
209
-
210
- test "split method does not modify its arguments" do
211
- path = "C:\\foo\\bar"
212
- assert_nothing_raised{ File.split(path) }
213
- assert_equal("C:\\foo\\bar", path)
214
- end
215
-
216
- test "split method accepts stringy arguments" do
217
- assert_equal(["C:\\foo", "bar"], File.split(Pathname.new("C:/foo/bar")))
218
- end
219
-
220
- test "split requires a stringy argument or a TypeError is raised" do
221
- assert_raise(TypeError){ File.split(nil) }
222
- assert_raise(TypeError){ File.split([]) }
223
- end
224
-
225
- test "File.long_path basic functionality" do
226
- assert_respond_to(File, :long_path)
227
- assert_nothing_raised{ File.long_path(@short_file) }
228
- assert_kind_of(String, File.long_path(@short_file))
229
- end
230
-
231
- test "File.long_path returns the expected result" do
232
- assert_equal(@long_file, File.long_path(@short_file))
233
- end
234
-
235
- test "File.short_path basic functionality" do
236
- assert_respond_to(File, :short_path)
237
- assert_nothing_raised{ File.short_path(@short_file) }
238
- assert_kind_of(String, File.short_path(@short_file))
239
- end
240
-
241
- test "File.short_path returns the expected result" do
242
- path = File.short_path(@long_file)
243
- assert_equal('PATH_T~1.TXT', File.basename(path))
244
- end
245
-
246
- test "join method works as expected" do
247
- assert_respond_to(File, :join)
248
- end
249
-
250
- test "join handles multiple arguments as expected" do
251
- assert_equal("C:\\foo\\bar", File.join("C:", "foo", "bar"))
252
- assert_equal("foo\\bar", File.join("foo", "bar"))
253
- end
254
-
255
- test "join handles multiple arguments as expected with unc paths" do
256
- assert_equal("\\\\foo", File.join("\\\\foo"))
257
- assert_equal("\\\\foo\\bar", File.join("\\\\foo", "bar"))
258
- end
259
-
260
- test "join does not normalize paths" do
261
- assert_equal("C:\\.\\foo\\..", File.join("C:", ".", "foo", ".."))
262
- end
263
-
264
- test "join with no arguments returns an empty string" do
265
- assert_equal('', File.join)
266
- end
267
-
268
- test "join with one argument returns the argument" do
269
- assert_equal('foo', File.join('foo'))
270
- assert_equal('c:', File.join('c:'))
271
- end
272
-
273
- def teardown
274
- @short_file = nil
275
- @long_file = nil
276
- end
277
-
278
- def self.shutdown
279
- File.delete(@@file) if File.exist?(@@file)
280
- @@file = nil
281
- end
282
- end
1
+ #############################################################################
2
+ # test_win32_file_path.rb
3
+ #
4
+ # Test case for the path related methods of win32-file. You should run this
5
+ # test via the 'rake' or 'rake test:path' task.
6
+ #############################################################################
7
+ require 'test-unit'
8
+ require 'win32/file'
9
+ require 'pathname'
10
+
11
+ class TC_Win32_File_Path < Test::Unit::TestCase
12
+ def self.startup
13
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
14
+ @@file = File.join(Dir.pwd, 'path_test.txt')
15
+ File.open(@@file, 'w'){ |fh| fh.puts "This is a path test." }
16
+ end
17
+
18
+ def setup
19
+ @long_file = File.join(Dir.pwd, 'path_test.txt').tr("/", "\\")
20
+ @short_file = File.join(Dir.pwd, 'PATH_T~1.TXT').tr("/", "\\")
21
+ end
22
+
23
+ test "basename method basic functionality" do
24
+ assert_respond_to(File, :basename)
25
+ assert_nothing_raised{ File.basename("C:\\foo") }
26
+ assert_kind_of(String, File.basename("C:\\foo"))
27
+ end
28
+
29
+ test "basename method handles standard paths" do
30
+ assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt"))
31
+ assert_equal("baz", File.basename("C:\\foo\\bar\\baz.txt", ".txt"))
32
+ assert_equal("baz.txt", File.basename("C:\\foo\\bar\\baz.txt", ".zip"))
33
+ assert_equal("bar", File.basename("C:\\foo\\bar"))
34
+ assert_equal("bar", File.basename("C:\\foo\\bar\\"))
35
+ assert_equal("foo", File.basename("C:\\foo"))
36
+ assert_equal("C:\\", File.basename("C:\\"))
37
+ end
38
+
39
+ test "basename method handles unc paths" do
40
+ assert_equal("baz.txt", File.basename("\\\\foo\\bar\\baz.txt"))
41
+ assert_equal("baz", File.basename("\\\\foo\\bar\\baz"))
42
+ assert_equal("\\\\foo", File.basename("\\\\foo"))
43
+ assert_equal("\\\\foo\\bar", File.basename("\\\\foo\\bar"))
44
+ end
45
+
46
+ test "basename method handles forward slashes in standard unix paths" do
47
+ assert_equal("bar", File.basename("/foo/bar"))
48
+ assert_equal("bar.txt", File.basename("/foo/bar.txt"))
49
+ assert_equal("bar.txt", File.basename("bar.txt"))
50
+ assert_equal("bar", File.basename("/bar"))
51
+ assert_equal("bar", File.basename("/bar/"))
52
+ assert_equal("baz", File.basename("//foo/bar/baz"))
53
+ end
54
+
55
+ test "basename method handles forward slashes in unc unix paths" do
56
+ assert_equal("\\\\foo", File.basename("//foo"))
57
+ assert_equal("\\\\foo\\bar", File.basename("//foo/bar"))
58
+ end
59
+
60
+ test "basename method handles forward slashes in windows paths" do
61
+ assert_equal("bar", File.basename("C:/foo/bar"))
62
+ assert_equal("bar", File.basename("C:/foo/bar/"))
63
+ assert_equal("foo", File.basename("C:/foo"))
64
+ assert_equal("C:\\", File.basename("C:/"))
65
+ assert_equal("bar", File.basename("C:/foo/bar//"))
66
+ end
67
+
68
+ test "basename handles edge cases as expected" do
69
+ assert_equal("", File.basename(""))
70
+ assert_equal(".", File.basename("."))
71
+ assert_equal("..", File.basename(".."))
72
+ assert_equal("foo", File.basename("//foo/"))
73
+ end
74
+
75
+ test "basename handles path names with suffixes" do
76
+ assert_equal("bar", File.basename("bar.txt", ".txt"))
77
+ assert_equal("bar", File.basename("/foo/bar.txt", ".txt"))
78
+ assert_equal("bar.txt", File.basename("bar.txt", ".exe"))
79
+ assert_equal("bar.txt", File.basename("bar.txt.exe", ".exe"))
80
+ assert_equal("bar.txt.exe", File.basename("bar.txt.exe", ".txt"))
81
+ assert_equal("bar", File.basename("bar.txt", ".*"))
82
+ assert_equal("bar.txt", File.basename("bar.txt.exe", ".*"))
83
+ end
84
+
85
+ test "basename method does not modify its argument" do
86
+ path = "C:\\foo\\bar"
87
+ assert_nothing_raised{ File.basename(path) }
88
+ assert_equal("C:\\foo\\bar", path)
89
+ end
90
+
91
+ test "basename removes all trailing slashes" do
92
+ assert_equal("foo.txt", File.basename("C:/foo.txt/"))
93
+ assert_equal("foo.txt", File.basename("C:/foo.txt//"))
94
+ assert_equal("foo.txt", File.basename("C:/foo.txt///"))
95
+ assert_equal("foo.txt", File.basename("C:\\foo.txt\\"))
96
+ assert_equal("foo.txt", File.basename("C:\\foo.txt\\\\"))
97
+ assert_equal("foo.txt", File.basename("C:\\foo.txt\\\\\\"))
98
+ assert_equal("foo.txt", File.basename("foo.txt\\\\\\"))
99
+ end
100
+
101
+ test "basename method handles arguments that honor to_str or to_path" do
102
+ assert_equal("foo.txt", File.basename(Pathname.new("C:/blah/blah/foo.txt")))
103
+ assert_equal("foo", File.basename(Pathname.new("C:/blah/blah/foo.txt"), Pathname.new(".*")))
104
+ end
105
+
106
+ test "dirname basic functionality" do
107
+ assert_respond_to(File, :dirname)
108
+ assert_nothing_raised{ File.dirname("C:\\foo") }
109
+ assert_kind_of(String, File.dirname("C:\\foo"))
110
+ end
111
+
112
+ test "dirname handles standard windows paths as expected" do
113
+ assert_equal("C:\\foo", File.dirname("C:\\foo\\bar.txt"))
114
+ assert_equal("C:\\foo", File.dirname("C:\\foo\\bar"))
115
+ assert_equal("C:\\", File.dirname("C:\\foo"))
116
+ assert_equal("C:\\", File.dirname("C:\\"))
117
+ assert_equal(".", File.dirname("foo"))
118
+ end
119
+
120
+ test "dirname handles unc windows paths as expected" do
121
+ assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz"))
122
+ assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar"))
123
+ assert_equal("\\\\foo", File.dirname("\\\\foo"))
124
+ assert_equal("\\\\", File.dirname("\\\\"))
125
+ end
126
+
127
+ test "dirname handles forward slashes in standard windows path names" do
128
+ assert_equal("C:\\foo", File.dirname("C:/foo/bar.txt"))
129
+ assert_equal("C:\\foo", File.dirname("C:/foo/bar"))
130
+ assert_equal("C:\\", File.dirname("C:/foo"))
131
+ assert_equal("C:\\", File.dirname("C:/"))
132
+ end
133
+
134
+ test "dirname handles forward slashes in unc windows path names" do
135
+ assert_equal("\\\\foo\\bar", File.dirname("//foo/bar/baz"))
136
+ assert_equal("\\\\foo\\bar", File.dirname("//foo/bar"))
137
+ assert_equal("\\\\foo", File.dirname("//foo"))
138
+ assert_equal("\\\\", File.dirname("//"))
139
+ end
140
+
141
+ test "dirname handles forward slashes in relative path names" do
142
+ assert_equal(".", File.dirname("./foo"))
143
+ assert_equal(".\\foo", File.dirname("./foo/bar"))
144
+ end
145
+
146
+ test "dirname handles various edge cases as expected" do
147
+ assert_equal(".", File.dirname(""))
148
+ assert_equal(".", File.dirname("."))
149
+ assert_equal(".", File.dirname(".."))
150
+ assert_equal(".", File.dirname("./"))
151
+ end
152
+
153
+ test "dirname method does not modify its argument" do
154
+ path = "C:\\foo\\bar"
155
+ assert_nothing_raised{ File.dirname(path) }
156
+ assert_equal("C:\\foo\\bar", path)
157
+ end
158
+
159
+ test "dirname method ignores trailing slashes" do
160
+ assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz/"))
161
+ assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz//"))
162
+ assert_equal("C:\\foo\\bar", File.dirname("C:/foo/bar/baz///"))
163
+ assert_equal("C:\\foo\\bar", File.dirname("C:\\foo\\bar\\baz\\"))
164
+ assert_equal("\\\\foo\\bar", File.dirname("\\\\foo\\bar\\baz\\"))
165
+ end
166
+
167
+ test "argument to dirname must be a stringy object" do
168
+ assert_raises(TypeError){ File.dirname(nil) }
169
+ assert_raises(TypeError){ File.dirname(['foo', 'bar']) }
170
+ end
171
+
172
+ test "dirname method handles arguments that honor to_str or to_path" do
173
+ assert_equal("C:\\blah\\blah", File.dirname(Pathname.new("C:/blah/blah/foo.txt")))
174
+ end
175
+
176
+ test "split method basic functionality" do
177
+ assert_respond_to(File, :split)
178
+ assert_nothing_raised{ File.split("C:\\foo\\bar") }
179
+ assert_kind_of(Array, File.split("C:\\foo\\bar"))
180
+ end
181
+
182
+ test "split method handles standard windows path names" do
183
+ assert_equal(["C:\\foo", "bar"], File.split("C:\\foo\\bar"))
184
+ assert_equal([".", "foo"], File.split("foo"))
185
+ end
186
+
187
+ test "split method handles windows paths with forward slashes" do
188
+ assert_equal(["C:\\foo", "bar"], File.split("C:/foo/bar"))
189
+ assert_equal([".", "foo"], File.split("foo"))
190
+ end
191
+
192
+ test "split method handles standard unix paths as expected" do
193
+ assert_equal(["\\foo","bar"], File.split("/foo/bar"))
194
+ assert_equal(["\\", "foo"], File.split("/foo"))
195
+ assert_equal([".", "foo"], File.split("foo"))
196
+ end
197
+
198
+ test "split method handles unc paths as expected" do
199
+ assert_equal(["\\\\foo\\bar", "baz"], File.split("\\\\foo\\bar\\baz"))
200
+ assert_equal(["\\\\foo\\bar", ""], File.split("\\\\foo\\bar"))
201
+ assert_equal(["\\\\foo", ""], File.split("\\\\foo"))
202
+ assert_equal(["\\\\", ""], File.split("\\\\"))
203
+ end
204
+
205
+ test "split method handles various edge cases as expected" do
206
+ assert_equal(["C:\\", ""], File.split("C:\\"))
207
+ assert_equal(["", ""], File.split(""))
208
+ end
209
+
210
+ test "split method does not modify its arguments" do
211
+ path = "C:\\foo\\bar"
212
+ assert_nothing_raised{ File.split(path) }
213
+ assert_equal("C:\\foo\\bar", path)
214
+ end
215
+
216
+ test "split method accepts stringy arguments" do
217
+ assert_equal(["C:\\foo", "bar"], File.split(Pathname.new("C:/foo/bar")))
218
+ end
219
+
220
+ test "split requires a stringy argument or a TypeError is raised" do
221
+ assert_raise(TypeError){ File.split(nil) }
222
+ assert_raise(TypeError){ File.split([]) }
223
+ end
224
+
225
+ test "File.long_path basic functionality" do
226
+ assert_respond_to(File, :long_path)
227
+ assert_nothing_raised{ File.long_path(@short_file) }
228
+ assert_kind_of(String, File.long_path(@short_file))
229
+ end
230
+
231
+ test "File.long_path returns the expected result" do
232
+ assert_equal(@long_file, File.long_path(@short_file))
233
+ end
234
+
235
+ test "File.short_path basic functionality" do
236
+ assert_respond_to(File, :short_path)
237
+ assert_nothing_raised{ File.short_path(@short_file) }
238
+ assert_kind_of(String, File.short_path(@short_file))
239
+ end
240
+
241
+ test "File.short_path returns the expected result" do
242
+ path = File.short_path(@long_file)
243
+ assert_equal('PATH_T~1.TXT', File.basename(path))
244
+ end
245
+
246
+ test "join method works as expected" do
247
+ assert_respond_to(File, :join)
248
+ end
249
+
250
+ test "join handles multiple arguments as expected" do
251
+ assert_equal("C:\\foo\\bar", File.join("C:", "foo", "bar"))
252
+ assert_equal("foo\\bar", File.join("foo", "bar"))
253
+ end
254
+
255
+ test "join handles multiple arguments as expected with unc paths" do
256
+ assert_equal("\\\\foo", File.join("\\\\foo"))
257
+ assert_equal("\\\\foo\\bar", File.join("\\\\foo", "bar"))
258
+ end
259
+
260
+ test "join does not normalize paths" do
261
+ assert_equal("C:\\.\\foo\\..", File.join("C:", ".", "foo", ".."))
262
+ end
263
+
264
+ test "join with no arguments returns an empty string" do
265
+ assert_equal('', File.join)
266
+ end
267
+
268
+ test "join with one argument returns the argument" do
269
+ assert_equal('foo', File.join('foo'))
270
+ assert_equal('c:', File.join('c:'))
271
+ end
272
+
273
+ def teardown
274
+ @short_file = nil
275
+ @long_file = nil
276
+ end
277
+
278
+ def self.shutdown
279
+ File.delete(@@file) if File.exist?(@@file)
280
+ @@file = nil
281
+ end
282
+ end