mirror of https://github.com/gobwas/glob.git
tests
This commit is contained in:
parent
f2255c18f5
commit
df67a5925f
|
@ -49,12 +49,10 @@ func optimize(matcher match.Matcher) match.Matcher {
|
|||
|
||||
if leftNil && rightSuffix {
|
||||
return match.PrefixSuffix{Prefix: r.Str, Suffix: rs.Suffix}
|
||||
// return match.EveryOf{match.Matchers{match.Prefix{r.Str}, rs}}
|
||||
}
|
||||
|
||||
if rightNil && leftPrefix {
|
||||
return match.PrefixSuffix{Prefix: lp.Prefix, Suffix: r.Str}
|
||||
// return match.EveryOf{match.Matchers{lp, match.Suffix{r.Str}}}
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -278,7 +278,6 @@ func TestCompiler(t *testing.T) {
|
|||
},
|
||||
{
|
||||
ast: pattern(&nodeText{text: "abc"}, &nodeAny{}, &nodeText{text: "def"}),
|
||||
// result: match.EveryOf{match.Matchers{match.Prefix{"abc"}, match.Suffix{"def"}}},
|
||||
result: match.PrefixSuffix{"abc", "def"},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestCompilePattern(t *testing.T) {
|
|||
exp match.Matcher
|
||||
}{
|
||||
// {
|
||||
// pattern: "{*,def}ghi",
|
||||
// pattern: "{*,def,abc[a-z]*}ghi",
|
||||
// exp: match.Raw{"t"},
|
||||
// },
|
||||
} {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAnyIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
sep string
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
".",
|
||||
"abc",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
{
|
||||
".",
|
||||
"abc.def",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
} {
|
||||
p := Any{test.sep}
|
||||
index, segments := p.Index(test.fixture)
|
||||
if index != test.index {
|
||||
t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
|
||||
}
|
||||
if !reflect.DeepEqual(segments, test.segments) {
|
||||
t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue