1package match 2 3import ( 4 "reflect" 5 "testing" 6) 7 8func TestNothingIndex(t *testing.T) { 9 for id, test := range []struct { 10 fixture string 11 index int 12 segments []int 13 }{ 14 { 15 "abc", 16 0, 17 []int{0}, 18 }, 19 { 20 "", 21 0, 22 []int{0}, 23 }, 24 } { 25 p := NewNothing() 26 index, segments := p.Index(test.fixture) 27 if index != test.index { 28 t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index) 29 } 30 if !reflect.DeepEqual(segments, test.segments) { 31 t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments) 32 } 33 } 34} 35 36func BenchmarkIndexNothing(b *testing.B) { 37 m := NewNothing() 38 39 for i := 0; i < b.N; i++ { 40 _, s := m.Index(bench_pattern) 41 releaseSegments(s) 42 } 43} 44 45func BenchmarkIndexNothingParallel(b *testing.B) { 46 m := NewNothing() 47 48 b.RunParallel(func(pb *testing.PB) { 49 for pb.Next() { 50 _, s := m.Index(bench_pattern) 51 releaseSegments(s) 52 } 53 }) 54} 55