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");
204 Assert.AreEqual ("a", Path.Combine (new [] { "a", "" }), "Combine #08");
208 public void Combine_Path1_InvalidPathChars ()
211 Path.Combine ("a\0", "one");
213 } catch (ArgumentException ex) {
214 // Illegal characters in path
215 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
216 Assert.IsNull (ex.InnerException, "#3");
217 Assert.IsNotNull (ex.Message, "#4");
218 Assert.IsNull (ex.ParamName, "#5");
223 public void Combine_Path1_Null ()
226 Path.Combine (null, "one");
228 } catch (ArgumentNullException ex) {
229 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
230 Assert.IsNull (ex.InnerException, "#3");
231 Assert.IsNotNull (ex.Message, "#4");
232 Assert.AreEqual ("path1", ex.ParamName, "#5");
237 public void Combine_Path2_InvalidPathChars ()
240 Path.Combine ("one", "a\0");
242 } catch (ArgumentException ex) {
243 // Illegal characters in path
244 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
245 Assert.IsNull (ex.InnerException, "#3");
246 Assert.IsNotNull (ex.Message, "#4");
247 Assert.IsNull (ex.ParamName, "#5");
252 public void Combine_Path2_Null ()
255 Path.Combine ("one", null);
257 } catch (ArgumentNullException ex) {
258 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
259 Assert.IsNull (ex.InnerException, "#3");
260 Assert.IsNotNull (ex.Message, "#4");
261 Assert.AreEqual ("path2", ex.ParamName, "#5");
266 public void GetDirectoryName ()
268 string [] files = new string [3];
269 files [(int) OsType.Unix] = "/foo";
270 files [(int) OsType.Windows] = "c:\\foo";
271 files [(int) OsType.Mac] = "foo";
273 string testDirName = Path.GetDirectoryName (path1);
274 Assert.AreEqual (files [(int) OS], testDirName, "#A1");
275 testDirName = Path.GetDirectoryName (files [(int) OS] + DSC);
276 Assert.AreEqual (files [(int) OS], testDirName, "#A2");
279 Assert.AreEqual ("C:\\foo", Path.GetDirectoryName ("C:\\foo\\foo.txt"), "#B1");
280 Assert.AreEqual (null, Path.GetDirectoryName ("C:"), "#B2");
281 Assert.AreEqual (null, Path.GetDirectoryName (@"C:\"), "#B3");
282 Assert.AreEqual (@"C:\", Path.GetDirectoryName (@"C:\dir"), "#B4");
283 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\"), "#B5");
284 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"), "#B6");
285 Assert.AreEqual (@"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"), "#B7");
286 Assert.AreEqual (@"C:", Path.GetDirectoryName (@"C:foo.txt"), "#B8");
287 Assert.AreEqual (@"C:dir", Path.GetDirectoryName (@"C:dir\"), "#B9");
289 Assert.AreEqual ("\\foo\\bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#C1");
290 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar/"), "#C2");
291 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar\\xxx"), "#C3");
292 Assert.AreEqual ("\\\\host\\dir\\dir2", Path.GetDirectoryName ("\\\\host\\dir\\\\dir2\\path"), "#C4");
295 Assert.AreEqual (null, Path.GetDirectoryName (@"\\"), "#D1");
296 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server"), "#D2");
297 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server\share"), "#D3");
298 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\"), "#D4");
299 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\dir"), "#D5");
300 Assert.AreEqual (@"\\server\share\dir", Path.GetDirectoryName (@"\\server\share\dir\subdir"), "#D6");
302 Assert.AreEqual ("/etc", Path.GetDirectoryName ("/etc/hostname"), "#B1");
303 Assert.AreEqual ("/foo/bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#B2");
304 Assert.AreEqual ("foo/bar", Path.GetDirectoryName ("foo/bar/"), "#B3");
305 Assert.AreEqual ("/", Path.GetDirectoryName ("/tmp"), "#B4");
306 Assert.IsNull (Path.GetDirectoryName ("/"), "#B5");
307 Assert.AreEqual ("a", Path.GetDirectoryName ("a//b"), "#B6");
312 public void GetDirectoryName_Path_Empty ()
315 Path.GetDirectoryName (String.Empty);
317 } catch (ArgumentException ex) {
318 // The path is not of a legal form
319 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
320 Assert.IsNull (ex.InnerException, "#3");
321 Assert.IsNotNull (ex.Message, "#4");
322 Assert.IsNull (ex.ParamName, "#5");
327 public void GetDirectoryName_Path_InvalidPathChars ()
330 Path.GetDirectoryName ("hi\0world");
332 } catch (ArgumentException ex) {
333 // Illegal characters in path
334 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
335 Assert.IsNull (ex.InnerException, "#3");
336 Assert.IsNotNull (ex.Message, "#4");
337 Assert.IsNull (ex.ParamName, "#5");
342 public void GetDirectoryName_Path_Null ()
344 Assert.IsNull (Path.GetDirectoryName (null));
348 public void GetDirectoryName_Path_Whitespace ()
351 Path.GetDirectoryName (" ");
353 } catch (ArgumentException ex) {
354 // The path is not of a legal form
355 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
356 Assert.IsNull (ex.InnerException, "#3");
357 Assert.IsNotNull (ex.Message, "#4");
358 Assert.IsNull (ex.ParamName, "#5");
363 public void GetExtension ()
365 string testExtn = Path.GetExtension (path1);
367 Assert.AreEqual (".txt", testExtn, "GetExtension #01");
369 testExtn = Path.GetExtension (path2);
370 Assert.AreEqual (String.Empty, testExtn, "GetExtension #02");
372 testExtn = Path.GetExtension (String.Empty);
373 Assert.AreEqual (String.Empty, testExtn, "GetExtension #03");
375 testExtn = Path.GetExtension (null);
376 Assert.AreEqual (null, testExtn, "GetExtension #04");
378 testExtn = Path.GetExtension (" ");
379 Assert.AreEqual (String.Empty, testExtn, "GetExtension #05");
381 testExtn = Path.GetExtension (path1 + ".doc");
382 Assert.AreEqual (".doc", testExtn, "GetExtension #06");
384 testExtn = Path.GetExtension (path1 + ".doc" + DSC + "a.txt");
385 Assert.AreEqual (".txt", testExtn, "GetExtension #07");
387 testExtn = Path.GetExtension (".");
388 Assert.AreEqual (String.Empty, testExtn, "GetExtension #08");
390 testExtn = Path.GetExtension ("end.");
391 Assert.AreEqual (String.Empty, testExtn, "GetExtension #09");
393 testExtn = Path.GetExtension (".start");
394 Assert.AreEqual (".start", testExtn, "GetExtension #10");
396 testExtn = Path.GetExtension (".a");
397 Assert.AreEqual (".a", testExtn, "GetExtension #11");
399 testExtn = Path.GetExtension ("a.");
400 Assert.AreEqual (String.Empty, testExtn, "GetExtension #12");
402 testExtn = Path.GetExtension ("a");
403 Assert.AreEqual (String.Empty, testExtn, "GetExtension #13");
405 testExtn = Path.GetExtension ("makefile");
406 Assert.AreEqual (String.Empty, testExtn, "GetExtension #14");
410 public void GetExtension_Path_InvalidPathChars ()
413 Path.GetExtension ("hi\0world.txt");
415 } catch (ArgumentException ex) {
416 // Illegal characters in path.
417 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
418 Assert.IsNull (ex.InnerException, "#3");
419 Assert.IsNotNull (ex.Message, "#4");
420 Assert.IsNull (ex.ParamName, "#5");
425 public void GetFileName ()
427 string testFileName = Path.GetFileName (path1);
429 Assert.AreEqual ("test.txt", testFileName, "#1");
430 testFileName = Path.GetFileName (null);
431 Assert.AreEqual (null, testFileName, "#2");
432 testFileName = Path.GetFileName (String.Empty);
433 Assert.AreEqual (String.Empty, testFileName, "#3");
434 testFileName = Path.GetFileName (" ");
435 Assert.AreEqual (" ", testFileName, "#4");
439 public void GetFileName_Path_InvalidPathChars ()
442 Path.GetFileName ("hi\0world");
444 } catch (ArgumentException ex) {
445 // Illegal characters in path
446 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
447 Assert.IsNull (ex.InnerException, "#3");
448 Assert.IsNotNull (ex.Message, "#4");
449 Assert.IsNull (ex.ParamName, "#5");
454 public void GetFileNameWithoutExtension ()
456 string testFileName = Path.GetFileNameWithoutExtension (path1);
458 Assert.AreEqual ("test", testFileName, "GetFileNameWithoutExtension #01");
460 testFileName = Path.GetFileNameWithoutExtension (null);
461 Assert.AreEqual (null, testFileName, "GetFileNameWithoutExtension #02");
463 testFileName = Path.GetFileNameWithoutExtension (String.Empty);
464 Assert.AreEqual (String.Empty, testFileName, "GetFileNameWithoutExtension #03");
468 public void GetFileNameWithoutExtension_Path_InvalidPathChars ()
471 Path.GetFileNameWithoutExtension ("hi\0world");
473 } catch (ArgumentException ex) {
474 // Illegal characters in path
475 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
476 Assert.IsNull (ex.InnerException, "#3");
477 Assert.IsNotNull (ex.Message, "#4");
478 Assert.IsNull (ex.ParamName, "#5");
483 public void GetFullPath ()
485 string current = Directory.GetCurrentDirectory ();
486 bool currentIsDSC = current.Length == 1 && current [0] == DSC;
487 string testFullPath = Path.GetFullPath ("foo.txt");
488 string expected = (currentIsDSC ? String.Empty : current) + DSC + "foo.txt";
489 Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
491 testFullPath = Path.GetFullPath ("a//./.././foo.txt");
492 Assert.AreEqual (expected, testFullPath, "GetFullPath #02");
495 Assert.AreEqual ("/bin/bash", Path.GetFullPath ("/../bin/bash"));
501 public void GetFullPath_Unix ()
504 Assert.Ignore ("Running on Windows.");
507 string [,] test = new string [,] {
508 {"root////././././././../root/././../root", "root"},
510 {"root/./", "root/"},
511 {"root/./", "root/"},
512 {"root/../", String.Empty},
513 {"root/../", String.Empty},
514 {"root/../..", String.Empty},
515 {"root/.hiddenfile", "root/.hiddenfile"},
516 {"root/. /", "root/. /"},
517 {"root/.. /", "root/.. /"},
518 {"root/..weirdname", "root/..weirdname"},
519 {"root/..", String.Empty},
520 {"root/../a/b/../../..", String.Empty},
521 {"root/./..", String.Empty},
522 {"..", String.Empty},
524 {"root//dir", "root/dir"},
525 {"root/. /", "root/. /"},
526 {"root/.. /", "root/.. /"},
527 {"root/ . /", "root/ . /"},
528 {"root/ .. /", "root/ .. /"},
529 {"root/./", "root/"},
530 //ERROR! Paths are trimmed
531 // I don't understand this comment^^.
532 // No trimming occurs but the paths are not equal. That's why the test fails. Commented out.
533 //{"root/.. /", "root/.. /"},
534 {".//", String.Empty}
537 for (int i = 0; i < test.GetUpperBound (0); i++) {
538 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
539 String.Format ("GetFullPathUnix #{0}", i));
542 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
543 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
544 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
545 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
546 Path.GetFullPath ("hey"), "#04");
547 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
549 string curdir = Directory.GetCurrentDirectory ();
551 Directory.SetCurrentDirectory ("/");
552 Assert.AreEqual ("/test.txt", Path.GetFullPath ("test.txt"), "xambug #833");
555 Directory.SetCurrentDirectory (curdir);
560 public void GetFullPath_Windows ()
563 Assert.Ignore ("Not running on Windows.");
565 string root = "C:\\";
566 string [,] test = new string [,] {
567 {"root////././././././../root/././../root", "root"},
569 {"root/./", "root\\"},
570 {"root/./", "root\\"},
574 {"root/.hiddenfile", "root\\.hiddenfile"},
575 {"root/. /", "root\\"},
577 {"root/..weirdname", "root\\..weirdname"},
579 {"root/../a/b/../../..", ""},
583 {"root//dir", "root\\dir"},
584 {"root/. /", "root\\"},
586 {"root/./", "root\\"},
591 for (int i = 0; i < test.GetUpperBound (0); i++) {
593 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
594 String.Format ("GetFullPathWindows #{0}", i));
595 } catch (Exception ex) {
596 Assert.Fail (String.Format ("GetFullPathWindows #{0} (\"{1}\") failed: {2}",
597 i, root + test [i, 0], ex.GetType ()));
602 string root2 = @"\\server\share";
603 root = @"\\server\share\";
604 test = new string [,] {
605 {"root////././././././../root/././../root", "root"},
607 {"root/./", "root\\"},
608 {"root/./", "root\\"},
611 {"root/../..", null},
612 {"root/.hiddenfile", "root\\.hiddenfile"},
613 {"root/. /", "root\\"},
615 {"root/..weirdname", "root\\..weirdname"},
617 {"root/../a/b/../../..", null},
621 {"root//dir", "root\\dir"},
622 {"root/. /", "root\\"},
624 {"root/./", "root\\"},
629 for (int i = 0; i < test.GetUpperBound (0); i++) {
630 // "null" means we have to compare against "root2"
631 string res = test [i, 1] != null
635 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
636 String.Format ("GetFullPathWindows UNC #{0}", i));
637 } catch (AssertionException) {
639 } catch (Exception ex) {
640 Assert.Fail (String.Format ("GetFullPathWindows UNC #{0} (\"{1}\") failed: {2}",
641 i, root + test [i, 0], ex.GetType ()));
645 test = new string [,] {
646 {"root////././././././../root/././../root", "root"},
648 {"root/./", "root\\"},
649 {"root/./", "root\\"},
652 {"root/../..", null},
653 {"root/.hiddenfile", "root\\.hiddenfile"},
654 {"root/. /", "root\\"},
656 {"root/..weirdname", "root\\..weirdname"},
658 {"root/../a/b/../../..", null},
662 {"root//dir", "root\\dir"},
663 {"root/. /", "root\\"},
665 {"root/./", "root\\"},
670 string root3 = @"//server/share";
671 root = @"//server/share/";
672 bool needSlashConvert = Path.DirectorySeparatorChar != '/';
674 for (int i = 0; i < test.GetUpperBound (0); i++) {
675 // "null" means we have to compare against "root2"
676 string res = test [i, 1] != null
679 if (needSlashConvert)
680 res = res.Replace ('/', Path.DirectorySeparatorChar);
682 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
683 String.Format ("GetFullPathWindows UNC[2] #{0}", i));
684 } catch (AssertionException) {
686 } catch (Exception ex) {
687 Assert.Fail (String.Format ("GetFullPathWindows UNC[2] #{0} (\"{1}\") failed: {2}",
688 i, root + test [i, 0], ex.GetType ()));
694 public void GetFullPath_Path_Empty ()
697 Path.GetFullPath (String.Empty);
699 } catch (ArgumentException ex) {
700 // The path is not of a legal form
701 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
702 Assert.IsNull (ex.InnerException, "#3");
703 Assert.IsNotNull (ex.Message, "#4");
704 Assert.IsNull (ex.ParamName, "#5");
709 public void GetFullPath_Path_EndingSeparator ()
711 string fp = Path.GetFullPath ("something/");
712 char end = fp [fp.Length - 1];
713 Assert.IsTrue (end == Path.DirectorySeparatorChar);
717 public void GetFullPath_Path_InvalidPathChars ()
720 Path.GetFullPath ("hi\0world");
722 } catch (ArgumentException ex) {
723 // Illegal characters in path
724 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
725 Assert.IsNull (ex.InnerException, "#3");
726 Assert.IsNotNull (ex.Message, "#4");
727 Assert.IsNull (ex.ParamName, "#5");
732 public void GetFullPath_Path_Null ()
735 Path.GetFullPath (null);
737 } catch (ArgumentNullException ex) {
738 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
739 Assert.IsNull (ex.InnerException, "#3");
740 Assert.IsNotNull (ex.Message, "#4");
741 Assert.AreEqual ("path", ex.ParamName, "#5");
746 public void GetFullPath_Path_Whitespace ()
749 Path.GetFullPath (" ");
751 } catch (ArgumentException ex) {
752 // The path is not of a legal form
753 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
754 Assert.IsNull (ex.InnerException, "#3");
755 Assert.IsNotNull (ex.Message, "#4");
756 Assert.IsNull (ex.ParamName, "#5");
761 public void GetFullPath2 ()
764 Assert.AreEqual (@"Z:\", Path.GetFullPath ("Z:"), "GetFullPath w#01");
765 Assert.AreEqual (@"c:\abc\def", Path.GetFullPath (@"c:\abc\def"), "GetFullPath w#02");
766 Assert.IsTrue (Path.GetFullPath (@"\").EndsWith (@"\"), "GetFullPath w#03");
767 // "\\\\" is not allowed
768 Assert.IsTrue (Path.GetFullPath ("/").EndsWith (@"\"), "GetFullPath w#05");
769 // "//" is not allowed
770 Assert.IsTrue (Path.GetFullPath ("readme.txt").EndsWith (@"\readme.txt"), "GetFullPath w#07");
771 Assert.IsTrue (Path.GetFullPath ("c").EndsWith (@"\c"), "GetFullPath w#08");
772 Assert.IsTrue (Path.GetFullPath (@"abc\def").EndsWith (@"abc\def"), "GetFullPath w#09");
773 Assert.IsTrue (Path.GetFullPath (@"\abc\def").EndsWith (@"\abc\def"), "GetFullPath w#10");
774 Assert.AreEqual (@"\\abc\def", Path.GetFullPath (@"\\abc\def"), "GetFullPath w#11");
775 Assert.AreEqual (Directory.GetCurrentDirectory () + @"\abc\def", Path.GetFullPath (@"abc//def"), "GetFullPath w#12");
776 Assert.AreEqual (Directory.GetCurrentDirectory ().Substring (0, 2) + @"\abc\def", Path.GetFullPath ("/abc/def"), "GetFullPath w#13");
777 Assert.AreEqual (@"\\abc\def", Path.GetFullPath ("//abc/def"), "GetFullPath w#14");
779 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
780 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
781 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
782 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
783 Path.GetFullPath ("hey"), "#04");
788 public void GetPathRoot ()
793 current = Directory.GetCurrentDirectory ();
794 expected = current [0].ToString ();
796 current = @"J:\Some\Strange Directory\Name";
800 string pathRoot = Path.GetPathRoot (current);
801 Assert.AreEqual (expected, pathRoot, "GetPathRoot #01");
805 public void GetPathRoot2 ()
807 // note: this method doesn't call Directory.GetCurrentDirectory so it can be
808 // reused for partial trust unit tests in PathCas.cs
812 pathRoot = Path.GetPathRoot ("hola");
813 Assert.AreEqual (String.Empty, pathRoot, "#A1");
814 pathRoot = Path.GetPathRoot (null);
815 Assert.AreEqual (null, pathRoot, "#A2");
818 Assert.AreEqual ("z:", Path.GetPathRoot ("z:"), "GetPathRoot w#01");
819 Assert.AreEqual ("c:\\", Path.GetPathRoot ("c:\\abc\\def"), "GetPathRoot w#02");
820 Assert.AreEqual ("\\", Path.GetPathRoot ("\\"), "GetPathRoot w#03");
821 Assert.AreEqual ("\\\\", Path.GetPathRoot ("\\\\"), "GetPathRoot w#04");
822 Assert.AreEqual ("\\", Path.GetPathRoot ("/"), "GetPathRoot w#05");
823 Assert.AreEqual ("\\\\", Path.GetPathRoot ("//"), "GetPathRoot w#06");
824 Assert.AreEqual (String.Empty, Path.GetPathRoot ("readme.txt"), "GetPathRoot w#07");
825 Assert.AreEqual (String.Empty, Path.GetPathRoot ("c"), "GetPathRoot w#08");
826 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc\\def"), "GetPathRoot w#09");
827 Assert.AreEqual ("\\", Path.GetPathRoot ("\\abc\\def"), "GetPathRoot w#10");
828 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def"), "GetPathRoot w#11");
829 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc//def"), "GetPathRoot w#12");
830 Assert.AreEqual ("\\", Path.GetPathRoot ("/abc/def"), "GetPathRoot w#13");
831 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("//abc/def"), "GetPathRoot w#14");
832 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\"), "GetPathRoot w#15");
833 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\\"), "GetPathRoot w#16");
834 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def\\ghi"), "GetPathRoot w#17");
836 // TODO: Same tests for Unix.
841 public void GetPathRoot_Path_Empty ()
844 Path.GetPathRoot (String.Empty);
846 } catch (ArgumentException ex) {
847 // The path is not of a legal form
848 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
849 Assert.IsNull (ex.InnerException, "#3");
850 Assert.IsNotNull (ex.Message, "#4");
851 Assert.IsNull (ex.ParamName, "#5");
856 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");
871 public void GetPathRoot_Path_Whitespace ()
874 Path.GetPathRoot (" ");
876 } catch (ArgumentException ex) {
877 // The path is not of a legal form
878 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
879 Assert.IsNull (ex.InnerException, "#3");
880 Assert.IsNotNull (ex.Message, "#4");
881 Assert.IsNull (ex.ParamName, "#5");
886 public void GetTempPath ()
888 string getTempPath = Path.GetTempPath ();
889 Assert.IsTrue (getTempPath != String.Empty, "GetTempPath #01");
890 Assert.IsTrue (Path.IsPathRooted (getTempPath), "GetTempPath #02");
891 Assert.AreEqual (Path.DirectorySeparatorChar, getTempPath [getTempPath.Length - 1], "GetTempPath #03");
895 public void GetTempFileName ()
897 string getTempFileName = null;
899 getTempFileName = Path.GetTempFileName ();
900 Assert.IsTrue (getTempFileName != String.Empty, "GetTempFileName #01");
901 Assert.IsTrue (File.Exists (getTempFileName), "GetTempFileName #02");
903 if (getTempFileName != null && getTempFileName != String.Empty){
904 File.Delete (getTempFileName);
910 public void HasExtension ()
912 Assert.AreEqual (true, Path.HasExtension ("foo.txt"), "HasExtension #01");
913 Assert.AreEqual (false, Path.HasExtension ("foo"), "HasExtension #02");
914 Assert.AreEqual (true, Path.HasExtension (path1), "HasExtension #03");
915 Assert.AreEqual (false, Path.HasExtension (path2), "HasExtension #04");
916 Assert.AreEqual (false, Path.HasExtension (null), "HasExtension #05");
917 Assert.AreEqual (false, Path.HasExtension (String.Empty), "HasExtension #06");
918 Assert.AreEqual (false, Path.HasExtension (" "), "HasExtension #07");
919 Assert.AreEqual (false, Path.HasExtension ("."), "HasExtension #08");
920 Assert.AreEqual (false, Path.HasExtension ("end."), "HasExtension #09");
921 Assert.AreEqual (true, Path.HasExtension (".start"), "HasExtension #10");
922 Assert.AreEqual (true, Path.HasExtension (".a"), "HasExtension #11");
923 Assert.AreEqual (false, Path.HasExtension ("a."), "HasExtension #12");
924 Assert.AreEqual (false, Path.HasExtension ("Makefile"), "HasExtension #13");
928 public void HasExtension_Path_InvalidPathChars ()
931 Path.HasExtension ("hi\0world.txt");
933 } catch (ArgumentException ex) {
934 // Illegal characters in path
935 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
936 Assert.IsNull (ex.InnerException, "#3");
937 Assert.IsNotNull (ex.Message, "#4");
938 Assert.IsNull (ex.ParamName, "#5");
943 public void IsPathRooted ()
945 Assert.IsTrue (Path.IsPathRooted (path2), "IsPathRooted #01");
946 Assert.IsTrue (!Path.IsPathRooted (path3), "IsPathRooted #02");
947 Assert.IsTrue (!Path.IsPathRooted (null), "IsPathRooted #03");
948 Assert.IsTrue (!Path.IsPathRooted (String.Empty), "IsPathRooted #04");
949 Assert.IsTrue (!Path.IsPathRooted (" "), "IsPathRooted #05");
950 Assert.IsTrue (Path.IsPathRooted ("/"), "IsPathRooted #06");
951 Assert.IsTrue (Path.IsPathRooted ("//"), "IsPathRooted #07");
952 Assert.IsTrue (!Path.IsPathRooted (":"), "IsPathRooted #08");
955 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #09");
956 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
957 Assert.IsTrue (Path.IsPathRooted ("z:"), "IsPathRooted #11");
958 Assert.IsTrue (Path.IsPathRooted ("z:\\"), "IsPathRooted #12");
959 Assert.IsTrue (Path.IsPathRooted ("z:\\topdir"), "IsPathRooted #13");
960 // This looks MS BUG. It is treated as absolute path
961 Assert.IsTrue (Path.IsPathRooted ("z:curdir"), "IsPathRooted #14");
962 Assert.IsTrue (Path.IsPathRooted ("\\abc\\def"), "IsPathRooted #15");
964 if (Environment.GetEnvironmentVariable ("MONO_IOMAP") == "all"){
965 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #16");
966 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #17");
968 Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");
969 Assert.IsTrue (!Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
970 Assert.IsTrue (!Path.IsPathRooted ("z:"), "IsPathRooted #11");
976 public void IsPathRooted_Path_Empty ()
978 Assert.IsTrue (!Path.IsPathRooted (String.Empty));
982 public void IsPathRooted_Path_InvalidPathChars ()
985 Path.IsPathRooted ("hi\0world");
987 } catch (ArgumentException ex) {
988 // Illegal characters in path.
989 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
990 Assert.IsNull (ex.InnerException, "#3");
991 Assert.IsNotNull (ex.Message, "#4");
992 Assert.IsNull (ex.ParamName, "#5");
997 public void IsPathRooted_Path_Null ()
999 Assert.IsTrue (!Path.IsPathRooted (null));
1003 public void IsPathRooted_Path_Whitespace ()
1005 Assert.IsTrue (!Path.IsPathRooted (" "));
1009 public void CanonicalizeDots ()
1011 string current = Path.GetFullPath (".");
1012 Assert.IsTrue (!current.EndsWith ("."), "TestCanonicalizeDotst #01");
1013 string parent = Path.GetFullPath ("..");
1014 Assert.IsTrue (!current.EndsWith (".."), "TestCanonicalizeDotst #02");
1018 public void WindowsSystem32_76191 ()
1020 // check for Unix platforms - see FAQ for more details
1021 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1022 int platform = (int) Environment.OSVersion.Platform;
1023 if ((platform == 4) || (platform == 128) || (platform == 6))
1024 Assert.Ignore ("Running on Unix.");
1026 string curdir = Directory.GetCurrentDirectory ();
1028 string system = Environment.SystemDirectory;
1029 Directory.SetCurrentDirectory (system);
1030 string drive = system.Substring (0, 2);
1031 Assert.AreEqual (system, Path.GetFullPath (drive), "current dir");
1034 Directory.SetCurrentDirectory (curdir);
1039 public void WindowsSystem32_77007 ()
1041 // check for Unix platforms - see FAQ for more details
1042 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1043 int platform = (int) Environment.OSVersion.Platform;
1044 if ((platform == 4) || (platform == 128) || (platform == 6))
1045 Assert.Ignore ("Running on Unix.");
1047 string curdir = Directory.GetCurrentDirectory ();
1049 string system = Environment.SystemDirectory;
1050 Directory.SetCurrentDirectory (system);
1051 // e.g. C:dir (no backslash) will return CurrentDirectory + dir
1052 string dir = system.Substring (0, 2) + "dir";
1053 Assert.AreEqual (Path.Combine (system, "dir"), Path.GetFullPath (dir), "current dir");
1056 Directory.SetCurrentDirectory (curdir);
1061 public void WindowsDriveC14N_77058 ()
1063 // check for Unix platforms - see FAQ for more details
1064 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1065 int platform = (int) Environment.OSVersion.Platform;
1066 if ((platform == 4) || (platform == 128) || (platform == 6))
1067 Assert.Ignore ("Running on Unix.");
1069 Assert.AreEqual (@"C:\Windows\dir", Path.GetFullPath (@"C:\Windows\System32\..\dir"), "1");
1070 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\dir"), "2");
1071 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\dir"), "3");
1072 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\..\dir"), "4");
1073 Assert.AreEqual (@"C:\dir\", Path.GetFullPath (@"C:\Windows\System32\..\.\..\.\..\dir\"), "5");
1077 public void InvalidPathChars_Values ()
1079 char[] invalid = Path.InvalidPathChars;
1081 Assert.AreEqual (36, invalid.Length, "Length");
1083 foreach (char c in invalid) {
1089 // in both 1.1 SP1 and 2.0
1090 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1092 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1095 foreach (char c in invalid) {
1099 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1105 public void InvalidPathChars_Modify ()
1107 char[] expected = Path.InvalidPathChars;
1108 char[] invalid = Path.InvalidPathChars;
1109 char original = invalid[0];
1113 Assert.IsTrue (expected[0] == 'a', "expected");
1114 Assert.AreEqual (expected[0], Path.InvalidPathChars[0], "readonly");
1116 invalid[0] = original;
1121 public void GetInvalidFileNameChars_Values ()
1123 char[] invalid = Path.GetInvalidFileNameChars ();
1125 Assert.AreEqual (41, invalid.Length);
1126 foreach (char c in invalid) {
1130 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1132 // ':', '*', '?', '\', '/'
1133 if ((i == 58) || (i == 42) || (i == 63) || (i == 92) || (i == 47))
1135 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1138 foreach (char c in invalid) {
1141 if ((i == 0) || (i == 47))
1143 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1149 public void GetInvalidFileNameChars_Modify ()
1151 char[] expected = Path.GetInvalidFileNameChars ();
1152 char[] invalid = Path.GetInvalidFileNameChars ();
1154 Assert.IsTrue (expected[0] != 'a', "expected");
1155 Assert.AreEqual (expected[0], Path.GetInvalidFileNameChars ()[0], "readonly");
1159 public void GetInvalidPathChars_Values ()
1161 char[] invalid = Path.GetInvalidPathChars ();
1163 Assert.AreEqual (36, invalid.Length);
1164 foreach (char c in invalid) {
1168 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1170 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1173 foreach (char c in invalid) {
1177 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1183 public void GetInvalidPathChars_Order ()
1186 char [] invalid = Path.GetInvalidPathChars ();
1187 char [] expected = new char [36] { '\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02',
1188 '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D',
1189 '\x0E', '\x0F', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18',
1190 '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' };
1191 Assert.AreEqual (expected.Length, invalid.Length);
1192 for (int i = 0; i < expected.Length; i++ ) {
1193 Assert.AreEqual (expected [i], invalid [i], "Character at position " + i);
1199 public void GetInvalidPathChars_Modify ()
1201 char[] expected = Path.GetInvalidPathChars ();
1202 char[] invalid = Path.GetInvalidPathChars ();
1204 Assert.IsTrue (expected[0] != 'a', "expected");
1205 Assert.AreEqual (expected[0], Path.GetInvalidPathChars ()[0], "readonly");
1209 public void GetRandomFileName ()
1211 string s = Path.GetRandomFileName ();
1212 Assert.AreEqual (12, s.Length, "Length");
1213 char[] invalid = Path.GetInvalidFileNameChars ();
1214 for (int i=0; i < s.Length; i++) {
1216 Assert.AreEqual ('.', s[i], "8");
1218 Assert.IsTrue (Array.IndexOf (invalid, s[i]) == -1, i.ToString ());
1223 public void GetRandomFileNameIsAlphaNumerical ()
1225 string [] names = new string [1000];
1226 for (int i = 0; i < names.Length; i++)
1227 names [i] = Path.GetRandomFileName ();
1229 foreach (string name in names) {
1230 Assert.AreEqual (12, name.Length);
1231 Assert.AreEqual ('.', name [8]);
1233 for (int i = 0; i < 12; i++) {
1238 Assert.IsTrue (('a' <= c && c <= 'z') || ('0' <= c && c <= '9'));
1243 string Concat (string sep, params string [] parms)
1245 return String.Join (sep, parms);
1249 public void Combine_3Params ()
1251 string sep = Path.DirectorySeparatorChar.ToString ();
1254 Path.Combine (null, "two", "three");
1255 Assert.Fail ("#A1-1");
1261 Path.Combine ("one", null, "three");
1262 Assert.Fail ("#A1-2");
1268 Path.Combine ("one", "two", null);
1269 Assert.Fail ("#A1-3");
1274 Assert.AreEqual (Concat (sep, "one", "two", "three"), Path.Combine ("one", "two", "three"), "#A2-1");
1275 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one", "two", "three"), "#A2-2");
1276 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one" + sep, "two", "three"), "#A2-3");
1277 Assert.AreEqual (Concat (sep, sep + "two", "three"), Path.Combine (sep + "one" + sep, sep + "two", "three"), "#A2-4");
1278 Assert.AreEqual (Concat (sep, sep + "three"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three"), "#A2-5");
1280 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three"), Path.Combine (sep + "one" + sep + sep, "two", "three"), "#A3");
1282 Assert.AreEqual ("", Path.Combine ("", "", ""), "#A4");
1286 public void Combine_4Params ()
1288 string sep = Path.DirectorySeparatorChar.ToString ();
1291 Path.Combine (null, "two", "three", "four");
1292 Assert.Fail ("#A1-1");
1298 Path.Combine ("one", null, "three", "four");
1299 Assert.Fail ("#A1-2");
1305 Path.Combine ("one", "two", null, "four");
1306 Assert.Fail ("#A1-3");
1312 Path.Combine ("one", "two", "three", null);
1313 Assert.Fail ("#A1-4");
1318 Assert.AreEqual (Concat (sep, "one", "two", "three", "four"), Path.Combine ("one", "two", "three", "four"), "#A2-1");
1319 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one", "two", "three", "four"), "#A2-2");
1320 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one" + sep, "two", "three", "four"), "#A2-3");
1321 Assert.AreEqual (Concat (sep, sep + "two", "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four"), "#A2-4");
1322 Assert.AreEqual (Concat (sep, sep + "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four"), "#A2-5");
1323 Assert.AreEqual (Concat (sep, sep + "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four"), "#A2-6");
1325 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four"), "#A3");
1327 Assert.AreEqual ("", Path.Combine ("", "", "", ""), "#A4");
1331 public void Combine_ManyParams ()
1333 string sep = Path.DirectorySeparatorChar.ToString ();
1336 Path.Combine (null, "two", "three", "four", "five");
1337 Assert.Fail ("#A1-1");
1343 Path.Combine ("one", null, "three", "four", "five");
1344 Assert.Fail ("#A1-2");
1350 Path.Combine ("one", "two", null, "four", "five");
1351 Assert.Fail ("#A1-3");
1357 Path.Combine ("one", "two", "three", null, "five");
1358 Assert.Fail ("#A1-4");
1364 Path.Combine ("one", "two", "three", "four", null);
1365 Assert.Fail ("#A1-5");
1370 Assert.AreEqual (Concat (sep, "one", "two", "three", "four", "five"), Path.Combine ("one", "two", "three", "four", "five"), "#A2-1");
1371 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one", "two", "three", "four", "five"), "#A2-2");
1372 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, "two", "three", "four", "five"), "#A2-3");
1373 Assert.AreEqual (Concat (sep, sep + "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four", "five"), "#A2-4");
1374 Assert.AreEqual (Concat (sep, sep + "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four", "five"), "#A2-5");
1375 Assert.AreEqual (Concat (sep, sep + "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", "five"), "#A2-6");
1376 Assert.AreEqual (Concat (sep, sep + "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", sep + "five"), "#A2-6");
1378 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four", "five"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four", "five"), "#A3");
1380 Assert.AreEqual ("", Path.Combine ("", "", "", "", ""), "#A4");