...

Source file src/github.com/gobwas/glob/match/suffix_any_test.go

Documentation: github.com/gobwas/glob/match

     1  package match
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestSuffixAnyIndex(t *testing.T) {
     9  	for id, test := range []struct {
    10  		suffix     string
    11  		separators []rune
    12  		fixture    string
    13  		index      int
    14  		segments   []int
    15  	}{
    16  		{
    17  			"ab",
    18  			[]rune{'.'},
    19  			"ab",
    20  			0,
    21  			[]int{2},
    22  		},
    23  		{
    24  			"ab",
    25  			[]rune{'.'},
    26  			"cab",
    27  			0,
    28  			[]int{3},
    29  		},
    30  		{
    31  			"ab",
    32  			[]rune{'.'},
    33  			"qw.cdab.efg",
    34  			3,
    35  			[]int{4},
    36  		},
    37  	} {
    38  		p := NewSuffixAny(test.suffix, test.separators)
    39  		index, segments := p.Index(test.fixture)
    40  		if index != test.index {
    41  			t.Errorf("#%d unexpected index: exp: %d, act: %d", id, test.index, index)
    42  		}
    43  		if !reflect.DeepEqual(segments, test.segments) {
    44  			t.Errorf("#%d unexpected segments: exp: %v, act: %v", id, test.segments, segments)
    45  		}
    46  	}
    47  }
    48  

View as plain text