mirror of https://github.com/mickael-menu/zk
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
766 B
Go
33 lines
766 B
Go
4 years ago
|
package icu
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
4 years ago
|
"github.com/mickael-menu/zk/internal/util/test/assert"
|
||
4 years ago
|
)
|
||
|
|
||
|
func TestEscapePAttern(t *testing.T) {
|
||
|
tests := map[string]string{
|
||
|
`foo bar`: `foo bar`,
|
||
|
`\a`: `\\a`,
|
||
|
`.`: `\.`,
|
||
|
`^`: `\^`,
|
||
|
`$`: `\$`,
|
||
|
`(`: `\(`,
|
||
|
`)`: `\)`,
|
||
|
`[`: `\[`,
|
||
|
`]`: `\]`,
|
||
|
`{`: `\{`,
|
||
|
`}`: `\}`,
|
||
|
`|`: `\|`,
|
||
|
`*`: `\*`,
|
||
|
`+`: `\+`,
|
||
|
`?`: `\?`,
|
||
|
`(?:[A-Za-z0-9]+[._]?){1,}[A-Za-z0-9]+\@(?:(?:[A-Za-z0-9]+[-]?){1,}[A-Za-z0-9]+\.){1,}`: `\(\?:\[A-Za-z0-9\]\+\[\._\]\?\)\{1,\}\[A-Za-z0-9\]\+\\@\(\?:\(\?:\[A-Za-z0-9\]\+\[-\]\?\)\{1,\}\[A-Za-z0-9\]\+\\\.\)\{1,\}`,
|
||
|
}
|
||
|
|
||
|
for input, expected := range tests {
|
||
|
assert.Equal(t, EscapePattern(input), expected)
|
||
|
}
|
||
|
}
|