瀏覽代碼

2004-06-22 Atsushi Enomoto <[email protected]>

	* UriTest.cs : As Unix paths, //foo/bar never means host == foo,
	  file path == /bar. So on *nix environment, interpret LocalPath of
	  file://foo/bar as /bar, not //foo/bar.
	* test-uri-list.txt, tset-uri-props.txt : We cannot test such path
	  that starts with "//" in automatic one, since on Windows it is
	  UNC host name but on Unix it is condensed to /foo style abs path.
	* UriTest2.cs : Test only on windows such path that starts with "\\".

svn path=/trunk/mcs/; revision=30141
Atsushi Eno 21 年之前
父節點
當前提交
ee12fd768b

+ 10 - 0
mcs/class/System/Test/System/ChangeLog

@@ -1,3 +1,13 @@
+2004-06-22  Atsushi Enomoto  <[email protected]>
+
+	* UriTest.cs : As Unix paths, //foo/bar never means host == foo,
+	  file path == /bar. So on *nix environment, interpret LocalPath of
+	  file://foo/bar as /bar, not //foo/bar.
+	* test-uri-list.txt, tset-uri-props.txt : We cannot test such path
+	  that starts with "//" in automatic one, since on Windows it is
+	  UNC host name but on Unix it is condensed to /foo style abs path.
+	* UriTest2.cs : Test only on windows such path that starts with "\\".
+
 2004-06-16  Atsushi Enomoto  <[email protected]>
 
 	* test-uri-list.txt, test-uri-props.txt, test-uri-props-manual.txt :

+ 6 - 5
mcs/class/System/Test/System/UriTest.cs

@@ -119,7 +119,8 @@ namespace MonoTests.System
 			if (isWin32)
 				AssertEquals ("#n11", @"\\myserver\mydir\mysubdir\myfile.ext", uri.LocalPath);
 			else
-				AssertEquals ("#n11", "//myserver/mydir/mysubdir/myfile.ext", uri.LocalPath);
+				// myserver never could be the part of Unix path.
+				AssertEquals ("#n11", "/mydir/mysubdir/myfile.ext", uri.LocalPath);
 
 			AssertEquals ("#n12", "/mydir/mysubdir/myfile.ext", uri.PathAndQuery);
 			AssertEquals ("#n13", -1, uri.Port);
@@ -249,7 +250,7 @@ namespace MonoTests.System
 			if (isWin32)
 				AssertEquals ("#3b win32", "\\\\cygwin\\tmp\\hello.txt", uri.LocalPath);
 			else
-				AssertEquals ("#3b *nix", "/cygwin/tmp/hello.txt", uri.LocalPath);
+				AssertEquals ("#3b *nix", "/tmp/hello.txt", uri.LocalPath);
 			AssertEquals ("#3c", "file", uri.Scheme);
 			AssertEquals ("#3d", "cygwin", uri.Host);
 			AssertEquals ("#3e", "/tmp/hello.txt", uri.AbsolutePath);
@@ -259,7 +260,7 @@ namespace MonoTests.System
 			if (isWin32)
 				AssertEquals ("#4b win32", "\\\\mymachine\\cygwin\\tmp\\hello.txt", uri.LocalPath);
 			else
-				AssertEquals ("#4b *nix", "/mymachine/cygwin/tmp/hello.txt", uri.LocalPath);
+				AssertEquals ("#4b *nix", "/cygwin/tmp/hello.txt", uri.LocalPath);
 			AssertEquals ("#4c", "file", uri.Scheme);
 			AssertEquals ("#4d", "mymachine", uri.Host);
 			AssertEquals ("#4e", "/cygwin/tmp/hello.txt", uri.AbsolutePath);
@@ -270,13 +271,13 @@ namespace MonoTests.System
 			AssertEquals ("#5c", "file", uri.Scheme);
 			AssertEquals ("#5d", "", uri.Host);
 			AssertEquals ("#5e", "c:/cygwin/tmp/hello.txt", uri.AbsolutePath);
-			
+			// Hmm, they should be regarded just as a host name, since all URIs are base on absolute path.
 			uri = new Uri("file://one_file.txt");
 			AssertEquals("#6a", "file://one_file.txt", uri.ToString());
 			if (isWin32)
 				AssertEquals("#6b", "\\\\one_file.txt", uri.LocalPath);
 			else
-				AssertEquals("#6b", "/one_file.txt", uri.LocalPath);
+				AssertEquals("#6b", "/", uri.LocalPath);
 			AssertEquals("#6c", "file", uri.Scheme);
 			AssertEquals("#6d", "one_file.txt", uri.Host);
 			AssertEquals("#6e", "", uri.AbsolutePath);

+ 3 - 1
mcs/class/System/Test/System/UriTest2.cs

@@ -32,7 +32,9 @@ namespace MonoTests.System
 			AssertEquals (relsrc + " Scheme", scheme, uri.Scheme);
 			AssertEquals (relsrc + " Host", host, uri.Host);
 			AssertEquals (relsrc + " Port", port, uri.Port);
-			AssertEquals (relsrc + " LocalPath", uri.Scheme == Uri.UriSchemeFile ? localPath.Replace (Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar) : localPath, uri.LocalPath);
+			// Windows UNC path is not automatically testable on *nix environment,
+			if (relsrc.StartsWith ("\\\\") && Path.DirectorySeparatorChar == '\\')
+				AssertEquals (relsrc + " LocalPath", localPath, uri.LocalPath);
 			AssertEquals (relsrc + " Query", query, uri.Query);
 			AssertEquals (relsrc + " Fragment", fragment, uri.Fragment);
 			AssertEquals (relsrc + " IsFile", isFile, uri.IsFile);

+ 2 - 2
mcs/class/System/Test/System/test-uri-list.txt

@@ -41,7 +41,7 @@ c:\foo.txt
 file://c:/foo.txt
 # /usr/local/bin ... doesn't pass. it is critical problem of MS.NET
 \\server
-//server
+# //server ... this test causes different interpretation between Windows and Unix. On Unix the path is condesnsed to /server
 # ///server ... this became UNC server name in MS.NET
 file://server
 file://server/
@@ -93,7 +93,7 @@ http://localhost/c#bookmark
 file://localhost/c#fragment
 file://test.domain.com/c#
 file://test.domain.com/c#bookmark
-//localhost/c#
+# //localhost/c# ... this is commented out as the same reason why //server is also commented out.
 # below should not be allowed ...
 file://c:/c#
 # this passes... it breaks RFC 2396 rule.

+ 0 - 38
mcs/class/System/Test/System/test-uri-props.txt

@@ -226,25 +226,6 @@ Dns
 server
 
 
--------------------------
-//server
-file://server
-file://server
-file
-server
-\\server
-
--1
-True
-True
-False
-False
-Dns
-
-
-server
-
-
 -------------------------
 file://server
 file://server
@@ -777,25 +758,6 @@ Dns
 test.domain.com
 #bookmark
 
--------------------------
-//localhost/c#
-file://localhost/c%23
-file://localhost/c%23
-file
-localhost
-\\localhost\c#
-
--1
-True
-True
-True
-False
-Dns
-/c%23
-/c%23
-localhost
-
-
 -------------------------
 file://c:/c#
 file:///c:/c#