2 // System.IO.Path Test Cases
5 // Marcin Szczepanski (marcins@zipworld.com.au)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // Ben Maurer (bmaurer@users.sf.net)
8 // Gilles Freart (gfr@skynet.be)
9 // Atsushi Enomoto (atsushi@ximian.com)
10 // Sebastien Pouliot <sebastien@ximian.com>
12 // (c) Marcin Szczepanski
13 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
14 // (c) 2003 Ben Maurer
15 // (c) 2003 Gilles Freart
16 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
19 using NUnit.Framework;
24 namespace MonoTests.System.IO
39 static char DSC = Path.DirectorySeparatorChar;
46 path1 = "/foo/test.txt";
49 } else if ('\\' == DSC) {
51 path1 = "c:\\foo\\test.txt";
52 path2 = Environment.GetEnvironmentVariable ("SYSTEMROOT");
56 //FIXME: For Mac. figure this out when we need it
57 path1 = "foo:test.txt";
66 return OS == OsType.Windows;
73 return OS == OsType.Unix;
80 return OS == OsType.Mac;
85 public void ChangeExtension ()
87 string [] files = new string [3];
88 files [(int) OsType.Unix] = "/foo/test.doc";
89 files [(int) OsType.Windows] = "c:\\foo\\test.doc";
90 files [(int) OsType.Mac] = "foo:test.doc";
92 string testPath = Path.ChangeExtension (path1, "doc");
93 Assert.AreEqual (files [(int) OS], testPath, "ChangeExtension #01");
95 testPath = Path.ChangeExtension (String.Empty, ".extension");
96 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #02");
98 testPath = Path.ChangeExtension (null, ".extension");
99 Assert.AreEqual (null, testPath, "ChangeExtension #03");
101 testPath = Path.ChangeExtension ("path", null);
102 Assert.AreEqual ("path", testPath, "ChangeExtension #04");
104 testPath = Path.ChangeExtension ("path.ext", "doc");
105 Assert.AreEqual ("path.doc", testPath, "ChangeExtension #05");
107 testPath = Path.ChangeExtension ("path.ext1.ext2", "doc");
108 Assert.AreEqual ("path.ext1.doc", testPath, "ChangeExtension #06");
110 testPath = Path.ChangeExtension ("hogehoge.xml", ".xsl");
111 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #07");
112 testPath = Path.ChangeExtension ("hogehoge", ".xsl");
113 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #08");
114 testPath = Path.ChangeExtension ("hogehoge.xml", "xsl");
115 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #09");
116 testPath = Path.ChangeExtension ("hogehoge", "xsl");
117 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #10");
118 testPath = Path.ChangeExtension ("hogehoge.xml", String.Empty);
119 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #11");
120 testPath = Path.ChangeExtension ("hogehoge", String.Empty);
121 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #12");
122 testPath = Path.ChangeExtension ("hogehoge.", null);
123 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #13");
124 testPath = Path.ChangeExtension ("hogehoge", null);
125 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #14");
126 testPath = Path.ChangeExtension (String.Empty, null);
127 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #15");
128 testPath = Path.ChangeExtension (String.Empty, "bashrc");
129 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #16");
130 testPath = Path.ChangeExtension (String.Empty, ".bashrc");
131 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #17");
132 testPath = Path.ChangeExtension (null, null);
133 Assert.IsNull (testPath, "ChangeExtension #18");
137 public void ChangeExtension_Extension_InvalidPathChars ()
139 string fn = Path.ChangeExtension ("file.ext", "<");
140 Assert.AreEqual ("file.<", fn, "Invalid filename");
144 public void ChangeExtension_Path_InvalidPathChars ()
147 Path.ChangeExtension ("fi\0le.ext", ".extension");
149 } catch (ArgumentException ex) {
150 // Illegal characters in path
151 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
152 Assert.IsNull (ex.InnerException, "#3");
153 Assert.IsNotNull (ex.Message, "#4");
154 Assert.IsNull (ex.ParamName, "#5");
159 public void Combine ()
161 string [] files = new string [3];
162 files [(int) OsType.Unix] = "/etc/init.d";
163 files [(int) OsType.Windows] = Environment.GetEnvironmentVariable ("SYSTEMROOT") + @"\system32";
164 files [(int) OsType.Mac] = "foo:bar";
166 string testPath = Path.Combine (path2, path3);
167 Assert.AreEqual (files [(int) OS], testPath, "Combine #01");
169 testPath = Path.Combine ("one", String.Empty);
170 Assert.AreEqual ("one", testPath, "Combine #02");
172 testPath = Path.Combine (String.Empty, "one");
173 Assert.AreEqual ("one", testPath, "Combine #03");
175 string current = Directory.GetCurrentDirectory ();
176 testPath = Path.Combine (current, "one");
178 string expected = current + DSC + "one";
179 Assert.AreEqual (expected, testPath, "Combine #04");
181 testPath = Path.Combine ("one", current);
182 // LAMESPEC noted in Path.cs
183 Assert.AreEqual (current, testPath, "Combine #05");
185 testPath = Path.Combine (current, expected);
186 Assert.AreEqual (expected, testPath, "Combine #06");
188 testPath = DSC + "one";
189 testPath = Path.Combine (testPath, "two" + DSC);
190 expected = DSC + "one" + DSC + "two" + DSC;
191 Assert.AreEqual (expected, testPath, "Combine #06");
193 testPath = "one" + DSC;
194 testPath = Path.Combine (testPath, DSC + "two");
195 expected = DSC + "two";
196 Assert.AreEqual (expected, testPath, "Combine #06");
198 testPath = "one" + DSC;
199 testPath = Path.Combine (testPath, "two" + DSC);
200 expected = "one" + DSC + "two" + DSC;
201 Assert.AreEqual (expected, testPath, "Combine #07");
205 public void Combine_Path1_InvalidPathChars ()
208 Path.Combine ("a\0", "one");
210 } catch (ArgumentException ex) {
211 // Illegal characters in path
212 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
213 Assert.IsNull (ex.InnerException, "#3");
214 Assert.IsNotNull (ex.Message, "#4");
215 Assert.IsNull (ex.ParamName, "#5");
220 public void Combine_Path1_Null ()
223 Path.Combine (null, "one");
225 } catch (ArgumentNullException ex) {
226 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
227 Assert.IsNull (ex.InnerException, "#3");
228 Assert.IsNotNull (ex.Message, "#4");
229 Assert.AreEqual ("path1", ex.ParamName, "#5");
234 public void Combine_Path2_InvalidPathChars ()
237 Path.Combine ("one", "a\0");
239 } catch (ArgumentException ex) {
240 // Illegal characters in path
241 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
242 Assert.IsNull (ex.InnerException, "#3");
243 Assert.IsNotNull (ex.Message, "#4");
244 Assert.IsNull (ex.ParamName, "#5");
249 public void Combine_Path2_Null ()
252 Path.Combine ("one", null);
254 } catch (ArgumentNullException ex) {
255 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
256 Assert.IsNull (ex.InnerException, "#3");
257 Assert.IsNotNull (ex.Message, "#4");
258 Assert.AreEqual ("path2", ex.ParamName, "#5");
263 public void GetDirectoryName ()
265 string [] files = new string [3];
266 files [(int) OsType.Unix] = "/foo";
267 files [(int) OsType.Windows] = "c:\\foo";
268 files [(int) OsType.Mac] = "foo";
270 string testDirName = Path.GetDirectoryName (path1);
271 Assert.AreEqual (files [(int) OS], testDirName, "#A1");
272 testDirName = Path.GetDirectoryName (files [(int) OS] + DSC);
273 Assert.AreEqual (files [(int) OS], testDirName, "#A2");
276 Assert.AreEqual ("C:\\foo", Path.GetDirectoryName ("C:\\foo\\foo.txt"), "#B1");
277 Assert.AreEqual (null, Path.GetDirectoryName ("C:"), "#B2");
278 Assert.AreEqual (null, Path.GetDirectoryName (@"C:\"), "#B3");
279 Assert.AreEqual (@"C:\", Path.GetDirectoryName (@"C:\dir"), "#B4");
280 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\"), "#B5");
281 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"), "#B6");
282 Assert.AreEqual (@"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"), "#B7");
283 Assert.AreEqual (@"C:", Path.GetDirectoryName (@"C:foo.txt"), "#B8");
284 Assert.AreEqual (@"C:dir", Path.GetDirectoryName (@"C:dir\"), "#B9");
286 Assert.AreEqual ("\\foo\\bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#C1");
287 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar/"), "#C2");
288 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar\\xxx"), "#C3");
289 Assert.AreEqual ("\\\\host\\dir\\dir2", Path.GetDirectoryName ("\\\\host\\dir\\\\dir2\\path"), "#C4");
292 Assert.AreEqual (null, Path.GetDirectoryName (@"\\"), "#D1");
293 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server"), "#D2");
294 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server\share"), "#D3");
295 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\"), "#D4");
296 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\dir"), "#D5");
297 Assert.AreEqual (@"\\server\share\dir", Path.GetDirectoryName (@"\\server\share\dir\subdir"), "#D6");
299 Assert.AreEqual ("/etc", Path.GetDirectoryName ("/etc/hostname"), "#B1");
300 Assert.AreEqual ("/foo/bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#B2");
301 Assert.AreEqual ("foo/bar", Path.GetDirectoryName ("foo/bar/"), "#B3");
302 Assert.AreEqual ("/", Path.GetDirectoryName ("/tmp"), "#B4");
303 Assert.IsNull (Path.GetDirectoryName ("/"), "#B5");
304 Assert.AreEqual ("a", Path.GetDirectoryName ("a//b"), "#B6");
309 public void GetDirectoryName_Path_Empty ()
312 Path.GetDirectoryName (String.Empty);
314 } catch (ArgumentException ex) {
315 // The path is not of a legal form
316 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
317 Assert.IsNull (ex.InnerException, "#3");
318 Assert.IsNotNull (ex.Message, "#4");
319 Assert.IsNull (ex.ParamName, "#5");
324 public void GetDirectoryName_Path_InvalidPathChars ()
327 Path.GetDirectoryName ("hi\0world");
329 } catch (ArgumentException ex) {
330 // Illegal characters in path
331 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
332 Assert.IsNull (ex.InnerException, "#3");
333 Assert.IsNotNull (ex.Message, "#4");
334 Assert.IsNull (ex.ParamName, "#5");
339 public void GetDirectoryName_Path_Null ()
341 Assert.IsNull (Path.GetDirectoryName (null));
345 public void GetDirectoryName_Path_Whitespace ()
348 Path.GetDirectoryName (" ");
350 } catch (ArgumentException ex) {
351 // The path is not of a legal form
352 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
353 Assert.IsNull (ex.InnerException, "#3");
354 Assert.IsNotNull (ex.Message, "#4");
355 Assert.IsNull (ex.ParamName, "#5");
360 public void GetExtension ()
362 string testExtn = Path.GetExtension (path1);
364 Assert.AreEqual (".txt", testExtn, "GetExtension #01");
366 testExtn = Path.GetExtension (path2);
367 Assert.AreEqual (String.Empty, testExtn, "GetExtension #02");
369 testExtn = Path.GetExtension (String.Empty);
370 Assert.AreEqual (String.Empty, testExtn, "GetExtension #03");
372 testExtn = Path.GetExtension (null);
373 Assert.AreEqual (null, testExtn, "GetExtension #04");
375 testExtn = Path.GetExtension (" ");
376 Assert.AreEqual (String.Empty, testExtn, "GetExtension #05");
378 testExtn = Path.GetExtension (path1 + ".doc");
379 Assert.AreEqual (".doc", testExtn, "GetExtension #06");
381 testExtn = Path.GetExtension (path1 + ".doc" + DSC + "a.txt");
382 Assert.AreEqual (".txt", testExtn, "GetExtension #07");
384 testExtn = Path.GetExtension (".");
385 Assert.AreEqual (String.Empty, testExtn, "GetExtension #08");
387 testExtn = Path.GetExtension ("end.");
388 Assert.AreEqual (String.Empty, testExtn, "GetExtension #09");
390 testExtn = Path.GetExtension (".start");
391 Assert.AreEqual (".start", testExtn, "GetExtension #10");
393 testExtn = Path.GetExtension (".a");
394 Assert.AreEqual (".a", testExtn, "GetExtension #11");
396 testExtn = Path.GetExtension ("a.");
397 Assert.AreEqual (String.Empty, testExtn, "GetExtension #12");
399 testExtn = Path.GetExtension ("a");
400 Assert.AreEqual (String.Empty, testExtn, "GetExtension #13");
402 testExtn = Path.GetExtension ("makefile");
403 Assert.AreEqual (String.Empty, testExtn, "GetExtension #14");
407 public void GetExtension_Path_InvalidPathChars ()
410 Path.GetExtension ("hi\0world.txt");
412 } catch (ArgumentException ex) {
413 // Illegal characters in path.
414 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
415 Assert.IsNull (ex.InnerException, "#3");
416 Assert.IsNotNull (ex.Message, "#4");
417 Assert.IsNull (ex.ParamName, "#5");
422 public void GetFileName ()
424 string testFileName = Path.GetFileName (path1);
426 Assert.AreEqual ("test.txt", testFileName, "#1");
427 testFileName = Path.GetFileName (null);
428 Assert.AreEqual (null, testFileName, "#2");
429 testFileName = Path.GetFileName (String.Empty);
430 Assert.AreEqual (String.Empty, testFileName, "#3");
431 testFileName = Path.GetFileName (" ");
432 Assert.AreEqual (" ", testFileName, "#4");
436 public void GetFileName_Path_InvalidPathChars ()
439 Path.GetFileName ("hi\0world");
441 } catch (ArgumentException ex) {
442 // Illegal characters in path
443 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
444 Assert.IsNull (ex.InnerException, "#3");
445 Assert.IsNotNull (ex.Message, "#4");
446 Assert.IsNull (ex.ParamName, "#5");
451 public void GetFileNameWithoutExtension ()
453 string testFileName = Path.GetFileNameWithoutExtension (path1);
455 Assert.AreEqual ("test", testFileName, "GetFileNameWithoutExtension #01");
457 testFileName = Path.GetFileNameWithoutExtension (null);
458 Assert.AreEqual (null, testFileName, "GetFileNameWithoutExtension #02");
460 testFileName = Path.GetFileNameWithoutExtension (String.Empty);
461 Assert.AreEqual (String.Empty, testFileName, "GetFileNameWithoutExtension #03");
465 public void GetFileNameWithoutExtension_Path_InvalidPathChars ()
468 Path.GetFileNameWithoutExtension ("hi\0world");
470 } catch (ArgumentException ex) {
471 // Illegal characters in path
472 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
473 Assert.IsNull (ex.InnerException, "#3");
474 Assert.IsNotNull (ex.Message, "#4");
475 Assert.IsNull (ex.ParamName, "#5");
480 public void GetFullPath ()
482 string current = Directory.GetCurrentDirectory ();
484 string testFullPath = Path.GetFullPath ("foo.txt");
485 string expected = current + DSC + "foo.txt";
486 Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
488 testFullPath = Path.GetFullPath ("a//./.././foo.txt");
489 Assert.AreEqual (expected, testFullPath, "GetFullPath #02");
493 public void GetFullPath_Unix ()
499 string [,] test = new string [,] {
500 {"root////././././././../root/././../root", "root"},
502 {"root/./", "root/"},
503 {"root/./", "root/"},
504 {"root/../", String.Empty},
505 {"root/../", String.Empty},
506 {"root/../..", String.Empty},
507 {"root/.hiddenfile", "root/.hiddenfile"},
508 {"root/. /", "root/. /"},
509 {"root/.. /", "root/.. /"},
510 {"root/..weirdname", "root/..weirdname"},
511 {"root/..", String.Empty},
512 {"root/../a/b/../../..", String.Empty},
513 {"root/./..", String.Empty},
514 {"..", String.Empty},
516 {"root//dir", "root/dir"},
517 {"root/. /", "root/. /"},
518 {"root/.. /", "root/.. /"},
519 {"root/ . /", "root/ . /"},
520 {"root/ .. /", "root/ .. /"},
521 {"root/./", "root/"},
522 //ERROR! Paths are trimmed
523 // I don't understand this comment^^.
524 // No trimming occurs but the paths are not equal. That's why the test fails. Commented out.
525 //{"root/.. /", "root/.. /"},
526 {".//", String.Empty}
529 for (int i = 0; i < test.GetUpperBound (0); i++) {
530 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
531 String.Format ("GetFullPathUnix #{0}", i));
534 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
535 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
536 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
537 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
538 Path.GetFullPath ("hey"), "#04");
542 public void GetFullPath_Windows ()
547 string root = "C:\\";
548 string [,] test = new string [,] {
549 {"root////././././././../root/././../root", "root"},
551 {"root/./", "root\\"},
552 {"root/./", "root\\"},
556 {"root/.hiddenfile", "root\\.hiddenfile"},
557 {"root/. /", "root\\"},
559 {"root/..weirdname", "root\\..weirdname"},
561 {"root/../a/b/../../..", ""},
565 {"root//dir", "root\\dir"},
566 {"root/. /", "root\\"},
569 {"root/ . /", "root\\"},
572 {"root/./", "root\\"},
577 for (int i = 0; i < test.GetUpperBound (0); i++) {
579 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
580 String.Format ("GetFullPathWindows #{0}", i));
581 } catch (Exception ex) {
582 Assert.Fail (String.Format ("GetFullPathWindows #{0} (\"{1}\") failed: {2}",
583 i, root + test [i, 0], ex.GetType ()));
588 string root2 = @"\\server\share";
589 root = @"\\server\share\";
590 test = new string [,] {
591 {"root////././././././../root/././../root", "root"},
593 {"root/./", "root\\"},
594 {"root/./", "root\\"},
597 {"root/../..", null},
598 {"root/.hiddenfile", "root\\.hiddenfile"},
599 {"root/. /", "root\\"},
601 {"root/..weirdname", "root\\..weirdname"},
603 {"root/../a/b/../../..", null},
607 {"root//dir", "root\\dir"},
608 {"root/. /", "root\\"},
611 {"root/ . /", "root\\"},
614 {"root/./", "root\\"},
619 for (int i = 0; i < test.GetUpperBound (0); i++) {
620 // "null" means we have to compare against "root2"
621 string res = test [i, 1] != null
625 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
626 String.Format ("GetFullPathWindows UNC #{0}", i));
627 } catch (AssertionException) {
629 } catch (Exception ex) {
630 Assert.Fail (String.Format ("GetFullPathWindows UNC #{0} (\"{1}\") failed: {2}",
631 i, root + test [i, 0], ex.GetType ()));
635 test = new string [,] {
636 {"root////././././././../root/././../root", "root"},
638 {"root/./", "root\\"},
639 {"root/./", "root\\"},
642 {"root/../..", null},
643 {"root/.hiddenfile", "root\\.hiddenfile"},
644 {"root/. /", "root\\"},
646 {"root/..weirdname", "root\\..weirdname"},
648 {"root/../a/b/../../..", null},
652 {"root//dir", "root\\dir"},
653 {"root/. /", "root\\"},
656 {"root/ . /", "root\\"},
659 {"root/./", "root\\"},
664 string root3 = @"//server/share";
665 root = @"//server/share/";
666 bool needSlashConvert = Path.DirectorySeparatorChar != '/';
668 for (int i = 0; i < test.GetUpperBound (0); i++) {
669 // "null" means we have to compare against "root2"
670 string res = test [i, 1] != null
673 if (needSlashConvert)
674 res = res.Replace ('/', Path.DirectorySeparatorChar);
676 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
677 String.Format ("GetFullPathWindows UNC[2] #{0}", i));
678 } catch (AssertionException) {
680 } catch (Exception ex) {
681 Assert.Fail (String.Format ("GetFullPathWindows UNC[2] #{0} (\"{1}\") failed: {2}",
682 i, root + test [i, 0], ex.GetType ()));
688 public void GetFullPath_Path_Empty ()
691 Path.GetFullPath (String.Empty);
693 } catch (ArgumentException ex) {
694 // The path is not of a legal form
695 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
696 Assert.IsNull (ex.InnerException, "#3");
697 Assert.IsNotNull (ex.Message, "#4");
698 Assert.IsNull (ex.ParamName, "#5");
703 public void GetFullPath_Path_EndingSeparator ()
705 string fp = Path.GetFullPath ("something/");
706 char end = fp [fp.Length - 1];
707 Assert.IsTrue (end == Path.DirectorySeparatorChar);
711 public void GetFullPath_Path_InvalidPathChars ()
714 Path.GetFullPath ("hi\0world");
716 } catch (ArgumentException ex) {
717 // Illegal characters in path
718 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
719 Assert.IsNull (ex.InnerException, "#3");
720 Assert.IsNotNull (ex.Message, "#4");
721 Assert.IsNull (ex.ParamName, "#5");
726 public void GetFullPath_Path_Null ()
729 Path.GetFullPath (null);
731 } catch (ArgumentNullException ex) {
732 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
733 Assert.IsNull (ex.InnerException, "#3");
734 Assert.IsNotNull (ex.Message, "#4");
735 Assert.AreEqual ("path", ex.ParamName, "#5");
740 public void GetFullPath_Path_Whitespace ()
743 Path.GetFullPath (" ");
745 } catch (ArgumentException ex) {
746 // The path is not of a legal form
747 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
748 Assert.IsNull (ex.InnerException, "#3");
749 Assert.IsNotNull (ex.Message, "#4");
750 Assert.IsNull (ex.ParamName, "#5");
755 public void GetFullPath2 ()
758 Assert.AreEqual (@"Z:\", Path.GetFullPath ("Z:"), "GetFullPath w#01");
759 #if !TARGET_JVM // Java full (canonical) path always starts with caps drive letter
760 Assert.AreEqual (@"c:\abc\def", Path.GetFullPath (@"c:\abc\def"), "GetFullPath w#02");
762 Assert.IsTrue (Path.GetFullPath (@"\").EndsWith (@"\"), "GetFullPath w#03");
763 // "\\\\" is not allowed
764 Assert.IsTrue (Path.GetFullPath ("/").EndsWith (@"\"), "GetFullPath w#05");
765 // "//" is not allowed
766 Assert.IsTrue (Path.GetFullPath ("readme.txt").EndsWith (@"\readme.txt"), "GetFullPath w#07");
767 Assert.IsTrue (Path.GetFullPath ("c").EndsWith (@"\c"), "GetFullPath w#08");
768 Assert.IsTrue (Path.GetFullPath (@"abc\def").EndsWith (@"abc\def"), "GetFullPath w#09");
769 Assert.IsTrue (Path.GetFullPath (@"\abc\def").EndsWith (@"\abc\def"), "GetFullPath w#10");
770 Assert.AreEqual (@"\\abc\def", Path.GetFullPath (@"\\abc\def"), "GetFullPath w#11");
771 Assert.AreEqual (Directory.GetCurrentDirectory () + @"\abc\def", Path.GetFullPath (@"abc//def"), "GetFullPath w#12");
772 Assert.AreEqual (Directory.GetCurrentDirectory ().Substring (0, 2) + @"\abc\def", Path.GetFullPath ("/abc/def"), "GetFullPath w#13");
773 Assert.AreEqual (@"\\abc\def", Path.GetFullPath ("//abc/def"), "GetFullPath w#14");
775 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
776 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
777 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
778 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
779 Path.GetFullPath ("hey"), "#04");
784 public void GetPathRoot ()
789 current = Directory.GetCurrentDirectory ();
790 expected = current [0].ToString ();
792 current = @"J:\Some\Strange Directory\Name";
796 string pathRoot = Path.GetPathRoot (current);
797 Assert.AreEqual (expected, pathRoot, "GetPathRoot #01");
801 public void GetPathRoot2 ()
803 // note: this method doesn't call Directory.GetCurrentDirectory so it can be
804 // reused for partial trust unit tests in PathCas.cs
808 pathRoot = Path.GetPathRoot ("hola");
809 Assert.AreEqual (String.Empty, pathRoot, "#A1");
810 pathRoot = Path.GetPathRoot (null);
811 Assert.AreEqual (null, pathRoot, "#A2");
814 Assert.AreEqual ("z:", Path.GetPathRoot ("z:"), "GetPathRoot w#01");
815 Assert.AreEqual ("c:\\", Path.GetPathRoot ("c:\\abc\\def"), "GetPathRoot w#02");
816 Assert.AreEqual ("\\", Path.GetPathRoot ("\\"), "GetPathRoot w#03");
817 Assert.AreEqual ("\\\\", Path.GetPathRoot ("\\\\"), "GetPathRoot w#04");
818 Assert.AreEqual ("\\", Path.GetPathRoot ("/"), "GetPathRoot w#05");
819 Assert.AreEqual ("\\\\", Path.GetPathRoot ("//"), "GetPathRoot w#06");
820 Assert.AreEqual (String.Empty, Path.GetPathRoot ("readme.txt"), "GetPathRoot w#07");
821 Assert.AreEqual (String.Empty, Path.GetPathRoot ("c"), "GetPathRoot w#08");
822 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc\\def"), "GetPathRoot w#09");
823 Assert.AreEqual ("\\", Path.GetPathRoot ("\\abc\\def"), "GetPathRoot w#10");
824 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def"), "GetPathRoot w#11");
825 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc//def"), "GetPathRoot w#12");
826 Assert.AreEqual ("\\", Path.GetPathRoot ("/abc/def"), "GetPathRoot w#13");
827 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("//abc/def"), "GetPathRoot w#14");
828 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\"), "GetPathRoot w#15");
829 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\\"), "GetPathRoot w#16");
830 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def\\ghi"), "GetPathRoot w#17");
832 // TODO: Same tests for Unix.
837 public void GetPathRoot_Path_Empty ()
840 Path.GetPathRoot (String.Empty);
842 } catch (ArgumentException ex) {
843 // The path is not of a legal form
844 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
845 Assert.IsNull (ex.InnerException, "#3");
846 Assert.IsNotNull (ex.Message, "#4");
847 Assert.IsNull (ex.ParamName, "#5");
853 [Category ("NotWorking")] // we also throw ArgumentException on 1.0 profile
855 public void GetPathRoot_Path_InvalidPathChars ()
859 Path.GetPathRoot ("hi\0world");
861 } catch (ArgumentException ex) {
862 // Illegal characters in path
863 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
864 Assert.IsNull (ex.InnerException, "#3");
865 Assert.IsNotNull (ex.Message, "#4");
866 Assert.IsNull (ex.ParamName, "#5");
869 Assert.AreEqual (String.Empty, Path.GetPathRoot ("hi\0world"));
874 public void GetPathRoot_Path_Whitespace ()
877 Path.GetPathRoot (" ");
879 } catch (ArgumentException ex) {
880 // The path is not of a legal form
881 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
882 Assert.IsNull (ex.InnerException, "#3");
883 Assert.IsNotNull (ex.Message, "#4");
884 Assert.IsNull (ex.ParamName, "#5");
889 public void GetTempPath ()
891 string getTempPath = Path.GetTempPath ();
892 Assert.IsTrue (getTempPath != String.Empty, "GetTempPath #01");
893 Assert.IsTrue (Path.IsPathRooted (getTempPath), "GetTempPath #02");
894 Assert.AreEqual (Path.DirectorySeparatorChar, getTempPath [getTempPath.Length - 1], "GetTempPath #03");
898 public void GetTempFileName ()
900 string getTempFileName = null;
902 getTempFileName = Path.GetTempFileName ();
903 Assert.IsTrue (getTempFileName != String.Empty, "GetTempFileName #01");
904 Assert.IsTrue (File.Exists (getTempFileName), "GetTempFileName #02");
906 if (getTempFileName != null && getTempFileName != String.Empty){
907 File.Delete (getTempFileName);
913 public void HasExtension ()
915 Assert.AreEqual (true, Path.HasExtension ("foo.txt"), "HasExtension #01");
916 Assert.AreEqual (false, Path.HasExtension ("foo"), "HasExtension #02");
917 Assert.AreEqual (true, Path.HasExtension (path1), "HasExtension #03");
918 Assert.AreEqual (false, Path.HasExtension (path2), "HasExtension #04");
919 Assert.AreEqual (false, Path.HasExtension (null), "HasExtension #05");
920 Assert.AreEqual (false, Path.HasExtension (String.Empty), "HasExtension #06");
921 Assert.AreEqual (false, Path.HasExtension (" "), "HasExtension #07");
922 Assert.AreEqual (false, Path.HasExtension ("."), "HasExtension #08");
923 Assert.AreEqual (false, Path.HasExtension ("end."), "HasExtension #09");
924 Assert.AreEqual (true, Path.HasExtension (".start"), "HasExtension #10");
925 Assert.AreEqual (true, Path.HasExtension (".a"), "HasExtension #11");
926 Assert.AreEqual (false, Path.HasExtension ("a."), "HasExtension #12");
927 Assert.AreEqual (false, Path.HasExtension ("Makefile"), "HasExtension #13");
931 public void HasExtension_Path_InvalidPathChars ()
934 Path.HasExtension ("hi\0world.txt");
936 } catch (ArgumentException ex) {
937 // Illegal characters in path
938 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
939 Assert.IsNull (ex.InnerException, "#3");
940 Assert.IsNotNull (ex.Message, "#4");
941 Assert.IsNull (ex.ParamName, "#5");
946 public void IsPathRooted ()
948 Assert.IsTrue (Path.IsPathRooted (path2), "IsPathRooted #01");
949 Assert.IsTrue (!Path.IsPathRooted (path3), "IsPathRooted #02");
950 Assert.IsTrue (!Path.IsPathRooted (null), "IsPathRooted #03");
951 Assert.IsTrue (!Path.IsPathRooted (String.Empty), "IsPathRooted #04");
952 Assert.IsTrue (!Path.IsPathRooted (" "), "IsPathRooted #05");
953 Assert.IsTrue (Path.IsPathRooted ("/"), "IsPathRooted #06");
954 Assert.IsTrue (Path.IsPathRooted ("//"), "IsPathRooted #07");
955 Assert.IsTrue (!Path.IsPathRooted (":"), "IsPathRooted #08");
958 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #09");
959 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
960 Assert.IsTrue (Path.IsPathRooted ("z:"), "IsPathRooted #11");
961 Assert.IsTrue (Path.IsPathRooted ("z:\\"), "IsPathRooted #12");
962 Assert.IsTrue (Path.IsPathRooted ("z:\\topdir"), "IsPathRooted #13");
963 // This looks MS BUG. It is treated as absolute path
964 Assert.IsTrue (Path.IsPathRooted ("z:curdir"), "IsPathRooted #14");
965 Assert.IsTrue (Path.IsPathRooted ("\\abc\\def"), "IsPathRooted #15");
967 if (Environment.GetEnvironmentVariable ("MONO_IOMAP") == "all"){
968 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #16");
969 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #17");
971 Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");
972 Assert.IsTrue (!Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
973 Assert.IsTrue (!Path.IsPathRooted ("z:"), "IsPathRooted #11");
979 public void IsPathRooted_Path_Empty ()
981 Assert.IsTrue (!Path.IsPathRooted (String.Empty));
985 public void IsPathRooted_Path_InvalidPathChars ()
988 Path.IsPathRooted ("hi\0world");
990 } catch (ArgumentException ex) {
991 // Illegal characters in path.
992 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
993 Assert.IsNull (ex.InnerException, "#3");
994 Assert.IsNotNull (ex.Message, "#4");
995 Assert.IsNull (ex.ParamName, "#5");
1000 public void IsPathRooted_Path_Null ()
1002 Assert.IsTrue (!Path.IsPathRooted (null));
1006 public void IsPathRooted_Path_Whitespace ()
1008 Assert.IsTrue (!Path.IsPathRooted (" "));
1012 public void CanonicalizeDots ()
1014 string current = Path.GetFullPath (".");
1015 Assert.IsTrue (!current.EndsWith ("."), "TestCanonicalizeDotst #01");
1016 string parent = Path.GetFullPath ("..");
1017 Assert.IsTrue (!current.EndsWith (".."), "TestCanonicalizeDotst #02");
1021 public void WindowsSystem32_76191 ()
1023 // check for Unix platforms - see FAQ for more details
1024 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1025 int platform = (int) Environment.OSVersion.Platform;
1026 if ((platform == 4) || (platform == 128) || (platform == 6))
1029 string curdir = Directory.GetCurrentDirectory ();
1032 string system = "C:\\WINDOWS\\system32\\";
1034 string system = Environment.SystemDirectory;
1036 Directory.SetCurrentDirectory (system);
1037 string drive = system.Substring (0, 2);
1038 Assert.AreEqual (system, Path.GetFullPath (drive), "current dir");
1041 Directory.SetCurrentDirectory (curdir);
1046 public void WindowsSystem32_77007 ()
1048 // check for Unix platforms - see FAQ for more details
1049 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1050 int platform = (int) Environment.OSVersion.Platform;
1051 if ((platform == 4) || (platform == 128) || (platform == 6))
1054 string curdir = Directory.GetCurrentDirectory ();
1057 string system = "C:\\WINDOWS\\system32\\";
1059 string system = Environment.SystemDirectory;
1061 Directory.SetCurrentDirectory (system);
1062 // e.g. C:dir (no backslash) will return CurrentDirectory + dir
1063 string dir = system.Substring (0, 2) + "dir";
1064 Assert.AreEqual (Path.Combine (system, "dir"), Path.GetFullPath (dir), "current dir");
1067 Directory.SetCurrentDirectory (curdir);
1073 [Ignore("Java full (canonical) path always returns windows dir in caps")]
1075 public void WindowsDriveC14N_77058 ()
1077 // check for Unix platforms - see FAQ for more details
1078 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1079 int platform = (int) Environment.OSVersion.Platform;
1080 if ((platform == 4) || (platform == 128) || (platform == 6))
1083 Assert.AreEqual (@"C:\Windows\dir", Path.GetFullPath (@"C:\Windows\System32\..\dir"), "1");
1084 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\dir"), "2");
1085 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\dir"), "3");
1086 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\..\dir"), "4");
1087 Assert.AreEqual (@"C:\dir\", Path.GetFullPath (@"C:\Windows\System32\..\.\..\.\..\dir\"), "5");
1091 public void InvalidPathChars_Values ()
1093 char[] invalid = Path.InvalidPathChars;
1096 Assert.AreEqual (36, invalid.Length, "Length");
1098 Assert.AreEqual (15, invalid.Length, "Length");
1100 foreach (char c in invalid) {
1106 if ((i == 0) || (i == 8) || ((i > 15) && (i < 19)) || ((i > 19) && (i < 26)))
1109 // in both 1.1 SP1 and 2.0
1110 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1112 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1115 foreach (char c in invalid) {
1119 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1125 public void InvalidPathChars_Modify ()
1127 char[] expected = Path.InvalidPathChars;
1128 char[] invalid = Path.InvalidPathChars;
1129 char original = invalid[0];
1133 Assert.IsTrue (expected[0] == 'a', "expected");
1134 Assert.AreEqual (expected[0], Path.InvalidPathChars[0], "readonly");
1136 invalid[0] = original;
1142 public void GetInvalidFileNameChars_Values ()
1144 char[] invalid = Path.GetInvalidFileNameChars ();
1146 Assert.AreEqual (41, invalid.Length);
1147 foreach (char c in invalid) {
1151 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1153 // ':', '*', '?', '\', '/'
1154 if ((i == 58) || (i == 42) || (i == 63) || (i == 92) || (i == 47))
1156 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1159 foreach (char c in invalid) {
1162 if ((i == 0) || (i == 47))
1164 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1170 public void GetInvalidFileNameChars_Modify ()
1172 char[] expected = Path.GetInvalidFileNameChars ();
1173 char[] invalid = Path.GetInvalidFileNameChars ();
1175 Assert.IsTrue (expected[0] != 'a', "expected");
1176 Assert.AreEqual (expected[0], Path.GetInvalidFileNameChars ()[0], "readonly");
1180 public void GetInvalidPathChars_Values ()
1182 char[] invalid = Path.GetInvalidPathChars ();
1184 Assert.AreEqual (36, invalid.Length);
1185 foreach (char c in invalid) {
1189 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1191 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1194 foreach (char c in invalid) {
1198 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1204 public void GetInvalidPathChars_Order ()
1207 char [] invalid = Path.GetInvalidPathChars ();
1208 char [] expected = new char [36] { '\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02',
1209 '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D',
1210 '\x0E', '\x0F', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18',
1211 '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' };
1212 Assert.AreEqual (expected.Length, invalid.Length);
1213 for (int i = 0; i < expected.Length; i++ ) {
1214 Assert.AreEqual (expected [i], invalid [i], "Character at position " + i);
1220 public void GetInvalidPathChars_Modify ()
1222 char[] expected = Path.GetInvalidPathChars ();
1223 char[] invalid = Path.GetInvalidPathChars ();
1225 Assert.IsTrue (expected[0] != 'a', "expected");
1226 Assert.AreEqual (expected[0], Path.GetInvalidPathChars ()[0], "readonly");
1230 public void GetRandomFileName ()
1232 string s = Path.GetRandomFileName ();
1233 Assert.AreEqual (12, s.Length, "Length");
1234 char[] invalid = Path.GetInvalidFileNameChars ();
1235 for (int i=0; i < s.Length; i++) {
1237 Assert.AreEqual ('.', s[i], "8");
1239 Assert.IsTrue (Array.IndexOf (invalid, s[i]) == -1, i.ToString ());
1244 public void GetRandomFileNameIsAlphaNumerical ()
1246 string [] names = new string [1000];
1247 for (int i = 0; i < names.Length; i++)
1248 names [i] = Path.GetRandomFileName ();
1250 foreach (string name in names) {
1251 Assert.AreEqual (12, name.Length);
1252 Assert.AreEqual ('.', name [8]);
1254 for (int i = 0; i < 12; i++) {
1259 Assert.IsTrue (('a' <= c && c <= 'z') || ('0' <= c && c <= '9'));
1265 string Concat (string sep, params string [] parms)
1267 return String.Join (sep, parms);
1271 public void Combine_3Params ()
1273 string sep = Path.DirectorySeparatorChar.ToString ();
1276 Path.Combine (null, "two", "three");
1277 Assert.Fail ("#A1-1");
1283 Path.Combine ("one", null, "three");
1284 Assert.Fail ("#A1-2");
1290 Path.Combine ("one", "two", null);
1291 Assert.Fail ("#A1-3");
1296 Assert.AreEqual (Concat (sep, "one", "two", "three"), Path.Combine ("one", "two", "three"), "#A2-1");
1297 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one", "two", "three"), "#A2-2");
1298 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one" + sep, "two", "three"), "#A2-3");
1299 Assert.AreEqual (Concat (sep, sep + "two", "three"), Path.Combine (sep + "one" + sep, sep + "two", "three"), "#A2-4");
1300 Assert.AreEqual (Concat (sep, sep + "three"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three"), "#A2-5");
1302 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three"), Path.Combine (sep + "one" + sep + sep, "two", "three"), "#A3");
1304 Assert.AreEqual ("", Path.Combine ("", "", ""), "#A4");
1308 public void Combine_4Params ()
1310 string sep = Path.DirectorySeparatorChar.ToString ();
1313 Path.Combine (null, "two", "three", "four");
1314 Assert.Fail ("#A1-1");
1320 Path.Combine ("one", null, "three", "four");
1321 Assert.Fail ("#A1-2");
1327 Path.Combine ("one", "two", null, "four");
1328 Assert.Fail ("#A1-3");
1334 Path.Combine ("one", "two", "three", null);
1335 Assert.Fail ("#A1-4");
1340 Assert.AreEqual (Concat (sep, "one", "two", "three", "four"), Path.Combine ("one", "two", "three", "four"), "#A2-1");
1341 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one", "two", "three", "four"), "#A2-2");
1342 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one" + sep, "two", "three", "four"), "#A2-3");
1343 Assert.AreEqual (Concat (sep, sep + "two", "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four"), "#A2-4");
1344 Assert.AreEqual (Concat (sep, sep + "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four"), "#A2-5");
1345 Assert.AreEqual (Concat (sep, sep + "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four"), "#A2-6");
1347 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four"), "#A3");
1349 Assert.AreEqual ("", Path.Combine ("", "", "", ""), "#A4");
1353 public void Combine_ManyParams ()
1355 string sep = Path.DirectorySeparatorChar.ToString ();
1358 Path.Combine (null, "two", "three", "four", "five");
1359 Assert.Fail ("#A1-1");
1365 Path.Combine ("one", null, "three", "four", "five");
1366 Assert.Fail ("#A1-2");
1372 Path.Combine ("one", "two", null, "four", "five");
1373 Assert.Fail ("#A1-3");
1379 Path.Combine ("one", "two", "three", null, "five");
1380 Assert.Fail ("#A1-4");
1386 Path.Combine ("one", "two", "three", "four", null);
1387 Assert.Fail ("#A1-5");
1392 Assert.AreEqual (Concat (sep, "one", "two", "three", "four", "five"), Path.Combine ("one", "two", "three", "four", "five"), "#A2-1");
1393 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one", "two", "three", "four", "five"), "#A2-2");
1394 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, "two", "three", "four", "five"), "#A2-3");
1395 Assert.AreEqual (Concat (sep, sep + "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four", "five"), "#A2-4");
1396 Assert.AreEqual (Concat (sep, sep + "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four", "five"), "#A2-5");
1397 Assert.AreEqual (Concat (sep, sep + "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", "five"), "#A2-6");
1398 Assert.AreEqual (Concat (sep, sep + "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", sep + "five"), "#A2-6");
1400 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four", "five"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four", "five"), "#A3");
1402 Assert.AreEqual ("", Path.Combine ("", "", "", "", ""), "#A4");