github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/backend/onedrive/replace_test.go (about) 1 package onedrive 2 3 import "testing" 4 5 func TestReplace(t *testing.T) { 6 for _, test := range []struct { 7 in string 8 out string 9 }{ 10 {"", ""}, 11 {"abc 123", "abc 123"}, 12 {`\*<>?:|#%".~`, `\*<>?:|#%".~`}, 13 {`\*<>?:|#%".~/\*<>?:|#%".~`, `\*<>?:|#%".~/\*<>?:|#%".~`}, 14 {" leading space", "␠leading space"}, 15 {"~leading tilde", "~leading tilde"}, 16 {"trailing dot.", "trailing dot."}, 17 {" leading space/ leading space/ leading space", "␠leading space/␠leading space/␠leading space"}, 18 {"~leading tilde/~leading tilde/~leading tilde", "~leading tilde/~leading tilde/~leading tilde"}, 19 {"trailing dot./trailing dot./trailing dot.", "trailing dot./trailing dot./trailing dot."}, 20 } { 21 got := replaceReservedChars(test.in) 22 if got != test.out { 23 t.Errorf("replaceReservedChars(%q) want %q got %q", test.in, test.out, got) 24 } 25 got2 := restoreReservedChars(got) 26 if got2 != test.in { 27 t.Errorf("restoreReservedChars(%q) want %q got %q", got, test.in, got2) 28 } 29 } 30 }