github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/local/tests_test.go (about) 1 package local 2 3 import ( 4 "runtime" 5 "testing" 6 7 "github.com/rclone/rclone/lib/encoder" 8 ) 9 10 // Test Windows character replacements 11 var testsWindows = [][2]string{ 12 {`c:\temp`, `c:\temp`}, 13 {`\\?\UNC\theserver\dir\file.txt`, `\\?\UNC\theserver\dir\file.txt`}, 14 {`//?/UNC/theserver/dir\file.txt`, `\\?\UNC\theserver\dir\file.txt`}, 15 {`c:/temp`, `c:\temp`}, 16 {`C:/temp/file.txt`, `C:\temp\file.txt`}, 17 {`c:\!\"#¤%&/()=;:*^?+-`, `c:\!\"#¤%&\()=;:*^?+-`}, 18 {`c:\<>"|?*:&\<>"|?*:&\<>"|?*:&`, `c:\<>"|?*:&\<>"|?*:&\<>"|?*:&`}, 19 } 20 21 func TestCleanWindows(t *testing.T) { 22 if runtime.GOOS != "windows" { 23 t.Skipf("windows only") 24 } 25 for _, test := range testsWindows { 26 got := cleanRootPath(test[0], true, encoder.OS) 27 expect := test[1] 28 if got != expect { 29 t.Fatalf("got %q, expected %q", got, expect) 30 } 31 } 32 }