[tests] Fix for when CWD is /
authorMarek Habersack <grendel@twistedcode.net>
Thu, 11 Jun 2015 18:02:03 +0000 (20:02 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 15 Jul 2015 18:45:16 +0000 (20:45 +0200)
The test case doesn't account for the situation when the tests are ran
at the root of the Unix filesystem. This is, admittedly, a rare case on
Desktop but it's precisely what CWD is for Android processes. The test
would fail because it would get a path of the //Form instead of the /Form

mcs/class/corlib/Test/System.IO/PathTest.cs

index 8f5e4909b9f2b8005a5c2317b2be063f3419df48..9f499819db06f206f3217e160ae5da620bcb31b5 100644 (file)
@@ -173,9 +173,10 @@ namespace MonoTests.System.IO
                        Assert.AreEqual ("one", testPath, "Combine #03");
 
                        string current = Directory.GetCurrentDirectory ();
+                       bool currentIsDSC = current.Length == 1 && current [0] == DSC;
                        testPath = Path.Combine (current, "one");
 
-                       string expected = current + DSC + "one";
+                       string expected = (currentIsDSC ? String.Empty : current) + DSC + "one";
                        Assert.AreEqual (expected, testPath, "Combine #04");
 
                        testPath = Path.Combine ("one", current);
@@ -484,9 +485,9 @@ namespace MonoTests.System.IO
                public void GetFullPath ()
                {
                        string current = Directory.GetCurrentDirectory ();
-
+                       bool currentIsDSC = current.Length == 1 && current [0] == DSC;
                        string testFullPath = Path.GetFullPath ("foo.txt");
-                       string expected = current + DSC + "foo.txt";
+                       string expected = (currentIsDSC ? String.Empty : current) + DSC + "foo.txt";
                        Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
 
                        testFullPath = Path.GetFullPath ("a//./.././foo.txt");