vendor: Update github.com/gobwas/glob (fixes #3174)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3207
This commit is contained in:
13
vendor/github.com/gobwas/glob/match/any_of.go
generated
vendored
13
vendor/github.com/gobwas/glob/match/any_of.go
generated
vendored
@@ -63,16 +63,15 @@ func (self AnyOf) Len() (l int) {
|
||||
l = -1
|
||||
for _, m := range self.Matchers {
|
||||
ml := m.Len()
|
||||
if ml == -1 {
|
||||
return -1
|
||||
}
|
||||
|
||||
if l == -1 {
|
||||
switch {
|
||||
case l == -1:
|
||||
l = ml
|
||||
continue
|
||||
}
|
||||
|
||||
if l != ml {
|
||||
case ml == -1:
|
||||
return -1
|
||||
|
||||
case l != ml:
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
53
vendor/github.com/gobwas/glob/match/any_of_test.go
generated
vendored
53
vendor/github.com/gobwas/glob/match/any_of_test.go
generated
vendored
@@ -1,53 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAnyOfIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
matchers Matchers
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
Matchers{
|
||||
NewAny(nil),
|
||||
NewText("b"),
|
||||
NewText("c"),
|
||||
},
|
||||
"abc",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
{
|
||||
Matchers{
|
||||
NewPrefix("b"),
|
||||
NewSuffix("c"),
|
||||
},
|
||||
"abc",
|
||||
0,
|
||||
[]int{3},
|
||||
},
|
||||
{
|
||||
Matchers{
|
||||
NewList([]rune("[def]"), false),
|
||||
NewList([]rune("[abc]"), false),
|
||||
},
|
||||
"abcdef",
|
||||
0,
|
||||
[]int{1},
|
||||
},
|
||||
} {
|
||||
everyOf := NewAnyOf(test.matchers...)
|
||||
index, segments := everyOf.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/any_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/any_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAnyIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
sep []rune
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
[]rune{'.'},
|
||||
"abc",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
{
|
||||
[]rune{'.'},
|
||||
"abc.def",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
} {
|
||||
p := NewAny(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexAny(b *testing.B) {
|
||||
m := NewAny(bench_separators)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexAnyParallel(b *testing.B) {
|
||||
m := NewAny(bench_separators)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
90
vendor/github.com/gobwas/glob/match/btree_test.go
generated
vendored
90
vendor/github.com/gobwas/glob/match/btree_test.go
generated
vendored
@@ -1,90 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBTree(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
tree BTree
|
||||
str string
|
||||
exp bool
|
||||
}{
|
||||
{
|
||||
NewBTree(NewText("abc"), NewSuper(), NewSuper()),
|
||||
"abc",
|
||||
true,
|
||||
},
|
||||
{
|
||||
NewBTree(NewText("a"), NewSingle(nil), NewSingle(nil)),
|
||||
"aaa",
|
||||
true,
|
||||
},
|
||||
{
|
||||
NewBTree(NewText("b"), NewSingle(nil), nil),
|
||||
"bbb",
|
||||
false,
|
||||
},
|
||||
{
|
||||
NewBTree(
|
||||
NewText("c"),
|
||||
NewBTree(
|
||||
NewSingle(nil),
|
||||
NewSuper(),
|
||||
nil,
|
||||
),
|
||||
nil,
|
||||
),
|
||||
"abc",
|
||||
true,
|
||||
},
|
||||
} {
|
||||
act := test.tree.Match(test.str)
|
||||
if act != test.exp {
|
||||
t.Errorf("#%d match %q error: act: %t; exp: %t", id, test.str, act, test.exp)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type fakeMatcher struct {
|
||||
len int
|
||||
name string
|
||||
}
|
||||
|
||||
func (f *fakeMatcher) Match(string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var i = 3
|
||||
|
||||
func (f *fakeMatcher) Index(s string) (int, []int) {
|
||||
seg := make([]int, 0, i)
|
||||
for x := 0; x < i; x++ {
|
||||
seg = append(seg, x)
|
||||
}
|
||||
return 0, seg
|
||||
}
|
||||
func (f *fakeMatcher) Len() int {
|
||||
return f.len
|
||||
}
|
||||
func (f *fakeMatcher) String() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
func BenchmarkMatchBTree(b *testing.B) {
|
||||
l := &fakeMatcher{4, "left_fake"}
|
||||
r := &fakeMatcher{4, "right_fake"}
|
||||
v := &fakeMatcher{2, "value_fake"}
|
||||
|
||||
// must be <= len(l + r + v)
|
||||
fixture := "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
|
||||
|
||||
bt := NewBTree(v, l, r)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
bt.Match(fixture)
|
||||
}
|
||||
})
|
||||
}
|
||||
74
vendor/github.com/gobwas/glob/match/contains_test.go
generated
vendored
74
vendor/github.com/gobwas/glob/match/contains_test.go
generated
vendored
@@ -1,74 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestContainsIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
prefix string
|
||||
not bool
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"ab",
|
||||
false,
|
||||
"abc",
|
||||
0,
|
||||
[]int{2, 3},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
false,
|
||||
"fffabfff",
|
||||
0,
|
||||
[]int{5, 6, 7, 8},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
true,
|
||||
"abc",
|
||||
0,
|
||||
[]int{0},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
true,
|
||||
"fffabfff",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
} {
|
||||
p := NewContains(test.prefix, test.not)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexContains(b *testing.B) {
|
||||
m := NewContains(string(bench_separators), true)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexContainsParallel(b *testing.B) {
|
||||
m := NewContains(string(bench_separators), true)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
45
vendor/github.com/gobwas/glob/match/every_of_test.go
generated
vendored
45
vendor/github.com/gobwas/glob/match/every_of_test.go
generated
vendored
@@ -1,45 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEveryOfIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
matchers Matchers
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
Matchers{
|
||||
NewAny(nil),
|
||||
NewText("b"),
|
||||
NewText("c"),
|
||||
},
|
||||
"dbc",
|
||||
-1,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
Matchers{
|
||||
NewAny(nil),
|
||||
NewPrefix("b"),
|
||||
NewSuffix("c"),
|
||||
},
|
||||
"abc",
|
||||
1,
|
||||
[]int{2},
|
||||
},
|
||||
} {
|
||||
everyOf := NewEveryOf(test.matchers...)
|
||||
index, segments := everyOf.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
58
vendor/github.com/gobwas/glob/match/list_test.go
generated
vendored
58
vendor/github.com/gobwas/glob/match/list_test.go
generated
vendored
@@ -1,58 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
list []rune
|
||||
not bool
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
[]rune("ab"),
|
||||
false,
|
||||
"abc",
|
||||
0,
|
||||
[]int{1},
|
||||
},
|
||||
{
|
||||
[]rune("ab"),
|
||||
true,
|
||||
"fffabfff",
|
||||
0,
|
||||
[]int{1},
|
||||
},
|
||||
} {
|
||||
p := NewList(test.list, test.not)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexList(b *testing.B) {
|
||||
m := NewList([]rune("def"), false)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
m.Index(bench_pattern)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexListParallel(b *testing.B) {
|
||||
m := NewList([]rune("def"), false)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
m.Index(bench_pattern)
|
||||
}
|
||||
})
|
||||
}
|
||||
90
vendor/github.com/gobwas/glob/match/match_test.go
generated
vendored
90
vendor/github.com/gobwas/glob/match/match_test.go
generated
vendored
@@ -1,90 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var bench_separators = []rune{'.'}
|
||||
|
||||
const bench_pattern = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
func TestAppendMerge(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
segments [2][]int
|
||||
exp []int
|
||||
}{
|
||||
{
|
||||
[2][]int{
|
||||
[]int{0, 6, 7},
|
||||
[]int{0, 1, 3},
|
||||
},
|
||||
[]int{0, 1, 3, 6, 7},
|
||||
},
|
||||
{
|
||||
[2][]int{
|
||||
[]int{0, 1, 3, 6, 7},
|
||||
[]int{0, 1, 10},
|
||||
},
|
||||
[]int{0, 1, 3, 6, 7, 10},
|
||||
},
|
||||
} {
|
||||
act := appendMerge(test.segments[0], test.segments[1])
|
||||
if !reflect.DeepEqual(act, test.exp) {
|
||||
t.Errorf("#%d merge sort segments unexpected:\nact: %v\nexp:%v", id, act, test.exp)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAppendMerge(b *testing.B) {
|
||||
s1 := []int{0, 1, 3, 6, 7}
|
||||
s2 := []int{0, 1, 3}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
appendMerge(s1, s2)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAppendMergeParallel(b *testing.B) {
|
||||
s1 := []int{0, 1, 3, 6, 7}
|
||||
s2 := []int{0, 1, 3}
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
appendMerge(s1, s2)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkReverse(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
reverseSegments([]int{1, 2, 3, 4})
|
||||
}
|
||||
}
|
||||
|
||||
func getTable() []int {
|
||||
table := make([]int, utf8.MaxRune+1)
|
||||
for i := 0; i <= utf8.MaxRune; i++ {
|
||||
table[i] = utf8.RuneLen(rune(i))
|
||||
}
|
||||
|
||||
return table
|
||||
}
|
||||
|
||||
var table = getTable()
|
||||
|
||||
const runeToLen = 'q'
|
||||
|
||||
func BenchmarkRuneLenFromTable(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = table[runeToLen]
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRuneLenFromUTF8(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = utf8.RuneLen(runeToLen)
|
||||
}
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/max_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/max_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMaxIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
limit int
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
3,
|
||||
"abc",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
{
|
||||
3,
|
||||
"abcdef",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
} {
|
||||
p := NewMax(test.limit)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexMax(b *testing.B) {
|
||||
m := NewMax(10)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexMaxParallel(b *testing.B) {
|
||||
m := NewMax(10)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/min_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/min_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMinIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
limit int
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
1,
|
||||
"abc",
|
||||
0,
|
||||
[]int{1, 2, 3},
|
||||
},
|
||||
{
|
||||
3,
|
||||
"abcd",
|
||||
0,
|
||||
[]int{3, 4},
|
||||
},
|
||||
} {
|
||||
p := NewMin(test.limit)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexMin(b *testing.B) {
|
||||
m := NewMin(10)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexMinParallel(b *testing.B) {
|
||||
m := NewMin(10)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
54
vendor/github.com/gobwas/glob/match/nothing_test.go
generated
vendored
54
vendor/github.com/gobwas/glob/match/nothing_test.go
generated
vendored
@@ -1,54 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNothingIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"abc",
|
||||
0,
|
||||
[]int{0},
|
||||
},
|
||||
{
|
||||
"",
|
||||
0,
|
||||
[]int{0},
|
||||
},
|
||||
} {
|
||||
p := NewNothing()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexNothing(b *testing.B) {
|
||||
m := NewNothing()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexNothingParallel(b *testing.B) {
|
||||
m := NewNothing()
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
67
vendor/github.com/gobwas/glob/match/prefix_suffix_test.go
generated
vendored
67
vendor/github.com/gobwas/glob/match/prefix_suffix_test.go
generated
vendored
@@ -1,67 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrefixSuffixIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
prefix string
|
||||
suffix string
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"a",
|
||||
"c",
|
||||
"abc",
|
||||
0,
|
||||
[]int{3},
|
||||
},
|
||||
{
|
||||
"f",
|
||||
"f",
|
||||
"fffabfff",
|
||||
0,
|
||||
[]int{1, 2, 3, 6, 7, 8},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
"bc",
|
||||
"abc",
|
||||
0,
|
||||
[]int{3},
|
||||
},
|
||||
} {
|
||||
p := NewPrefixSuffix(test.prefix, test.suffix)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexPrefixSuffix(b *testing.B) {
|
||||
m := NewPrefixSuffix("qew", "sqw")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexPrefixSuffixParallel(b *testing.B) {
|
||||
m := NewPrefixSuffix("qew", "sqw")
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/prefix_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/prefix_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrefixIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
prefix string
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"ab",
|
||||
"abc",
|
||||
0,
|
||||
[]int{2, 3},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
"fffabfff",
|
||||
3,
|
||||
[]int{2, 3, 4, 5},
|
||||
},
|
||||
} {
|
||||
p := NewPrefix(test.prefix)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexPrefix(b *testing.B) {
|
||||
m := NewPrefix("qew")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexPrefixParallel(b *testing.B) {
|
||||
m := NewPrefix("qew")
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
67
vendor/github.com/gobwas/glob/match/range_test.go
generated
vendored
67
vendor/github.com/gobwas/glob/match/range_test.go
generated
vendored
@@ -1,67 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRangeIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
lo, hi rune
|
||||
not bool
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
'a', 'z',
|
||||
false,
|
||||
"abc",
|
||||
0,
|
||||
[]int{1},
|
||||
},
|
||||
{
|
||||
'a', 'c',
|
||||
false,
|
||||
"abcd",
|
||||
0,
|
||||
[]int{1},
|
||||
},
|
||||
{
|
||||
'a', 'c',
|
||||
true,
|
||||
"abcd",
|
||||
3,
|
||||
[]int{1},
|
||||
},
|
||||
} {
|
||||
m := NewRange(test.lo, test.hi, test.not)
|
||||
index, segments := m.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexRange(b *testing.B) {
|
||||
m := NewRange('0', '9', false)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexRangeParallel(b *testing.B) {
|
||||
m := NewRange('0', '9', false)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
82
vendor/github.com/gobwas/glob/match/row_test.go
generated
vendored
82
vendor/github.com/gobwas/glob/match/row_test.go
generated
vendored
@@ -1,82 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRowIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
matchers Matchers
|
||||
length int
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
Matchers{
|
||||
NewText("abc"),
|
||||
NewText("def"),
|
||||
NewSingle(nil),
|
||||
},
|
||||
7,
|
||||
"qweabcdefghij",
|
||||
3,
|
||||
[]int{7},
|
||||
},
|
||||
{
|
||||
Matchers{
|
||||
NewText("abc"),
|
||||
NewText("def"),
|
||||
NewSingle(nil),
|
||||
},
|
||||
7,
|
||||
"abcd",
|
||||
-1,
|
||||
nil,
|
||||
},
|
||||
} {
|
||||
p := NewRow(test.length, test.matchers...)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRowIndex(b *testing.B) {
|
||||
m := NewRow(
|
||||
7,
|
||||
Matchers{
|
||||
NewText("abc"),
|
||||
NewText("def"),
|
||||
NewSingle(nil),
|
||||
}...,
|
||||
)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexRowParallel(b *testing.B) {
|
||||
m := NewRow(
|
||||
7,
|
||||
Matchers{
|
||||
NewText("abc"),
|
||||
NewText("def"),
|
||||
NewSingle(nil),
|
||||
}...,
|
||||
)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
83
vendor/github.com/gobwas/glob/match/segments_test.go
generated
vendored
83
vendor/github.com/gobwas/glob/match/segments_test.go
generated
vendored
@@ -1,83 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func benchPool(i int, b *testing.B) {
|
||||
pool := sync.Pool{New: func() interface{} {
|
||||
return make([]int, 0, i)
|
||||
}}
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
s := pool.Get().([]int)[:0]
|
||||
pool.Put(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func benchMake(i int, b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_ = make([]int, 0, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkSegmentsPool_1(b *testing.B) {
|
||||
benchPool(1, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_2(b *testing.B) {
|
||||
benchPool(2, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_4(b *testing.B) {
|
||||
benchPool(4, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_8(b *testing.B) {
|
||||
benchPool(8, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_16(b *testing.B) {
|
||||
benchPool(16, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_32(b *testing.B) {
|
||||
benchPool(32, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_64(b *testing.B) {
|
||||
benchPool(64, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_128(b *testing.B) {
|
||||
benchPool(128, b)
|
||||
}
|
||||
func BenchmarkSegmentsPool_256(b *testing.B) {
|
||||
benchPool(256, b)
|
||||
}
|
||||
|
||||
func BenchmarkSegmentsMake_1(b *testing.B) {
|
||||
benchMake(1, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_2(b *testing.B) {
|
||||
benchMake(2, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_4(b *testing.B) {
|
||||
benchMake(4, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_8(b *testing.B) {
|
||||
benchMake(8, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_16(b *testing.B) {
|
||||
benchMake(16, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_32(b *testing.B) {
|
||||
benchMake(32, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_64(b *testing.B) {
|
||||
benchMake(64, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_128(b *testing.B) {
|
||||
benchMake(128, b)
|
||||
}
|
||||
func BenchmarkSegmentsMake_256(b *testing.B) {
|
||||
benchMake(256, b)
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/single_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/single_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSingleIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
separators []rune
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
[]rune{'.'},
|
||||
".abc",
|
||||
1,
|
||||
[]int{1},
|
||||
},
|
||||
{
|
||||
[]rune{'.'},
|
||||
".",
|
||||
-1,
|
||||
nil,
|
||||
},
|
||||
} {
|
||||
p := NewSingle(test.separators)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSingle(b *testing.B) {
|
||||
m := NewSingle(bench_separators)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSingleParallel(b *testing.B) {
|
||||
m := NewSingle(bench_separators)
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/suffix_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/suffix_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSuffixIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
prefix string
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"ab",
|
||||
"abc",
|
||||
0,
|
||||
[]int{2},
|
||||
},
|
||||
{
|
||||
"ab",
|
||||
"fffabfff",
|
||||
0,
|
||||
[]int{5},
|
||||
},
|
||||
} {
|
||||
p := NewSuffix(test.prefix)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSuffix(b *testing.B) {
|
||||
m := NewSuffix("qwe")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSuffixParallel(b *testing.B) {
|
||||
m := NewSuffix("qwe")
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
54
vendor/github.com/gobwas/glob/match/super_test.go
generated
vendored
54
vendor/github.com/gobwas/glob/match/super_test.go
generated
vendored
@@ -1,54 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSuperIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"abc",
|
||||
0,
|
||||
[]int{0, 1, 2, 3},
|
||||
},
|
||||
{
|
||||
"",
|
||||
0,
|
||||
[]int{0},
|
||||
},
|
||||
} {
|
||||
p := NewSuper()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSuper(b *testing.B) {
|
||||
m := NewSuper()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexSuperParallel(b *testing.B) {
|
||||
m := NewSuper()
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
57
vendor/github.com/gobwas/glob/match/text_test.go
generated
vendored
57
vendor/github.com/gobwas/glob/match/text_test.go
generated
vendored
@@ -1,57 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTextIndex(t *testing.T) {
|
||||
for id, test := range []struct {
|
||||
text string
|
||||
fixture string
|
||||
index int
|
||||
segments []int
|
||||
}{
|
||||
{
|
||||
"b",
|
||||
"abc",
|
||||
1,
|
||||
[]int{1},
|
||||
},
|
||||
{
|
||||
"f",
|
||||
"abcd",
|
||||
-1,
|
||||
nil,
|
||||
},
|
||||
} {
|
||||
m := NewText(test.text)
|
||||
index, segments := m.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexText(b *testing.B) {
|
||||
m := NewText("foo")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIndexTextParallel(b *testing.B) {
|
||||
m := NewText("foo")
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, s := m.Index(bench_pattern)
|
||||
releaseSegments(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user