2015-09-11 11:37:12 +02:00
|
|
|
|
package local
|
|
|
|
|
|
|
|
|
|
import (
|
2018-11-02 13:12:51 +01:00
|
|
|
|
"runtime"
|
2015-09-11 11:37:12 +02:00
|
|
|
|
"testing"
|
2021-05-28 13:34:29 +02:00
|
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/lib/encoder"
|
2015-09-11 11:37:12 +02:00
|
|
|
|
)
|
|
|
|
|
|
2015-10-16 11:49:00 +02:00
|
|
|
|
// Test Windows character replacements
|
|
|
|
|
var testsWindows = [][2]string{
|
2016-02-29 17:57:23 +01:00
|
|
|
|
{`c:\temp`, `c:\temp`},
|
|
|
|
|
{`\\?\UNC\theserver\dir\file.txt`, `\\?\UNC\theserver\dir\file.txt`},
|
2018-11-02 13:12:51 +01:00
|
|
|
|
{`//?/UNC/theserver/dir\file.txt`, `\\?\UNC\theserver\dir\file.txt`},
|
|
|
|
|
{`c:/temp`, `c:\temp`},
|
2019-10-28 16:41:47 +01:00
|
|
|
|
{`C:/temp/file.txt`, `C:\temp\file.txt`},
|
2018-11-02 13:12:51 +01:00
|
|
|
|
{`c:\!\"#¤%&/()=;:*^?+-`, `c:\!\"#¤%&\()=;:*^?+-`},
|
|
|
|
|
{`c:\<>"|?*:&\<>"|?*:&\<>"|?*:&`, `c:\<>"|?*:&\<>"|?*:&\<>"|?*:&`},
|
2015-10-16 11:49:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCleanWindows(t *testing.T) {
|
2018-11-02 13:12:51 +01:00
|
|
|
|
if runtime.GOOS != "windows" {
|
|
|
|
|
t.Skipf("windows only")
|
|
|
|
|
}
|
2015-10-16 11:49:00 +02:00
|
|
|
|
for _, test := range testsWindows {
|
2021-05-28 13:34:29 +02:00
|
|
|
|
got := cleanRootPath(test[0], true, encoder.OS)
|
2015-10-16 11:49:00 +02:00
|
|
|
|
expect := test[1]
|
|
|
|
|
if got != expect {
|
|
|
|
|
t.Fatalf("got %q, expected %q", got, expect)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|