Crosspath: extend tests with "long UNC" paths

See https://en.wikipedia.org/wiki/Path_(computing)#Universal_Naming_Convention
This commit is contained in:
Sybren A. Stüvel 2022-03-04 11:09:14 +01:00
parent 0a97d04741
commit 70f8140df5

View File

@ -57,8 +57,10 @@ func TestDir(t *testing.T) {
{"/", "/file-at-root"}, {"/", "/file-at-root"},
{"C:", "C:\\file-at-root"}, {"C:", "C:\\file-at-root"},
{"/Linux path", "/Linux path/with spaces.txt"}, {"/Linux path", "/Linux path/with spaces.txt"},
{"/Mixed path/with", "/Mixed path\\with/slash.txt"},
{"C:/ünicode/is", "C:\\ünicode\\is\\awésom.tar.gz"}, {"C:/ünicode/is", "C:\\ünicode\\is\\awésom.tar.gz"},
{"//SERVER/ünicode/is", "\\\\SERVER\\ünicode\\is\\awésom.tar.gz"}, {"//SERVER/ünicode/is", "\\\\SERVER\\ünicode\\is\\awésom.tar.gz"},
{"//?/UNC/ComputerName/SharedFolder", "\\\\?\\UNC\\ComputerName\\SharedFolder\\Resource"},
} }
for _, test := range tests { for _, test := range tests {
assert.Equal(t, assert.Equal(t,
@ -90,6 +92,7 @@ func TestJoin(t *testing.T) {
{"/Linux path/with spaces.txt", []string{"/Linux path", "with spaces.txt"}}, {"/Linux path/with spaces.txt", []string{"/Linux path", "with spaces.txt"}},
{"C:/ünicode/is/awésom.tar.gz", []string{"C:\\ünicode", "is\\awésom.tar.gz"}}, {"C:/ünicode/is/awésom.tar.gz", []string{"C:\\ünicode", "is\\awésom.tar.gz"}},
{"//SERVER/mount/dir/file.txt", []string{"\\\\SERVER", "mount", "dir", "file.txt"}}, {"//SERVER/mount/dir/file.txt", []string{"\\\\SERVER", "mount", "dir", "file.txt"}},
{"//?/UNC/ComputerName/SharedFolder/Resource", []string{"\\\\?\\UNC\\ComputerName", "SharedFolder\\Resource"}},
} }
for _, test := range tests { for _, test := range tests {
assert.Equal(t, assert.Equal(t,
@ -107,6 +110,9 @@ func TestStem(t *testing.T) {
{"stem.tar", "stem.tar.gz"}, {"stem.tar", "stem.tar.gz"},
{"file", "/path/to/file.txt"}, {"file", "/path/to/file.txt"},
{"file", "C:\\path\\to\\file.txt"}, {"file", "C:\\path\\to\\file.txt"},
{"file", "C:\\path\\to/mixed/slashes/file.txt"},
{"file", "C:\\path/to\\mixed/slashes\\file.txt"},
{"Resource with ext", "\\\\?\\UNC\\ComputerName\\SharedFolder\\Resource with ext.ension"},
} }
for _, test := range tests { for _, test := range tests {
assert.Equal(t, assert.Equal(t,