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 bool currentIsDSC = current.Length == 1 && current [0] == DSC;
177 testPath = Path.Combine (current, "one");
179 string expected = (currentIsDSC ? String.Empty : current) + DSC + "one";
180 Assert.AreEqual (expected, testPath, "Combine #04");
182 testPath = Path.Combine ("one", current);
183 // LAMESPEC noted in Path.cs
184 Assert.AreEqual (current, testPath, "Combine #05");
186 testPath = Path.Combine (current, expected);
187 Assert.AreEqual (expected, testPath, "Combine #06");
189 testPath = DSC + "one";
190 testPath = Path.Combine (testPath, "two" + DSC);
191 expected = DSC + "one" + DSC + "two" + DSC;
192 Assert.AreEqual (expected, testPath, "Combine #06");
194 testPath = "one" + DSC;
195 testPath = Path.Combine (testPath, DSC + "two");
196 expected = DSC + "two";
197 Assert.AreEqual (expected, testPath, "Combine #06");
199 testPath = "one" + DSC;
200 testPath = Path.Combine (testPath, "two" + DSC);
201 expected = "one" + DSC + "two" + DSC;
202 Assert.AreEqual (expected, testPath, "Combine #07");
205 Assert.AreEqual ("a", Path.Combine (new [] { "a", "" }), "Combine #08");
210 public void Combine_Path1_InvalidPathChars ()
213 Path.Combine ("a\0", "one");
215 } catch (ArgumentException ex) {
216 // Illegal characters in path
217 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
218 Assert.IsNull (ex.InnerException, "#3");
219 Assert.IsNotNull (ex.Message, "#4");
220 Assert.IsNull (ex.ParamName, "#5");
225 public void Combine_Path1_Null ()
228 Path.Combine (null, "one");
230 } catch (ArgumentNullException ex) {
231 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
232 Assert.IsNull (ex.InnerException, "#3");
233 Assert.IsNotNull (ex.Message, "#4");
234 Assert.AreEqual ("path1", ex.ParamName, "#5");
239 public void Combine_Path2_InvalidPathChars ()
242 Path.Combine ("one", "a\0");
244 } catch (ArgumentException ex) {
245 // Illegal characters in path
246 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
247 Assert.IsNull (ex.InnerException, "#3");
248 Assert.IsNotNull (ex.Message, "#4");
249 Assert.IsNull (ex.ParamName, "#5");
254 public void Combine_Path2_Null ()
257 Path.Combine ("one", null);
259 } catch (ArgumentNullException ex) {
260 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
261 Assert.IsNull (ex.InnerException, "#3");
262 Assert.IsNotNull (ex.Message, "#4");
263 Assert.AreEqual ("path2", ex.ParamName, "#5");
268 public void GetDirectoryName ()
270 string [] files = new string [3];
271 files [(int) OsType.Unix] = "/foo";
272 files [(int) OsType.Windows] = "c:\\foo";
273 files [(int) OsType.Mac] = "foo";
275 string testDirName = Path.GetDirectoryName (path1);
276 Assert.AreEqual (files [(int) OS], testDirName, "#A1");
277 testDirName = Path.GetDirectoryName (files [(int) OS] + DSC);
278 Assert.AreEqual (files [(int) OS], testDirName, "#A2");
281 Assert.AreEqual ("C:\\foo", Path.GetDirectoryName ("C:\\foo\\foo.txt"), "#B1");
282 Assert.AreEqual (null, Path.GetDirectoryName ("C:"), "#B2");
283 Assert.AreEqual (null, Path.GetDirectoryName (@"C:\"), "#B3");
284 Assert.AreEqual (@"C:\", Path.GetDirectoryName (@"C:\dir"), "#B4");
285 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\"), "#B5");
286 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"), "#B6");
287 Assert.AreEqual (@"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"), "#B7");
288 Assert.AreEqual (@"C:", Path.GetDirectoryName (@"C:foo.txt"), "#B8");
289 Assert.AreEqual (@"C:dir", Path.GetDirectoryName (@"C:dir\"), "#B9");
291 Assert.AreEqual ("\\foo\\bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#C1");
292 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar/"), "#C2");
293 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar\\xxx"), "#C3");
294 Assert.AreEqual ("\\\\host\\dir\\dir2", Path.GetDirectoryName ("\\\\host\\dir\\\\dir2\\path"), "#C4");
297 Assert.AreEqual (null, Path.GetDirectoryName (@"\\"), "#D1");
298 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server"), "#D2");
299 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server\share"), "#D3");
300 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\"), "#D4");
301 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\dir"), "#D5");
302 Assert.AreEqual (@"\\server\share\dir", Path.GetDirectoryName (@"\\server\share\dir\subdir"), "#D6");
304 Assert.AreEqual ("/etc", Path.GetDirectoryName ("/etc/hostname"), "#B1");
305 Assert.AreEqual ("/foo/bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#B2");
306 Assert.AreEqual ("foo/bar", Path.GetDirectoryName ("foo/bar/"), "#B3");
307 Assert.AreEqual ("/", Path.GetDirectoryName ("/tmp"), "#B4");
308 Assert.IsNull (Path.GetDirectoryName ("/"), "#B5");
309 Assert.AreEqual ("a", Path.GetDirectoryName ("a//b"), "#B6");
314 public void GetDirectoryName_Path_Empty ()
317 Path.GetDirectoryName (String.Empty);
319 } catch (ArgumentException ex) {
320 // The path is not of a legal form
321 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
322 Assert.IsNull (ex.InnerException, "#3");
323 Assert.IsNotNull (ex.Message, "#4");
324 Assert.IsNull (ex.ParamName, "#5");
329 public void GetDirectoryName_Path_InvalidPathChars ()
332 Path.GetDirectoryName ("hi\0world");
334 } catch (ArgumentException ex) {
335 // Illegal characters in path
336 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
337 Assert.IsNull (ex.InnerException, "#3");
338 Assert.IsNotNull (ex.Message, "#4");
339 Assert.IsNull (ex.ParamName, "#5");
344 public void GetDirectoryName_Path_Null ()
346 Assert.IsNull (Path.GetDirectoryName (null));
350 public void GetDirectoryName_Path_Whitespace ()
353 Path.GetDirectoryName (" ");
355 } catch (ArgumentException ex) {
356 // The path is not of a legal form
357 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
358 Assert.IsNull (ex.InnerException, "#3");
359 Assert.IsNotNull (ex.Message, "#4");
360 Assert.IsNull (ex.ParamName, "#5");
365 public void GetExtension ()
367 string testExtn = Path.GetExtension (path1);
369 Assert.AreEqual (".txt", testExtn, "GetExtension #01");
371 testExtn = Path.GetExtension (path2);
372 Assert.AreEqual (String.Empty, testExtn, "GetExtension #02");
374 testExtn = Path.GetExtension (String.Empty);
375 Assert.AreEqual (String.Empty, testExtn, "GetExtension #03");
377 testExtn = Path.GetExtension (null);
378 Assert.AreEqual (null, testExtn, "GetExtension #04");
380 testExtn = Path.GetExtension (" ");
381 Assert.AreEqual (String.Empty, testExtn, "GetExtension #05");
383 testExtn = Path.GetExtension (path1 + ".doc");
384 Assert.AreEqual (".doc", testExtn, "GetExtension #06");
386 testExtn = Path.GetExtension (path1 + ".doc" + DSC + "a.txt");
387 Assert.AreEqual (".txt", testExtn, "GetExtension #07");
389 testExtn = Path.GetExtension (".");
390 Assert.AreEqual (String.Empty, testExtn, "GetExtension #08");
392 testExtn = Path.GetExtension ("end.");
393 Assert.AreEqual (String.Empty, testExtn, "GetExtension #09");
395 testExtn = Path.GetExtension (".start");
396 Assert.AreEqual (".start", testExtn, "GetExtension #10");
398 testExtn = Path.GetExtension (".a");
399 Assert.AreEqual (".a", testExtn, "GetExtension #11");
401 testExtn = Path.GetExtension ("a.");
402 Assert.AreEqual (String.Empty, testExtn, "GetExtension #12");
404 testExtn = Path.GetExtension ("a");
405 Assert.AreEqual (String.Empty, testExtn, "GetExtension #13");
407 testExtn = Path.GetExtension ("makefile");
408 Assert.AreEqual (String.Empty, testExtn, "GetExtension #14");
412 public void GetExtension_Path_InvalidPathChars ()
415 Path.GetExtension ("hi\0world.txt");
417 } catch (ArgumentException ex) {
418 // Illegal characters in path.
419 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
420 Assert.IsNull (ex.InnerException, "#3");
421 Assert.IsNotNull (ex.Message, "#4");
422 Assert.IsNull (ex.ParamName, "#5");
427 public void GetFileName ()
429 string testFileName = Path.GetFileName (path1);
431 Assert.AreEqual ("test.txt", testFileName, "#1");
432 testFileName = Path.GetFileName (null);
433 Assert.AreEqual (null, testFileName, "#2");
434 testFileName = Path.GetFileName (String.Empty);
435 Assert.AreEqual (String.Empty, testFileName, "#3");
436 testFileName = Path.GetFileName (" ");
437 Assert.AreEqual (" ", testFileName, "#4");
441 public void GetFileName_Path_InvalidPathChars ()
444 Path.GetFileName ("hi\0world");
446 } catch (ArgumentException ex) {
447 // Illegal characters in path
448 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
449 Assert.IsNull (ex.InnerException, "#3");
450 Assert.IsNotNull (ex.Message, "#4");
451 Assert.IsNull (ex.ParamName, "#5");
456 public void GetFileNameWithoutExtension ()
458 string testFileName = Path.GetFileNameWithoutExtension (path1);
460 Assert.AreEqual ("test", testFileName, "GetFileNameWithoutExtension #01");
462 testFileName = Path.GetFileNameWithoutExtension (null);
463 Assert.AreEqual (null, testFileName, "GetFileNameWithoutExtension #02");
465 testFileName = Path.GetFileNameWithoutExtension (String.Empty);
466 Assert.AreEqual (String.Empty, testFileName, "GetFileNameWithoutExtension #03");
470 public void GetFileNameWithoutExtension_Path_InvalidPathChars ()
473 Path.GetFileNameWithoutExtension ("hi\0world");
475 } catch (ArgumentException ex) {
476 // Illegal characters in path
477 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
478 Assert.IsNull (ex.InnerException, "#3");
479 Assert.IsNotNull (ex.Message, "#4");
480 Assert.IsNull (ex.ParamName, "#5");
485 public void GetFullPath ()
487 string current = Directory.GetCurrentDirectory ();
488 bool currentIsDSC = current.Length == 1 && current [0] == DSC;
489 string testFullPath = Path.GetFullPath ("foo.txt");
490 string expected = (currentIsDSC ? String.Empty : current) + DSC + "foo.txt";
491 Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
493 testFullPath = Path.GetFullPath ("a//./.././foo.txt");
494 Assert.AreEqual (expected, testFullPath, "GetFullPath #02");
497 Assert.AreEqual ("/bin/bash", Path.GetFullPath ("/../bin/bash"));
503 public void GetFullPath_Unix ()
506 Assert.Ignore ("Running on Windows.");
509 string [,] test = new string [,] {
510 {"root////././././././../root/././../root", "root"},
512 {"root/./", "root/"},
513 {"root/./", "root/"},
514 {"root/../", String.Empty},
515 {"root/../", String.Empty},
516 {"root/../..", String.Empty},
517 {"root/.hiddenfile", "root/.hiddenfile"},
518 {"root/. /", "root/. /"},
519 {"root/.. /", "root/.. /"},
520 {"root/..weirdname", "root/..weirdname"},
521 {"root/..", String.Empty},
522 {"root/../a/b/../../..", String.Empty},
523 {"root/./..", String.Empty},
524 {"..", String.Empty},
526 {"root//dir", "root/dir"},
527 {"root/. /", "root/. /"},
528 {"root/.. /", "root/.. /"},
529 {"root/ . /", "root/ . /"},
530 {"root/ .. /", "root/ .. /"},
531 {"root/./", "root/"},
532 //ERROR! Paths are trimmed
533 // I don't understand this comment^^.
534 // No trimming occurs but the paths are not equal. That's why the test fails. Commented out.
535 //{"root/.. /", "root/.. /"},
536 {".//", String.Empty}
539 for (int i = 0; i < test.GetUpperBound (0); i++) {
540 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
541 String.Format ("GetFullPathUnix #{0}", i));
544 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
545 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
546 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
547 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
548 Path.GetFullPath ("hey"), "#04");
549 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
551 string curdir = Directory.GetCurrentDirectory ();
553 Directory.SetCurrentDirectory ("/");
554 Assert.AreEqual ("/test.txt", Path.GetFullPath ("test.txt"), "xambug #833");
557 Directory.SetCurrentDirectory (curdir);
562 public void GetFullPath_Windows ()
565 Assert.Ignore ("Not running on Windows.");
567 string root = "C:\\";
568 string [,] test = new string [,] {
569 {"root////././././././../root/././../root", "root"},
571 {"root/./", "root\\"},
572 {"root/./", "root\\"},
576 {"root/.hiddenfile", "root\\.hiddenfile"},
577 {"root/. /", "root\\"},
579 {"root/..weirdname", "root\\..weirdname"},
581 {"root/../a/b/../../..", ""},
585 {"root//dir", "root\\dir"},
586 {"root/. /", "root\\"},
588 {"root/./", "root\\"},
593 for (int i = 0; i < test.GetUpperBound (0); i++) {
595 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
596 String.Format ("GetFullPathWindows #{0}", i));
597 } catch (Exception ex) {
598 Assert.Fail (String.Format ("GetFullPathWindows #{0} (\"{1}\") failed: {2}",
599 i, root + test [i, 0], ex.GetType ()));
604 string root2 = @"\\server\share";
605 root = @"\\server\share\";
606 test = new string [,] {
607 {"root////././././././../root/././../root", "root"},
609 {"root/./", "root\\"},
610 {"root/./", "root\\"},
613 {"root/../..", null},
614 {"root/.hiddenfile", "root\\.hiddenfile"},
615 {"root/. /", "root\\"},
617 {"root/..weirdname", "root\\..weirdname"},
619 {"root/../a/b/../../..", null},
623 {"root//dir", "root\\dir"},
624 {"root/. /", "root\\"},
626 {"root/./", "root\\"},
631 for (int i = 0; i < test.GetUpperBound (0); i++) {
632 // "null" means we have to compare against "root2"
633 string res = test [i, 1] != null
637 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
638 String.Format ("GetFullPathWindows UNC #{0}", i));
639 } catch (AssertionException) {
641 } catch (Exception ex) {
642 Assert.Fail (String.Format ("GetFullPathWindows UNC #{0} (\"{1}\") failed: {2}",
643 i, root + test [i, 0], ex.GetType ()));
647 test = new string [,] {
648 {"root////././././././../root/././../root", "root"},
650 {"root/./", "root\\"},
651 {"root/./", "root\\"},
654 {"root/../..", null},
655 {"root/.hiddenfile", "root\\.hiddenfile"},
656 {"root/. /", "root\\"},
658 {"root/..weirdname", "root\\..weirdname"},
660 {"root/../a/b/../../..", null},
664 {"root//dir", "root\\dir"},
665 {"root/. /", "root\\"},
667 {"root/./", "root\\"},
672 string root3 = @"//server/share";
673 root = @"//server/share/";
674 bool needSlashConvert = Path.DirectorySeparatorChar != '/';
676 for (int i = 0; i < test.GetUpperBound (0); i++) {
677 // "null" means we have to compare against "root2"
678 string res = test [i, 1] != null
681 if (needSlashConvert)
682 res = res.Replace ('/', Path.DirectorySeparatorChar);
684 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
685 String.Format ("GetFullPathWindows UNC[2] #{0}", i));
686 } catch (AssertionException) {
688 } catch (Exception ex) {
689 Assert.Fail (String.Format ("GetFullPathWindows UNC[2] #{0} (\"{1}\") failed: {2}",
690 i, root + test [i, 0], ex.GetType ()));
696 public void GetFullPath_Path_Empty ()
699 Path.GetFullPath (String.Empty);
701 } catch (ArgumentException ex) {
702 // The path is not of a legal form
703 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
704 Assert.IsNull (ex.InnerException, "#3");
705 Assert.IsNotNull (ex.Message, "#4");
706 Assert.IsNull (ex.ParamName, "#5");
711 public void GetFullPath_Path_EndingSeparator ()
713 string fp = Path.GetFullPath ("something/");
714 char end = fp [fp.Length - 1];
715 Assert.IsTrue (end == Path.DirectorySeparatorChar);
719 public void GetFullPath_Path_InvalidPathChars ()
722 Path.GetFullPath ("hi\0world");
724 } catch (ArgumentException ex) {
725 // Illegal characters in path
726 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
727 Assert.IsNull (ex.InnerException, "#3");
728 Assert.IsNotNull (ex.Message, "#4");
729 Assert.IsNull (ex.ParamName, "#5");
734 public void GetFullPath_Path_Null ()
737 Path.GetFullPath (null);
739 } catch (ArgumentNullException ex) {
740 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
741 Assert.IsNull (ex.InnerException, "#3");
742 Assert.IsNotNull (ex.Message, "#4");
743 Assert.AreEqual ("path", ex.ParamName, "#5");
748 public void GetFullPath_Path_Whitespace ()
751 Path.GetFullPath (" ");
753 } catch (ArgumentException ex) {
754 // The path is not of a legal form
755 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
756 Assert.IsNull (ex.InnerException, "#3");
757 Assert.IsNotNull (ex.Message, "#4");
758 Assert.IsNull (ex.ParamName, "#5");
763 public void GetFullPath2 ()
766 Assert.AreEqual (@"Z:\", Path.GetFullPath ("Z:"), "GetFullPath w#01");
767 Assert.AreEqual (@"c:\abc\def", Path.GetFullPath (@"c:\abc\def"), "GetFullPath w#02");
768 Assert.IsTrue (Path.GetFullPath (@"\").EndsWith (@"\"), "GetFullPath w#03");
769 // "\\\\" is not allowed
770 Assert.IsTrue (Path.GetFullPath ("/").EndsWith (@"\"), "GetFullPath w#05");
771 // "//" is not allowed
772 Assert.IsTrue (Path.GetFullPath ("readme.txt").EndsWith (@"\readme.txt"), "GetFullPath w#07");
773 Assert.IsTrue (Path.GetFullPath ("c").EndsWith (@"\c"), "GetFullPath w#08");
774 Assert.IsTrue (Path.GetFullPath (@"abc\def").EndsWith (@"abc\def"), "GetFullPath w#09");
775 Assert.IsTrue (Path.GetFullPath (@"\abc\def").EndsWith (@"\abc\def"), "GetFullPath w#10");
776 Assert.AreEqual (@"\\abc\def", Path.GetFullPath (@"\\abc\def"), "GetFullPath w#11");
777 Assert.AreEqual (Directory.GetCurrentDirectory () + @"\abc\def", Path.GetFullPath (@"abc//def"), "GetFullPath w#12");
778 Assert.AreEqual (Directory.GetCurrentDirectory ().Substring (0, 2) + @"\abc\def", Path.GetFullPath ("/abc/def"), "GetFullPath w#13");
779 Assert.AreEqual (@"\\abc\def", Path.GetFullPath ("//abc/def"), "GetFullPath w#14");
781 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
782 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
783 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
784 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
785 Path.GetFullPath ("hey"), "#04");
790 public void GetPathRoot ()
795 current = Directory.GetCurrentDirectory ();
796 expected = current [0].ToString ();
798 current = @"J:\Some\Strange Directory\Name";
802 string pathRoot = Path.GetPathRoot (current);
803 Assert.AreEqual (expected, pathRoot, "GetPathRoot #01");
807 public void GetPathRoot2 ()
809 // note: this method doesn't call Directory.GetCurrentDirectory so it can be
810 // reused for partial trust unit tests in PathCas.cs
814 pathRoot = Path.GetPathRoot ("hola");
815 Assert.AreEqual (String.Empty, pathRoot, "#A1");
816 pathRoot = Path.GetPathRoot (null);
817 Assert.AreEqual (null, pathRoot, "#A2");
820 Assert.AreEqual ("z:", Path.GetPathRoot ("z:"), "GetPathRoot w#01");
821 Assert.AreEqual ("c:\\", Path.GetPathRoot ("c:\\abc\\def"), "GetPathRoot w#02");
822 Assert.AreEqual ("\\", Path.GetPathRoot ("\\"), "GetPathRoot w#03");
823 Assert.AreEqual ("\\\\", Path.GetPathRoot ("\\\\"), "GetPathRoot w#04");
824 Assert.AreEqual ("\\", Path.GetPathRoot ("/"), "GetPathRoot w#05");
825 Assert.AreEqual ("\\\\", Path.GetPathRoot ("//"), "GetPathRoot w#06");
826 Assert.AreEqual (String.Empty, Path.GetPathRoot ("readme.txt"), "GetPathRoot w#07");
827 Assert.AreEqual (String.Empty, Path.GetPathRoot ("c"), "GetPathRoot w#08");
828 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc\\def"), "GetPathRoot w#09");
829 Assert.AreEqual ("\\", Path.GetPathRoot ("\\abc\\def"), "GetPathRoot w#10");
830 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def"), "GetPathRoot w#11");
831 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc//def"), "GetPathRoot w#12");
832 Assert.AreEqual ("\\", Path.GetPathRoot ("/abc/def"), "GetPathRoot w#13");
833 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("//abc/def"), "GetPathRoot w#14");
834 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\"), "GetPathRoot w#15");
835 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\\"), "GetPathRoot w#16");
836 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def\\ghi"), "GetPathRoot w#17");
838 // TODO: Same tests for Unix.
843 public void GetPathRoot_Path_Empty ()
846 Path.GetPathRoot (String.Empty);
848 } catch (ArgumentException ex) {
849 // The path is not of a legal form
850 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
851 Assert.IsNull (ex.InnerException, "#3");
852 Assert.IsNotNull (ex.Message, "#4");
853 Assert.IsNull (ex.ParamName, "#5");
858 public void GetPathRoot_Path_InvalidPathChars ()
861 Path.GetPathRoot ("hi\0world");
863 } catch (ArgumentException ex) {
864 // Illegal characters in path
865 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
866 Assert.IsNull (ex.InnerException, "#3");
867 Assert.IsNotNull (ex.Message, "#4");
868 Assert.IsNull (ex.ParamName, "#5");
873 public void GetPathRoot_Path_Whitespace ()
876 Path.GetPathRoot (" ");
878 } catch (ArgumentException ex) {
879 // The path is not of a legal form
880 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
881 Assert.IsNull (ex.InnerException, "#3");
882 Assert.IsNotNull (ex.Message, "#4");
883 Assert.IsNull (ex.ParamName, "#5");
888 public void GetTempPath ()
890 string getTempPath = Path.GetTempPath ();
891 Assert.IsTrue (getTempPath != String.Empty, "GetTempPath #01");
892 Assert.IsTrue (Path.IsPathRooted (getTempPath), "GetTempPath #02");
893 Assert.AreEqual (Path.DirectorySeparatorChar, getTempPath [getTempPath.Length - 1], "GetTempPath #03");
897 public void GetTempFileName ()
899 string getTempFileName = null;
901 getTempFileName = Path.GetTempFileName ();
902 Assert.IsTrue (getTempFileName != String.Empty, "GetTempFileName #01");
903 Assert.IsTrue (File.Exists (getTempFileName), "GetTempFileName #02");
905 if (getTempFileName != null && getTempFileName != String.Empty){
906 File.Delete (getTempFileName);
912 public void HasExtension ()
914 Assert.AreEqual (true, Path.HasExtension ("foo.txt"), "HasExtension #01");
915 Assert.AreEqual (false, Path.HasExtension ("foo"), "HasExtension #02");
916 Assert.AreEqual (true, Path.HasExtension (path1), "HasExtension #03");
917 Assert.AreEqual (false, Path.HasExtension (path2), "HasExtension #04");
918 Assert.AreEqual (false, Path.HasExtension (null), "HasExtension #05");
919 Assert.AreEqual (false, Path.HasExtension (String.Empty), "HasExtension #06");
920 Assert.AreEqual (false, Path.HasExtension (" "), "HasExtension #07");
921 Assert.AreEqual (false, Path.HasExtension ("."), "HasExtension #08");
922 Assert.AreEqual (false, Path.HasExtension ("end."), "HasExtension #09");
923 Assert.AreEqual (true, Path.HasExtension (".start"), "HasExtension #10");
924 Assert.AreEqual (true, Path.HasExtension (".a"), "HasExtension #11");
925 Assert.AreEqual (false, Path.HasExtension ("a."), "HasExtension #12");
926 Assert.AreEqual (false, Path.HasExtension ("Makefile"), "HasExtension #13");
930 public void HasExtension_Path_InvalidPathChars ()
933 Path.HasExtension ("hi\0world.txt");
935 } catch (ArgumentException ex) {
936 // Illegal characters in path
937 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
938 Assert.IsNull (ex.InnerException, "#3");
939 Assert.IsNotNull (ex.Message, "#4");
940 Assert.IsNull (ex.ParamName, "#5");
945 public void IsPathRooted ()
947 Assert.IsTrue (Path.IsPathRooted (path2), "IsPathRooted #01");
948 Assert.IsTrue (!Path.IsPathRooted (path3), "IsPathRooted #02");
949 Assert.IsTrue (!Path.IsPathRooted (null), "IsPathRooted #03");
950 Assert.IsTrue (!Path.IsPathRooted (String.Empty), "IsPathRooted #04");
951 Assert.IsTrue (!Path.IsPathRooted (" "), "IsPathRooted #05");
952 Assert.IsTrue (Path.IsPathRooted ("/"), "IsPathRooted #06");
953 Assert.IsTrue (Path.IsPathRooted ("//"), "IsPathRooted #07");
954 Assert.IsTrue (!Path.IsPathRooted (":"), "IsPathRooted #08");
957 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #09");
958 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
959 Assert.IsTrue (Path.IsPathRooted ("z:"), "IsPathRooted #11");
960 Assert.IsTrue (Path.IsPathRooted ("z:\\"), "IsPathRooted #12");
961 Assert.IsTrue (Path.IsPathRooted ("z:\\topdir"), "IsPathRooted #13");
962 // This looks MS BUG. It is treated as absolute path
963 Assert.IsTrue (Path.IsPathRooted ("z:curdir"), "IsPathRooted #14");
964 Assert.IsTrue (Path.IsPathRooted ("\\abc\\def"), "IsPathRooted #15");
966 if (Environment.GetEnvironmentVariable ("MONO_IOMAP") == "all"){
967 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #16");
968 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #17");
970 Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");
971 Assert.IsTrue (!Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
972 Assert.IsTrue (!Path.IsPathRooted ("z:"), "IsPathRooted #11");
978 public void IsPathRooted_Path_Empty ()
980 Assert.IsTrue (!Path.IsPathRooted (String.Empty));
984 public void IsPathRooted_Path_InvalidPathChars ()
987 Path.IsPathRooted ("hi\0world");
989 } catch (ArgumentException ex) {
990 // Illegal characters in path.
991 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
992 Assert.IsNull (ex.InnerException, "#3");
993 Assert.IsNotNull (ex.Message, "#4");
994 Assert.IsNull (ex.ParamName, "#5");
999 public void IsPathRooted_Path_Null ()
1001 Assert.IsTrue (!Path.IsPathRooted (null));
1005 public void IsPathRooted_Path_Whitespace ()
1007 Assert.IsTrue (!Path.IsPathRooted (" "));
1011 public void CanonicalizeDots ()
1013 string current = Path.GetFullPath (".");
1014 Assert.IsTrue (!current.EndsWith ("."), "TestCanonicalizeDotst #01");
1015 string parent = Path.GetFullPath ("..");
1016 Assert.IsTrue (!current.EndsWith (".."), "TestCanonicalizeDotst #02");
1020 public void WindowsSystem32_76191 ()
1022 // check for Unix platforms - see FAQ for more details
1023 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1024 int platform = (int) Environment.OSVersion.Platform;
1025 if ((platform == 4) || (platform == 128) || (platform == 6))
1026 Assert.Ignore ("Running on Unix.");
1028 string curdir = Directory.GetCurrentDirectory ();
1030 string system = Environment.SystemDirectory;
1031 Directory.SetCurrentDirectory (system);
1032 string drive = system.Substring (0, 2);
1033 Assert.AreEqual (system, Path.GetFullPath (drive), "current dir");
1036 Directory.SetCurrentDirectory (curdir);
1041 public void WindowsSystem32_77007 ()
1043 // check for Unix platforms - see FAQ for more details
1044 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1045 int platform = (int) Environment.OSVersion.Platform;
1046 if ((platform == 4) || (platform == 128) || (platform == 6))
1047 Assert.Ignore ("Running on Unix.");
1049 string curdir = Directory.GetCurrentDirectory ();
1051 string system = Environment.SystemDirectory;
1052 Directory.SetCurrentDirectory (system);
1053 // e.g. C:dir (no backslash) will return CurrentDirectory + dir
1054 string dir = system.Substring (0, 2) + "dir";
1055 Assert.AreEqual (Path.Combine (system, "dir"), Path.GetFullPath (dir), "current dir");
1058 Directory.SetCurrentDirectory (curdir);
1063 public void WindowsDriveC14N_77058 ()
1065 // check for Unix platforms - see FAQ for more details
1066 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1067 int platform = (int) Environment.OSVersion.Platform;
1068 if ((platform == 4) || (platform == 128) || (platform == 6))
1069 Assert.Ignore ("Running on Unix.");
1071 Assert.AreEqual (@"C:\Windows\dir", Path.GetFullPath (@"C:\Windows\System32\..\dir"), "1");
1072 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\dir"), "2");
1073 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\dir"), "3");
1074 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\..\dir"), "4");
1075 Assert.AreEqual (@"C:\dir\", Path.GetFullPath (@"C:\Windows\System32\..\.\..\.\..\dir\"), "5");
1079 public void InvalidPathChars_Values ()
1081 char[] invalid = Path.InvalidPathChars;
1083 Assert.AreEqual (36, invalid.Length, "Length");
1085 foreach (char c in invalid) {
1091 // in both 1.1 SP1 and 2.0
1092 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1094 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1097 foreach (char c in invalid) {
1101 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1107 public void InvalidPathChars_Modify ()
1109 char[] expected = Path.InvalidPathChars;
1110 char[] invalid = Path.InvalidPathChars;
1111 char original = invalid[0];
1115 Assert.IsTrue (expected[0] == 'a', "expected");
1116 Assert.AreEqual (expected[0], Path.InvalidPathChars[0], "readonly");
1118 invalid[0] = original;
1123 public void GetInvalidFileNameChars_Values ()
1125 char[] invalid = Path.GetInvalidFileNameChars ();
1127 Assert.AreEqual (41, invalid.Length);
1128 foreach (char c in invalid) {
1132 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1134 // ':', '*', '?', '\', '/'
1135 if ((i == 58) || (i == 42) || (i == 63) || (i == 92) || (i == 47))
1137 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1140 foreach (char c in invalid) {
1143 if ((i == 0) || (i == 47))
1145 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1151 public void GetInvalidFileNameChars_Modify ()
1153 char[] expected = Path.GetInvalidFileNameChars ();
1154 char[] invalid = Path.GetInvalidFileNameChars ();
1156 Assert.IsTrue (expected[0] != 'a', "expected");
1157 Assert.AreEqual (expected[0], Path.GetInvalidFileNameChars ()[0], "readonly");
1161 public void GetInvalidPathChars_Values ()
1163 char[] invalid = Path.GetInvalidPathChars ();
1165 Assert.AreEqual (36, invalid.Length);
1166 foreach (char c in invalid) {
1170 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1172 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1175 foreach (char c in invalid) {
1179 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1185 public void GetInvalidPathChars_Order ()
1188 char [] invalid = Path.GetInvalidPathChars ();
1189 char [] expected = new char [36] { '\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02',
1190 '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D',
1191 '\x0E', '\x0F', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18',
1192 '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' };
1193 Assert.AreEqual (expected.Length, invalid.Length);
1194 for (int i = 0; i < expected.Length; i++ ) {
1195 Assert.AreEqual (expected [i], invalid [i], "Character at position " + i);
1201 public void GetInvalidPathChars_Modify ()
1203 char[] expected = Path.GetInvalidPathChars ();
1204 char[] invalid = Path.GetInvalidPathChars ();
1206 Assert.IsTrue (expected[0] != 'a', "expected");
1207 Assert.AreEqual (expected[0], Path.GetInvalidPathChars ()[0], "readonly");
1211 public void GetRandomFileName ()
1213 string s = Path.GetRandomFileName ();
1214 Assert.AreEqual (12, s.Length, "Length");
1215 char[] invalid = Path.GetInvalidFileNameChars ();
1216 for (int i=0; i < s.Length; i++) {
1218 Assert.AreEqual ('.', s[i], "8");
1220 Assert.IsTrue (Array.IndexOf (invalid, s[i]) == -1, i.ToString ());
1225 public void GetRandomFileNameIsAlphaNumerical ()
1227 string [] names = new string [1000];
1228 for (int i = 0; i < names.Length; i++)
1229 names [i] = Path.GetRandomFileName ();
1231 foreach (string name in names) {
1232 Assert.AreEqual (12, name.Length);
1233 Assert.AreEqual ('.', name [8]);
1235 for (int i = 0; i < 12; i++) {
1240 Assert.IsTrue (('a' <= c && c <= 'z') || ('0' <= c && c <= '9'));
1246 string Concat (string sep, params string [] parms)
1248 return String.Join (sep, parms);
1252 public void Combine_3Params ()
1254 string sep = Path.DirectorySeparatorChar.ToString ();
1257 Path.Combine (null, "two", "three");
1258 Assert.Fail ("#A1-1");
1264 Path.Combine ("one", null, "three");
1265 Assert.Fail ("#A1-2");
1271 Path.Combine ("one", "two", null);
1272 Assert.Fail ("#A1-3");
1277 Assert.AreEqual (Concat (sep, "one", "two", "three"), Path.Combine ("one", "two", "three"), "#A2-1");
1278 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one", "two", "three"), "#A2-2");
1279 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one" + sep, "two", "three"), "#A2-3");
1280 Assert.AreEqual (Concat (sep, sep + "two", "three"), Path.Combine (sep + "one" + sep, sep + "two", "three"), "#A2-4");
1281 Assert.AreEqual (Concat (sep, sep + "three"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three"), "#A2-5");
1283 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three"), Path.Combine (sep + "one" + sep + sep, "two", "three"), "#A3");
1285 Assert.AreEqual ("", Path.Combine ("", "", ""), "#A4");
1289 public void Combine_4Params ()
1291 string sep = Path.DirectorySeparatorChar.ToString ();
1294 Path.Combine (null, "two", "three", "four");
1295 Assert.Fail ("#A1-1");
1301 Path.Combine ("one", null, "three", "four");
1302 Assert.Fail ("#A1-2");
1308 Path.Combine ("one", "two", null, "four");
1309 Assert.Fail ("#A1-3");
1315 Path.Combine ("one", "two", "three", null);
1316 Assert.Fail ("#A1-4");
1321 Assert.AreEqual (Concat (sep, "one", "two", "three", "four"), Path.Combine ("one", "two", "three", "four"), "#A2-1");
1322 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one", "two", "three", "four"), "#A2-2");
1323 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one" + sep, "two", "three", "four"), "#A2-3");
1324 Assert.AreEqual (Concat (sep, sep + "two", "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four"), "#A2-4");
1325 Assert.AreEqual (Concat (sep, sep + "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four"), "#A2-5");
1326 Assert.AreEqual (Concat (sep, sep + "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four"), "#A2-6");
1328 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four"), "#A3");
1330 Assert.AreEqual ("", Path.Combine ("", "", "", ""), "#A4");
1334 public void Combine_ManyParams ()
1336 string sep = Path.DirectorySeparatorChar.ToString ();
1339 Path.Combine (null, "two", "three", "four", "five");
1340 Assert.Fail ("#A1-1");
1346 Path.Combine ("one", null, "three", "four", "five");
1347 Assert.Fail ("#A1-2");
1353 Path.Combine ("one", "two", null, "four", "five");
1354 Assert.Fail ("#A1-3");
1360 Path.Combine ("one", "two", "three", null, "five");
1361 Assert.Fail ("#A1-4");
1367 Path.Combine ("one", "two", "three", "four", null);
1368 Assert.Fail ("#A1-5");
1373 Assert.AreEqual (Concat (sep, "one", "two", "three", "four", "five"), Path.Combine ("one", "two", "three", "four", "five"), "#A2-1");
1374 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one", "two", "three", "four", "five"), "#A2-2");
1375 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, "two", "three", "four", "five"), "#A2-3");
1376 Assert.AreEqual (Concat (sep, sep + "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four", "five"), "#A2-4");
1377 Assert.AreEqual (Concat (sep, sep + "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four", "five"), "#A2-5");
1378 Assert.AreEqual (Concat (sep, sep + "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", "five"), "#A2-6");
1379 Assert.AreEqual (Concat (sep, sep + "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", sep + "five"), "#A2-6");
1381 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four", "five"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four", "five"), "#A3");
1383 Assert.AreEqual ("", Path.Combine ("", "", "", "", ""), "#A4");