github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/backend/opendrive/replace_test.go (about) 1 package opendrive 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 {" path/ leading spaces", "␠path/␠ leading spaces"}, 16 {"trailing space ", "trailing space␠"}, 17 {"trailing spaces /path ", "trailing spaces ␠/path␠"}, 18 } { 19 got := replaceReservedChars(test.in) 20 if got != test.out { 21 t.Errorf("replaceReservedChars(%q) want %q got %q", test.in, test.out, got) 22 } 23 got2 := restoreReservedChars(got) 24 if got2 != test.in { 25 t.Errorf("restoreReservedChars(%q) want %q got %q", got, test.in, got2) 26 } 27 } 28 }