2018-08-02 01:02:35 +02:00
|
|
|
|
package jottacloud
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestReplace(t *testing.T) {
|
|
|
|
|
for _, test := range []struct {
|
|
|
|
|
in string
|
|
|
|
|
out string
|
|
|
|
|
}{
|
|
|
|
|
{"", ""},
|
|
|
|
|
{"abc 123", "abc 123"},
|
2018-09-16 22:30:20 +02:00
|
|
|
|
{`\*<>?:;|"`, `\*<>?:;|"`},
|
|
|
|
|
{`\*<>?:;|"\*<>?:;|"`, `\*<>?:;|"\*<>?:;|"`},
|
2018-08-02 01:02:35 +02:00
|
|
|
|
{" leading space", "␠leading space"},
|
|
|
|
|
{"trailing space ", "trailing space␠"},
|
|
|
|
|
{" leading space/ leading space/ leading space", "␠leading space/␠leading space/␠leading space"},
|
|
|
|
|
{"trailing space /trailing space /trailing space ", "trailing space␠/trailing space␠/trailing space␠"},
|
|
|
|
|
} {
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|