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;
40 static char ADSC = Path.AltDirectorySeparatorChar;
47 path1 = "/foo/test.txt";
50 } else if ('\\' == DSC) {
52 path1 = "c:\\foo\\test.txt";
53 path2 = Environment.GetEnvironmentVariable ("SYSTEMROOT");
57 //FIXME: For Mac. figure this out when we need it
58 path1 = "foo:test.txt";
67 return OS == OsType.Windows;
74 return OS == OsType.Unix;
81 return OS == OsType.Mac;
86 public void ChangeExtension ()
88 string [] files = new string [3];
89 files [(int) OsType.Unix] = "/foo/test.doc";
90 files [(int) OsType.Windows] = "c:\\foo\\test.doc";
91 files [(int) OsType.Mac] = "foo:test.doc";
93 string testPath = Path.ChangeExtension (path1, "doc");
94 Assert.AreEqual (files [(int) OS], testPath, "ChangeExtension #01");
96 testPath = Path.ChangeExtension (String.Empty, ".extension");
97 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #02");
99 testPath = Path.ChangeExtension (null, ".extension");
100 Assert.AreEqual (null, testPath, "ChangeExtension #03");
102 testPath = Path.ChangeExtension ("path", null);
103 Assert.AreEqual ("path", testPath, "ChangeExtension #04");
105 testPath = Path.ChangeExtension ("path.ext", "doc");
106 Assert.AreEqual ("path.doc", testPath, "ChangeExtension #05");
108 testPath = Path.ChangeExtension ("path.ext1.ext2", "doc");
109 Assert.AreEqual ("path.ext1.doc", testPath, "ChangeExtension #06");
111 testPath = Path.ChangeExtension ("hogehoge.xml", ".xsl");
112 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #07");
113 testPath = Path.ChangeExtension ("hogehoge", ".xsl");
114 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #08");
115 testPath = Path.ChangeExtension ("hogehoge.xml", "xsl");
116 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #09");
117 testPath = Path.ChangeExtension ("hogehoge", "xsl");
118 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #10");
119 testPath = Path.ChangeExtension ("hogehoge.xml", String.Empty);
120 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #11");
121 testPath = Path.ChangeExtension ("hogehoge", String.Empty);
122 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #12");
123 testPath = Path.ChangeExtension ("hogehoge.", null);
124 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #13");
125 testPath = Path.ChangeExtension ("hogehoge", null);
126 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #14");
127 testPath = Path.ChangeExtension (String.Empty, null);
128 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #15");
129 testPath = Path.ChangeExtension (String.Empty, "bashrc");
130 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #16");
131 testPath = Path.ChangeExtension (String.Empty, ".bashrc");
132 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #17");
133 testPath = Path.ChangeExtension (null, null);
134 Assert.IsNull (testPath, "ChangeExtension #18");
138 public void ChangeExtension_Extension_InvalidPathChars ()
140 string fn = Path.ChangeExtension ("file.ext", "<");
141 Assert.AreEqual ("file.<", fn, "Invalid filename");
145 public void ChangeExtension_Path_InvalidPathChars ()
148 Path.ChangeExtension ("fi\0le.ext", ".extension");
150 } catch (ArgumentException ex) {
151 // Illegal characters in path
152 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
153 Assert.IsNull (ex.InnerException, "#3");
154 Assert.IsNotNull (ex.Message, "#4");
155 Assert.IsNull (ex.ParamName, "#5");
160 public void Combine ()
162 string [] files = new string [3];
163 files [(int) OsType.Unix] = "/etc/init.d";
164 files [(int) OsType.Windows] = Environment.GetEnvironmentVariable ("SYSTEMROOT") + @"\system32";
165 files [(int) OsType.Mac] = "foo:bar";
167 string testPath = Path.Combine (path2, path3);
168 Assert.AreEqual (files [(int) OS], testPath, "Combine #01");
170 testPath = Path.Combine ("one", String.Empty);
171 Assert.AreEqual ("one", testPath, "Combine #02");
173 testPath = Path.Combine (String.Empty, "one");
174 Assert.AreEqual ("one", testPath, "Combine #03");
176 string current = Directory.GetCurrentDirectory ();
177 bool currentIsDSC = current.Length == 1 && current [0] == DSC;
178 testPath = Path.Combine (current, "one");
180 string expected = (currentIsDSC ? String.Empty : current) + DSC + "one";
181 Assert.AreEqual (expected, testPath, "Combine #04");
183 testPath = Path.Combine ("one", current);
184 // LAMESPEC noted in Path.cs
185 Assert.AreEqual (current, testPath, "Combine #05");
187 testPath = Path.Combine (current, expected);
188 Assert.AreEqual (expected, testPath, "Combine #06");
190 testPath = DSC + "one";
191 testPath = Path.Combine (testPath, "two" + DSC);
192 expected = DSC + "one" + DSC + "two" + DSC;
193 Assert.AreEqual (expected, testPath, "Combine #06");
195 testPath = "one" + DSC;
196 testPath = Path.Combine (testPath, DSC + "two");
197 expected = DSC + "two";
198 Assert.AreEqual (expected, testPath, "Combine #06");
200 testPath = "one" + DSC;
201 testPath = Path.Combine (testPath, "two" + DSC);
202 expected = "one" + DSC + "two" + DSC;
203 Assert.AreEqual (expected, testPath, "Combine #07");
205 Assert.AreEqual ("a", Path.Combine (new [] { "a", "" }), "Combine #08");
209 public void Combine_Path1_InvalidPathChars ()
212 Path.Combine ("a\0", "one");
214 } catch (ArgumentException ex) {
215 // Illegal characters in path
216 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
217 Assert.IsNull (ex.InnerException, "#3");
218 Assert.IsNotNull (ex.Message, "#4");
219 Assert.IsNull (ex.ParamName, "#5");
224 public void Combine_Path1_Null ()
227 Path.Combine (null, "one");
229 } catch (ArgumentNullException ex) {
230 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
231 Assert.IsNull (ex.InnerException, "#3");
232 Assert.IsNotNull (ex.Message, "#4");
233 Assert.AreEqual ("path1", ex.ParamName, "#5");
238 public void Combine_Path2_InvalidPathChars ()
241 Path.Combine ("one", "a\0");
243 } catch (ArgumentException ex) {
244 // Illegal characters in path
245 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
246 Assert.IsNull (ex.InnerException, "#3");
247 Assert.IsNotNull (ex.Message, "#4");
248 Assert.IsNull (ex.ParamName, "#5");
253 public void Combine_Path2_Null ()
256 Path.Combine ("one", null);
258 } catch (ArgumentNullException ex) {
259 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
260 Assert.IsNull (ex.InnerException, "#3");
261 Assert.IsNotNull (ex.Message, "#4");
262 Assert.AreEqual ("path2", ex.ParamName, "#5");
267 public void GetDirectoryName ()
269 string [] files = new string [3];
270 files [(int) OsType.Unix] = "/foo";
271 files [(int) OsType.Windows] = "c:\\foo";
272 files [(int) OsType.Mac] = "foo";
274 string testDirName = Path.GetDirectoryName (path1);
275 Assert.AreEqual (files [(int) OS], testDirName, "#A1");
276 testDirName = Path.GetDirectoryName (files [(int) OS] + DSC);
277 Assert.AreEqual (files [(int) OS], testDirName, "#A2");
280 Assert.AreEqual ("C:\\foo", Path.GetDirectoryName ("C:\\foo\\foo.txt"), "#B1");
281 Assert.AreEqual (null, Path.GetDirectoryName ("C:"), "#B2");
282 Assert.AreEqual (null, Path.GetDirectoryName (@"C:\"), "#B3");
283 Assert.AreEqual (@"C:\", Path.GetDirectoryName (@"C:\dir"), "#B4");
284 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\"), "#B5");
285 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"), "#B6");
286 Assert.AreEqual (@"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"), "#B7");
287 Assert.AreEqual (@"C:", Path.GetDirectoryName (@"C:foo.txt"), "#B8");
288 Assert.AreEqual (@"C:dir", Path.GetDirectoryName (@"C:dir\"), "#B9");
290 Assert.AreEqual ("\\foo\\bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#C1");
291 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar/"), "#C2");
292 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar\\xxx"), "#C3");
293 Assert.AreEqual ("\\\\host\\dir\\dir2", Path.GetDirectoryName ("\\\\host\\dir\\\\dir2\\path"), "#C4");
296 Assert.AreEqual (null, Path.GetDirectoryName (@"\\"), "#D1");
297 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server"), "#D2");
298 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server\share"), "#D3");
299 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\"), "#D4");
300 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\dir"), "#D5");
301 Assert.AreEqual (@"\\server\share\dir", Path.GetDirectoryName (@"\\server\share\dir\subdir"), "#D6");
303 Assert.AreEqual ("/etc", Path.GetDirectoryName ("/etc/hostname"), "#B1");
304 Assert.AreEqual ("/foo/bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#B2");
305 Assert.AreEqual ("foo/bar", Path.GetDirectoryName ("foo/bar/"), "#B3");
306 Assert.AreEqual ("/", Path.GetDirectoryName ("/tmp"), "#B4");
307 Assert.IsNull (Path.GetDirectoryName ("/"), "#B5");
308 Assert.AreEqual ("a", Path.GetDirectoryName ("a//b"), "#B6");
313 public void GetDirectoryName_Path_Empty ()
316 Path.GetDirectoryName (String.Empty);
318 } catch (ArgumentException ex) {
319 // The path is not of a legal form
320 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
321 Assert.IsNull (ex.InnerException, "#3");
322 Assert.IsNotNull (ex.Message, "#4");
323 Assert.IsNull (ex.ParamName, "#5");
328 public void GetDirectoryName_Path_InvalidPathChars ()
331 Path.GetDirectoryName ("hi\0world");
333 } catch (ArgumentException ex) {
334 // Illegal characters in path
335 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
336 Assert.IsNull (ex.InnerException, "#3");
337 Assert.IsNotNull (ex.Message, "#4");
338 Assert.IsNull (ex.ParamName, "#5");
343 public void GetDirectoryName_Path_Null ()
345 Assert.IsNull (Path.GetDirectoryName (null));
349 public void GetDirectoryName_Path_Whitespace ()
352 Path.GetDirectoryName (" ");
354 } catch (ArgumentException ex) {
355 // The path is not of a legal form
356 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
357 Assert.IsNull (ex.InnerException, "#3");
358 Assert.IsNotNull (ex.Message, "#4");
359 Assert.IsNull (ex.ParamName, "#5");
364 public void GetDirectoryName_Replaces_AltDirectorySeparatorChar ()
366 Assert.AreEqual ($"foo{DSC}bar", Path.GetDirectoryName ($"foo{ADSC}bar{ADSC}dingus"), "#1");
370 public void GetExtension ()
372 string testExtn = Path.GetExtension (path1);
374 Assert.AreEqual (".txt", testExtn, "GetExtension #01");
376 testExtn = Path.GetExtension (path2);
377 Assert.AreEqual (String.Empty, testExtn, "GetExtension #02");
379 testExtn = Path.GetExtension (String.Empty);
380 Assert.AreEqual (String.Empty, testExtn, "GetExtension #03");
382 testExtn = Path.GetExtension (null);
383 Assert.AreEqual (null, testExtn, "GetExtension #04");
385 testExtn = Path.GetExtension (" ");
386 Assert.AreEqual (String.Empty, testExtn, "GetExtension #05");
388 testExtn = Path.GetExtension (path1 + ".doc");
389 Assert.AreEqual (".doc", testExtn, "GetExtension #06");
391 testExtn = Path.GetExtension (path1 + ".doc" + DSC + "a.txt");
392 Assert.AreEqual (".txt", testExtn, "GetExtension #07");
394 testExtn = Path.GetExtension (".");
395 Assert.AreEqual (String.Empty, testExtn, "GetExtension #08");
397 testExtn = Path.GetExtension ("end.");
398 Assert.AreEqual (String.Empty, testExtn, "GetExtension #09");
400 testExtn = Path.GetExtension (".start");
401 Assert.AreEqual (".start", testExtn, "GetExtension #10");
403 testExtn = Path.GetExtension (".a");
404 Assert.AreEqual (".a", testExtn, "GetExtension #11");
406 testExtn = Path.GetExtension ("a.");
407 Assert.AreEqual (String.Empty, testExtn, "GetExtension #12");
409 testExtn = Path.GetExtension ("a");
410 Assert.AreEqual (String.Empty, testExtn, "GetExtension #13");
412 testExtn = Path.GetExtension ("makefile");
413 Assert.AreEqual (String.Empty, testExtn, "GetExtension #14");
417 public void GetExtension_Path_InvalidPathChars ()
420 Path.GetExtension ("hi\0world.txt");
422 } catch (ArgumentException ex) {
423 // Illegal characters in path.
424 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
425 Assert.IsNull (ex.InnerException, "#3");
426 Assert.IsNotNull (ex.Message, "#4");
427 Assert.IsNull (ex.ParamName, "#5");
432 public void GetFileName ()
434 string testFileName = Path.GetFileName (path1);
436 Assert.AreEqual ("test.txt", testFileName, "#1");
437 testFileName = Path.GetFileName (null);
438 Assert.AreEqual (null, testFileName, "#2");
439 testFileName = Path.GetFileName (String.Empty);
440 Assert.AreEqual (String.Empty, testFileName, "#3");
441 testFileName = Path.GetFileName (" ");
442 Assert.AreEqual (" ", testFileName, "#4");
446 public void GetFileName_Path_InvalidPathChars ()
449 Path.GetFileName ("hi\0world");
451 } catch (ArgumentException ex) {
452 // Illegal characters in path
453 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
454 Assert.IsNull (ex.InnerException, "#3");
455 Assert.IsNotNull (ex.Message, "#4");
456 Assert.IsNull (ex.ParamName, "#5");
461 public void GetFileNameWithoutExtension ()
463 string testFileName = Path.GetFileNameWithoutExtension (path1);
465 Assert.AreEqual ("test", testFileName, "GetFileNameWithoutExtension #01");
467 testFileName = Path.GetFileNameWithoutExtension (null);
468 Assert.AreEqual (null, testFileName, "GetFileNameWithoutExtension #02");
470 testFileName = Path.GetFileNameWithoutExtension (String.Empty);
471 Assert.AreEqual (String.Empty, testFileName, "GetFileNameWithoutExtension #03");
475 public void GetFileNameWithoutExtension_Path_InvalidPathChars ()
478 Path.GetFileNameWithoutExtension ("hi\0world");
480 } catch (ArgumentException ex) {
481 // Illegal characters in path
482 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
483 Assert.IsNull (ex.InnerException, "#3");
484 Assert.IsNotNull (ex.Message, "#4");
485 Assert.IsNull (ex.ParamName, "#5");
490 public void GetFullPath ()
492 string current = Directory.GetCurrentDirectory ();
493 bool currentIsDSC = current.Length == 1 && current [0] == DSC;
494 string testFullPath = Path.GetFullPath ("foo.txt");
495 string expected = (currentIsDSC ? String.Empty : current) + DSC + "foo.txt";
496 Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
498 testFullPath = Path.GetFullPath ("a//./.././foo.txt");
499 Assert.AreEqual (expected, testFullPath, "GetFullPath #02");
502 Assert.AreEqual ("/bin/bash", Path.GetFullPath ("/../bin/bash"));
508 public void GetFullPath_Unix ()
511 Assert.Ignore ("Running on Windows.");
514 string [,] test = new string [,] {
515 {"root////././././././../root/././../root", "root"},
517 {"root/./", "root/"},
518 {"root/./", "root/"},
519 {"root/../", String.Empty},
520 {"root/../", String.Empty},
521 {"root/../..", String.Empty},
522 {"root/.hiddenfile", "root/.hiddenfile"},
523 {"root/. /", "root/. /"},
524 {"root/.. /", "root/.. /"},
525 {"root/..weirdname", "root/..weirdname"},
526 {"root/..", String.Empty},
527 {"root/../a/b/../../..", String.Empty},
528 {"root/./..", String.Empty},
529 {"..", String.Empty},
531 {"root//dir", "root/dir"},
532 {"root/. /", "root/. /"},
533 {"root/.. /", "root/.. /"},
534 {"root/ . /", "root/ . /"},
535 {"root/ .. /", "root/ .. /"},
536 {"root/./", "root/"},
537 //ERROR! Paths are trimmed
538 // I don't understand this comment^^.
539 // No trimming occurs but the paths are not equal. That's why the test fails. Commented out.
540 //{"root/.. /", "root/.. /"},
541 {".//", String.Empty}
544 for (int i = 0; i < test.GetUpperBound (0); i++) {
545 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
546 String.Format ("GetFullPathUnix #{0}", i));
549 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
550 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
551 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
552 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
553 Path.GetFullPath ("hey"), "#04");
554 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
556 string curdir = Directory.GetCurrentDirectory ();
558 Directory.SetCurrentDirectory ("/");
559 Assert.AreEqual ("/test.txt", Path.GetFullPath ("test.txt"), "xambug #833");
562 Directory.SetCurrentDirectory (curdir);
567 public void GetFullPath_Windows ()
570 Assert.Ignore ("Not running on Windows.");
572 string root = "C:\\";
573 string [,] test = new string [,] {
574 {"root////././././././../root/././../root", "root"},
576 {"root/./", "root\\"},
577 {"root/./", "root\\"},
581 {"root/.hiddenfile", "root\\.hiddenfile"},
582 {"root/. /", "root\\"},
584 {"root/..weirdname", "root\\..weirdname"},
586 {"root/../a/b/../../..", ""},
590 {"root//dir", "root\\dir"},
591 {"root/. /", "root\\"},
593 {"root/./", "root\\"},
598 for (int i = 0; i < test.GetUpperBound (0); i++) {
600 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
601 String.Format ("GetFullPathWindows #{0}", i));
602 } catch (Exception ex) {
603 Assert.Fail (String.Format ("GetFullPathWindows #{0} (\"{1}\") failed: {2}",
604 i, root + test [i, 0], ex.GetType ()));
609 string root2 = @"\\server\share";
610 root = @"\\server\share\";
611 test = new string [,] {
612 {"root////././././././../root/././../root", "root"},
614 {"root/./", "root\\"},
615 {"root/./", "root\\"},
618 {"root/../..", null},
619 {"root/.hiddenfile", "root\\.hiddenfile"},
620 {"root/. /", "root\\"},
622 {"root/..weirdname", "root\\..weirdname"},
624 {"root/../a/b/../../..", null},
628 {"root//dir", "root\\dir"},
629 {"root/. /", "root\\"},
631 {"root/./", "root\\"},
636 for (int i = 0; i < test.GetUpperBound (0); i++) {
637 // "null" means we have to compare against "root2"
638 string res = test [i, 1] != null
642 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
643 String.Format ("GetFullPathWindows UNC #{0}", i));
644 } catch (AssertionException) {
646 } catch (Exception ex) {
647 Assert.Fail (String.Format ("GetFullPathWindows UNC #{0} (\"{1}\") failed: {2}",
648 i, root + test [i, 0], ex.GetType ()));
652 test = new string [,] {
653 {"root////././././././../root/././../root", "root"},
655 {"root/./", "root\\"},
656 {"root/./", "root\\"},
659 {"root/../..", null},
660 {"root/.hiddenfile", "root\\.hiddenfile"},
661 {"root/. /", "root\\"},
663 {"root/..weirdname", "root\\..weirdname"},
665 {"root/../a/b/../../..", null},
669 {"root//dir", "root\\dir"},
670 {"root/. /", "root\\"},
672 {"root/./", "root\\"},
677 string root3 = @"//server/share";
678 root = @"//server/share/";
679 bool needSlashConvert = Path.DirectorySeparatorChar != '/';
681 for (int i = 0; i < test.GetUpperBound (0); i++) {
682 // "null" means we have to compare against "root2"
683 string res = test [i, 1] != null
686 if (needSlashConvert)
687 res = res.Replace ('/', Path.DirectorySeparatorChar);
689 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
690 String.Format ("GetFullPathWindows UNC[2] #{0}", i));
691 } catch (AssertionException) {
693 } catch (Exception ex) {
694 Assert.Fail (String.Format ("GetFullPathWindows UNC[2] #{0} (\"{1}\") failed: {2}",
695 i, root + test [i, 0], ex.GetType ()));
699 // These cases require that we don't pass a root to GetFullPath - it should return the proper drive root.
700 string root4 = Path.GetPathRoot(Directory.GetCurrentDirectory());
701 Assert.AreEqual(root4, Path.GetFullPath(@"\"));
702 Assert.AreEqual(root4, Path.GetFullPath("/"));
706 public void GetFullPath_Path_Empty ()
709 Path.GetFullPath (String.Empty);
711 } catch (ArgumentException ex) {
712 // The path is not of a legal form
713 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
714 Assert.IsNull (ex.InnerException, "#3");
715 Assert.IsNotNull (ex.Message, "#4");
716 Assert.IsNull (ex.ParamName, "#5");
721 public void GetFullPath_Path_EndingSeparator ()
723 string fp = Path.GetFullPath ("something/");
724 char end = fp [fp.Length - 1];
725 Assert.IsTrue (end == Path.DirectorySeparatorChar);
729 public void GetFullPath_Path_InvalidPathChars ()
732 Path.GetFullPath ("hi\0world");
734 } catch (ArgumentException ex) {
735 // Illegal characters in path
736 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
737 Assert.IsNull (ex.InnerException, "#3");
738 Assert.IsNotNull (ex.Message, "#4");
739 Assert.IsNull (ex.ParamName, "#5");
744 public void GetFullPath_Path_Null ()
747 Path.GetFullPath (null);
749 } catch (ArgumentNullException ex) {
750 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
751 Assert.IsNull (ex.InnerException, "#3");
752 Assert.IsNotNull (ex.Message, "#4");
753 Assert.AreEqual ("path", ex.ParamName, "#5");
758 public void GetFullPath_Path_Whitespace ()
761 Path.GetFullPath (" ");
763 } catch (ArgumentException ex) {
764 // The path is not of a legal form
765 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
766 Assert.IsNull (ex.InnerException, "#3");
767 Assert.IsNotNull (ex.Message, "#4");
768 Assert.IsNull (ex.ParamName, "#5");
773 public void GetFullPath2 ()
776 Assert.AreEqual (@"Z:\", Path.GetFullPath ("Z:"), "GetFullPath w#01");
777 Assert.AreEqual (@"c:\abc\def", Path.GetFullPath (@"c:\abc\def"), "GetFullPath w#02");
778 Assert.IsTrue (Path.GetFullPath (@"\").EndsWith (@"\"), "GetFullPath w#03");
779 // "\\\\" is not allowed
780 Assert.IsTrue (Path.GetFullPath ("/").EndsWith (@"\"), "GetFullPath w#05");
781 // "//" is not allowed
782 Assert.IsTrue (Path.GetFullPath ("readme.txt").EndsWith (@"\readme.txt"), "GetFullPath w#07");
783 Assert.IsTrue (Path.GetFullPath ("c").EndsWith (@"\c"), "GetFullPath w#08");
784 Assert.IsTrue (Path.GetFullPath (@"abc\def").EndsWith (@"abc\def"), "GetFullPath w#09");
785 Assert.IsTrue (Path.GetFullPath (@"\abc\def").EndsWith (@"\abc\def"), "GetFullPath w#10");
786 Assert.AreEqual (@"\\abc\def", Path.GetFullPath (@"\\abc\def"), "GetFullPath w#11");
787 Assert.AreEqual (Directory.GetCurrentDirectory () + @"\abc\def", Path.GetFullPath (@"abc//def"), "GetFullPath w#12");
788 Assert.AreEqual (Directory.GetCurrentDirectory ().Substring (0, 2) + @"\abc\def", Path.GetFullPath ("/abc/def"), "GetFullPath w#13");
789 Assert.AreEqual (@"\\abc\def", Path.GetFullPath ("//abc/def"), "GetFullPath w#14");
791 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
792 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
793 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
794 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
795 Path.GetFullPath ("hey"), "#04");
800 public void GetPathRoot ()
805 current = Directory.GetCurrentDirectory ();
806 expected = current [0].ToString ();
808 current = @"J:\Some\Strange Directory\Name";
812 string pathRoot = Path.GetPathRoot (current);
813 Assert.AreEqual (expected, pathRoot, "GetPathRoot #01");
817 public void GetPathRoot2 ()
819 // note: this method doesn't call Directory.GetCurrentDirectory so it can be
820 // reused for partial trust unit tests in PathCas.cs
824 pathRoot = Path.GetPathRoot ("hola");
825 Assert.AreEqual (String.Empty, pathRoot, "#A1");
826 pathRoot = Path.GetPathRoot (null);
827 Assert.AreEqual (null, pathRoot, "#A2");
830 Assert.AreEqual ("z:", Path.GetPathRoot ("z:"), "GetPathRoot w#01");
831 Assert.AreEqual ("c:\\", Path.GetPathRoot ("c:\\abc\\def"), "GetPathRoot w#02");
832 Assert.AreEqual ("\\", Path.GetPathRoot ("\\"), "GetPathRoot w#03");
833 Assert.AreEqual ("\\\\", Path.GetPathRoot ("\\\\"), "GetPathRoot w#04");
834 Assert.AreEqual ("\\", Path.GetPathRoot ("/"), "GetPathRoot w#05");
835 Assert.AreEqual ("\\\\", Path.GetPathRoot ("//"), "GetPathRoot w#06");
836 Assert.AreEqual (String.Empty, Path.GetPathRoot ("readme.txt"), "GetPathRoot w#07");
837 Assert.AreEqual (String.Empty, Path.GetPathRoot ("c"), "GetPathRoot w#08");
838 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc\\def"), "GetPathRoot w#09");
839 Assert.AreEqual ("\\", Path.GetPathRoot ("\\abc\\def"), "GetPathRoot w#10");
840 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def"), "GetPathRoot w#11");
841 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc//def"), "GetPathRoot w#12");
842 Assert.AreEqual ("\\", Path.GetPathRoot ("/abc/def"), "GetPathRoot w#13");
843 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("//abc/def"), "GetPathRoot w#14");
844 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\"), "GetPathRoot w#15");
845 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\\"), "GetPathRoot w#16");
846 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def\\ghi"), "GetPathRoot w#17");
848 // TODO: Same tests for Unix.
853 public void GetPathRoot_Path_Empty ()
856 Path.GetPathRoot (String.Empty);
858 } catch (ArgumentException ex) {
859 // The path is not of a legal form
860 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
861 Assert.IsNull (ex.InnerException, "#3");
862 Assert.IsNotNull (ex.Message, "#4");
863 Assert.IsNull (ex.ParamName, "#5");
868 public void GetPathRoot_Path_InvalidPathChars ()
871 Path.GetPathRoot ("hi\0world");
873 } catch (ArgumentException ex) {
874 // Illegal characters in path
875 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
876 Assert.IsNull (ex.InnerException, "#3");
877 Assert.IsNotNull (ex.Message, "#4");
878 Assert.IsNull (ex.ParamName, "#5");
883 public void GetPathRoot_Path_Whitespace ()
886 Path.GetPathRoot (" ");
888 } catch (ArgumentException ex) {
889 // The path is not of a legal form
890 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
891 Assert.IsNull (ex.InnerException, "#3");
892 Assert.IsNotNull (ex.Message, "#4");
893 Assert.IsNull (ex.ParamName, "#5");
898 public void GetTempPath ()
900 string getTempPath = Path.GetTempPath ();
901 Assert.IsTrue (getTempPath != String.Empty, "GetTempPath #01");
902 Assert.IsTrue (Path.IsPathRooted (getTempPath), "GetTempPath #02");
903 Assert.AreEqual (Path.DirectorySeparatorChar, getTempPath [getTempPath.Length - 1], "GetTempPath #03");
907 public void GetTempFileName ()
909 string getTempFileName = null;
911 getTempFileName = Path.GetTempFileName ();
912 Assert.IsTrue (getTempFileName != String.Empty, "GetTempFileName #01");
913 Assert.IsTrue (File.Exists (getTempFileName), "GetTempFileName #02");
915 if (getTempFileName != null && getTempFileName != String.Empty){
916 File.Delete (getTempFileName);
922 public void HasExtension ()
924 Assert.AreEqual (true, Path.HasExtension ("foo.txt"), "HasExtension #01");
925 Assert.AreEqual (false, Path.HasExtension ("foo"), "HasExtension #02");
926 Assert.AreEqual (true, Path.HasExtension (path1), "HasExtension #03");
927 Assert.AreEqual (false, Path.HasExtension (path2), "HasExtension #04");
928 Assert.AreEqual (false, Path.HasExtension (null), "HasExtension #05");
929 Assert.AreEqual (false, Path.HasExtension (String.Empty), "HasExtension #06");
930 Assert.AreEqual (false, Path.HasExtension (" "), "HasExtension #07");
931 Assert.AreEqual (false, Path.HasExtension ("."), "HasExtension #08");
932 Assert.AreEqual (false, Path.HasExtension ("end."), "HasExtension #09");
933 Assert.AreEqual (true, Path.HasExtension (".start"), "HasExtension #10");
934 Assert.AreEqual (true, Path.HasExtension (".a"), "HasExtension #11");
935 Assert.AreEqual (false, Path.HasExtension ("a."), "HasExtension #12");
936 Assert.AreEqual (false, Path.HasExtension ("Makefile"), "HasExtension #13");
940 public void HasExtension_Path_InvalidPathChars ()
943 Path.HasExtension ("hi\0world.txt");
945 } catch (ArgumentException ex) {
946 // Illegal characters in path
947 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
948 Assert.IsNull (ex.InnerException, "#3");
949 Assert.IsNotNull (ex.Message, "#4");
950 Assert.IsNull (ex.ParamName, "#5");
955 public void IsPathRooted ()
957 Assert.IsTrue (Path.IsPathRooted (path2), "IsPathRooted #01");
958 Assert.IsTrue (!Path.IsPathRooted (path3), "IsPathRooted #02");
959 Assert.IsTrue (!Path.IsPathRooted (null), "IsPathRooted #03");
960 Assert.IsTrue (!Path.IsPathRooted (String.Empty), "IsPathRooted #04");
961 Assert.IsTrue (!Path.IsPathRooted (" "), "IsPathRooted #05");
962 Assert.IsTrue (Path.IsPathRooted ("/"), "IsPathRooted #06");
963 Assert.IsTrue (Path.IsPathRooted ("//"), "IsPathRooted #07");
964 Assert.IsTrue (!Path.IsPathRooted (":"), "IsPathRooted #08");
967 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #09");
968 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
969 Assert.IsTrue (Path.IsPathRooted ("z:"), "IsPathRooted #11");
970 Assert.IsTrue (Path.IsPathRooted ("z:\\"), "IsPathRooted #12");
971 Assert.IsTrue (Path.IsPathRooted ("z:\\topdir"), "IsPathRooted #13");
972 // This looks MS BUG. It is treated as absolute path
973 Assert.IsTrue (Path.IsPathRooted ("z:curdir"), "IsPathRooted #14");
974 Assert.IsTrue (Path.IsPathRooted ("\\abc\\def"), "IsPathRooted #15");
976 if (Environment.GetEnvironmentVariable ("MONO_IOMAP") == "all"){
977 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #16");
978 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #17");
980 Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");
981 Assert.IsTrue (!Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
982 Assert.IsTrue (!Path.IsPathRooted ("z:"), "IsPathRooted #11");
988 public void IsPathRooted_Path_Empty ()
990 Assert.IsTrue (!Path.IsPathRooted (String.Empty));
994 public void IsPathRooted_Path_InvalidPathChars ()
997 Path.IsPathRooted ("hi\0world");
999 } catch (ArgumentException ex) {
1000 // Illegal characters in path.
1001 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1002 Assert.IsNull (ex.InnerException, "#3");
1003 Assert.IsNotNull (ex.Message, "#4");
1004 Assert.IsNull (ex.ParamName, "#5");
1009 public void IsPathRooted_Path_Null ()
1011 Assert.IsTrue (!Path.IsPathRooted (null));
1015 public void IsPathRooted_Path_Whitespace ()
1017 Assert.IsTrue (!Path.IsPathRooted (" "));
1021 public void CanonicalizeDots ()
1023 string current = Path.GetFullPath (".");
1024 Assert.IsTrue (!current.EndsWith ("."), "TestCanonicalizeDotst #01");
1025 string parent = Path.GetFullPath ("..");
1026 Assert.IsTrue (!current.EndsWith (".."), "TestCanonicalizeDotst #02");
1030 public void WindowsSystem32_76191 ()
1032 // check for Unix platforms - see FAQ for more details
1033 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1034 int platform = (int) Environment.OSVersion.Platform;
1035 if ((platform == 4) || (platform == 128) || (platform == 6))
1036 Assert.Ignore ("Running on Unix.");
1038 string curdir = Directory.GetCurrentDirectory ();
1040 string system = Environment.SystemDirectory;
1041 Directory.SetCurrentDirectory (system);
1042 string drive = system.Substring (0, 2);
1043 Assert.AreEqual (system, Path.GetFullPath (drive), "current dir");
1046 Directory.SetCurrentDirectory (curdir);
1051 public void WindowsSystem32_77007 ()
1053 // check for Unix platforms - see FAQ for more details
1054 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1055 int platform = (int) Environment.OSVersion.Platform;
1056 if ((platform == 4) || (platform == 128) || (platform == 6))
1057 Assert.Ignore ("Running on Unix.");
1059 string curdir = Directory.GetCurrentDirectory ();
1061 string system = Environment.SystemDirectory;
1062 Directory.SetCurrentDirectory (system);
1063 // e.g. C:dir (no backslash) will return CurrentDirectory + dir
1064 string dir = system.Substring (0, 2) + "dir";
1065 Assert.AreEqual (Path.Combine (system, "dir"), Path.GetFullPath (dir), "current dir");
1068 Directory.SetCurrentDirectory (curdir);
1073 public void WindowsDriveC14N_77058 ()
1075 // check for Unix platforms - see FAQ for more details
1076 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1077 int platform = (int) Environment.OSVersion.Platform;
1078 if ((platform == 4) || (platform == 128) || (platform == 6))
1079 Assert.Ignore ("Running on Unix.");
1081 Assert.AreEqual (@"C:\Windows\dir", Path.GetFullPath (@"C:\Windows\System32\..\dir"), "1");
1082 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\dir"), "2");
1083 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\dir"), "3");
1084 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\..\dir"), "4");
1085 Assert.AreEqual (@"C:\dir\", Path.GetFullPath (@"C:\Windows\System32\..\.\..\.\..\dir\"), "5");
1089 public void InvalidPathChars_Values ()
1091 char[] invalid = Path.InvalidPathChars;
1093 Assert.AreEqual (36, invalid.Length, "Length");
1095 foreach (char c in invalid) {
1101 // in both 1.1 SP1 and 2.0
1102 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1104 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1107 foreach (char c in invalid) {
1111 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1117 public void InvalidPathChars_Modify ()
1119 char[] expected = Path.InvalidPathChars;
1120 char[] invalid = Path.InvalidPathChars;
1121 char original = invalid[0];
1125 Assert.IsTrue (expected[0] == 'a', "expected");
1126 Assert.AreEqual (expected[0], Path.InvalidPathChars[0], "readonly");
1128 invalid[0] = original;
1133 public void GetInvalidFileNameChars_Values ()
1135 char[] invalid = Path.GetInvalidFileNameChars ();
1137 Assert.AreEqual (41, invalid.Length);
1138 foreach (char c in invalid) {
1142 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1144 // ':', '*', '?', '\', '/'
1145 if ((i == 58) || (i == 42) || (i == 63) || (i == 92) || (i == 47))
1147 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1150 foreach (char c in invalid) {
1153 if ((i == 0) || (i == 47))
1155 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1161 public void GetInvalidFileNameChars_Modify ()
1163 char[] expected = Path.GetInvalidFileNameChars ();
1164 char[] invalid = Path.GetInvalidFileNameChars ();
1166 Assert.IsTrue (expected[0] != 'a', "expected");
1167 Assert.AreEqual (expected[0], Path.GetInvalidFileNameChars ()[0], "readonly");
1171 public void GetInvalidPathChars_Values ()
1173 char[] invalid = Path.GetInvalidPathChars ();
1175 Assert.AreEqual (36, invalid.Length);
1176 foreach (char c in invalid) {
1180 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1182 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1185 foreach (char c in invalid) {
1189 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1195 public void GetInvalidPathChars_Order ()
1198 char [] invalid = Path.GetInvalidPathChars ();
1199 char [] expected = new char [36] { '\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02',
1200 '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D',
1201 '\x0E', '\x0F', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18',
1202 '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' };
1203 Assert.AreEqual (expected.Length, invalid.Length);
1204 for (int i = 0; i < expected.Length; i++ ) {
1205 Assert.AreEqual (expected [i], invalid [i], "Character at position " + i);
1211 public void GetInvalidPathChars_Modify ()
1213 char[] expected = Path.GetInvalidPathChars ();
1214 char[] invalid = Path.GetInvalidPathChars ();
1216 Assert.IsTrue (expected[0] != 'a', "expected");
1217 Assert.AreEqual (expected[0], Path.GetInvalidPathChars ()[0], "readonly");
1221 public void GetRandomFileName ()
1223 string s = Path.GetRandomFileName ();
1224 Assert.AreEqual (12, s.Length, "Length");
1225 char[] invalid = Path.GetInvalidFileNameChars ();
1226 for (int i=0; i < s.Length; i++) {
1228 Assert.AreEqual ('.', s[i], "8");
1230 Assert.IsTrue (Array.IndexOf (invalid, s[i]) == -1, i.ToString ());
1235 public void GetRandomFileNameIsAlphaNumerical ()
1237 string [] names = new string [1000];
1238 for (int i = 0; i < names.Length; i++)
1239 names [i] = Path.GetRandomFileName ();
1241 foreach (string name in names) {
1242 Assert.AreEqual (12, name.Length);
1243 Assert.AreEqual ('.', name [8]);
1245 for (int i = 0; i < 12; i++) {
1250 Assert.IsTrue (('a' <= c && c <= 'z') || ('0' <= c && c <= '9'));
1255 string Concat (string sep, params string [] parms)
1257 return String.Join (sep, parms);
1261 public void Combine_3Params ()
1263 string sep = Path.DirectorySeparatorChar.ToString ();
1266 Path.Combine (null, "two", "three");
1267 Assert.Fail ("#A1-1");
1273 Path.Combine ("one", null, "three");
1274 Assert.Fail ("#A1-2");
1280 Path.Combine ("one", "two", null);
1281 Assert.Fail ("#A1-3");
1286 Assert.AreEqual (Concat (sep, "one", "two", "three"), Path.Combine ("one", "two", "three"), "#A2-1");
1287 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one", "two", "three"), "#A2-2");
1288 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one" + sep, "two", "three"), "#A2-3");
1289 Assert.AreEqual (Concat (sep, sep + "two", "three"), Path.Combine (sep + "one" + sep, sep + "two", "three"), "#A2-4");
1290 Assert.AreEqual (Concat (sep, sep + "three"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three"), "#A2-5");
1292 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three"), Path.Combine (sep + "one" + sep + sep, "two", "three"), "#A3");
1294 Assert.AreEqual ("", Path.Combine ("", "", ""), "#A4");
1298 public void Combine_4Params ()
1300 string sep = Path.DirectorySeparatorChar.ToString ();
1303 Path.Combine (null, "two", "three", "four");
1304 Assert.Fail ("#A1-1");
1310 Path.Combine ("one", null, "three", "four");
1311 Assert.Fail ("#A1-2");
1317 Path.Combine ("one", "two", null, "four");
1318 Assert.Fail ("#A1-3");
1324 Path.Combine ("one", "two", "three", null);
1325 Assert.Fail ("#A1-4");
1330 Assert.AreEqual (Concat (sep, "one", "two", "three", "four"), Path.Combine ("one", "two", "three", "four"), "#A2-1");
1331 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one", "two", "three", "four"), "#A2-2");
1332 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one" + sep, "two", "three", "four"), "#A2-3");
1333 Assert.AreEqual (Concat (sep, sep + "two", "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four"), "#A2-4");
1334 Assert.AreEqual (Concat (sep, sep + "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four"), "#A2-5");
1335 Assert.AreEqual (Concat (sep, sep + "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four"), "#A2-6");
1337 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four"), "#A3");
1339 Assert.AreEqual ("", Path.Combine ("", "", "", ""), "#A4");
1343 public void Combine_ManyParams ()
1345 string sep = Path.DirectorySeparatorChar.ToString ();
1348 Path.Combine (null, "two", "three", "four", "five");
1349 Assert.Fail ("#A1-1");
1355 Path.Combine ("one", null, "three", "four", "five");
1356 Assert.Fail ("#A1-2");
1362 Path.Combine ("one", "two", null, "four", "five");
1363 Assert.Fail ("#A1-3");
1369 Path.Combine ("one", "two", "three", null, "five");
1370 Assert.Fail ("#A1-4");
1376 Path.Combine ("one", "two", "three", "four", null);
1377 Assert.Fail ("#A1-5");
1382 Assert.AreEqual (Concat (sep, "one", "two", "three", "four", "five"), Path.Combine ("one", "two", "three", "four", "five"), "#A2-1");
1383 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one", "two", "three", "four", "five"), "#A2-2");
1384 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, "two", "three", "four", "five"), "#A2-3");
1385 Assert.AreEqual (Concat (sep, sep + "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four", "five"), "#A2-4");
1386 Assert.AreEqual (Concat (sep, sep + "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four", "five"), "#A2-5");
1387 Assert.AreEqual (Concat (sep, sep + "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", "five"), "#A2-6");
1388 Assert.AreEqual (Concat (sep, sep + "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", sep + "five"), "#A2-6");
1390 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four", "five"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four", "five"), "#A3");
1392 Assert.AreEqual ("", Path.Combine ("", "", "", "", ""), "#A4");