2017-07-17 13:36:45 +08:00
|
|
|
|
package opendrive
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestReplace(t *testing.T) {
|
|
|
|
|
for _, test := range []struct {
|
|
|
|
|
in string
|
|
|
|
|
out string
|
|
|
|
|
}{
|
|
|
|
|
{"", ""},
|
|
|
|
|
{"abc 123", "abc 123"},
|
2018-04-27 05:02:31 +08:00
|
|
|
|
{`\*<>?:|#%".~`, `\*<>?:|#%".~`},
|
|
|
|
|
{`\*<>?:|#%".~/\*<>?:|#%".~`, `\*<>?:|#%".~/\*<>?:|#%".~`},
|
2017-07-17 13:36:45 +08:00
|
|
|
|
{" leading space", "␠leading space"},
|
2018-04-27 05:02:31 +08:00
|
|
|
|
{" path/ leading spaces", "␠path/␠ leading spaces"},
|
|
|
|
|
{"trailing space ", "trailing space␠"},
|
|
|
|
|
{"trailing spaces /path ", "trailing spaces ␠/path␠"},
|
2017-07-17 13:36:45 +08:00
|
|
|
|
} {
|
|
|
|
|
got := replaceReservedChars(test.in)
|
|
|
|
|
if got != test.out {
|
|
|
|
|
t.Errorf("replaceReservedChars(%q) want %q got %q", test.in, test.out, got)
|
|
|
|
|
}
|
|
|
|
|
got2 := restoreReservedChars(got)
|
|
|
|
|
if got2 != test.in {
|
|
|
|
|
t.Errorf("restoreReservedChars(%q) want %q got %q", got, test.in, got2)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|