Add glob conversion

This commit is contained in:
2022-05-18 23:27:47 -07:00
parent 9d969a1382
commit e03c680213
2 changed files with 96 additions and 0 deletions

38
glob_test.go Normal file
View File

@@ -0,0 +1,38 @@
package pcre_test
import (
"testing"
"go.arsenm.dev/pcre"
)
func TestCompileGlob(t *testing.T) {
r, err := pcre.CompileGlob("/**/bin")
if err != nil {
t.Fatal(err)
}
if !r.MatchString("/bin") {
t.Error("expected /bin to match")
}
if !r.MatchString("/usr/bin") {
t.Error("expected /usr/bin to match")
}
if !r.MatchString("/usr/local/bin") {
t.Error("expected /usr/local/bin to match")
}
if r.MatchString("/usr") {
t.Error("expected /usr not to match")
}
if r.MatchString("/usr/local") {
t.Error("expected /usr/local not to match")
}
if r.MatchString("/home") {
t.Error("expected /home not to match")
}
}