1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package indexer
import "testing"
func TestUnescapeSpecials(t *testing.T) {
specials := []string{
`+`, `-`, `&&`, `||`,
`!`, `(`, `)`, `{`, `}`,
`[`, `]`, `^`, `"`, `~`,
`*`, `?`, `:`, `\`,
}
for _, s := range specials {
in := `\` + s
if out := unescape(in); out != s {
t.Errorf("Unescaping %s failed. expected = %s, got = %s", in, s, out)
}
}
}
func TestUnescapedStrings(t *testing.T) {
tests := []struct {
in, out string
}{
{`00\:01\:02`, `00:01:02`},
{`foo \&& bar`, `foo && bar`},
{`some\\file\\path`, `some\file\path`},
}
for _, tt := range tests {
if out := unescape(tt.in); out != tt.out {
t.Errorf("Unescaping %s failed. expected = %s, got = %s", tt.in, tt.out, out)
}
}
}
|