|
|
|
@ -673,7 +673,33 @@ var groupTests = []struct {
|
|
|
|
|
{`(<389-400>)`, nil, `391`, []Match{[]Group{{0, 3}, {0, 3}}}},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFindAllMatches(t *testing.T) {
|
|
|
|
|
func TestFind(t *testing.T) {
|
|
|
|
|
for _, test := range reTests {
|
|
|
|
|
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
|
|
|
|
regComp, err := Compile(test.re, test.flags...)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if test.result != nil {
|
|
|
|
|
panic(fmt.Errorf("Test Error: %v", err))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
groupIndex, err := regComp.Find(test.str)
|
|
|
|
|
if err != nil { // No matches found
|
|
|
|
|
if len(test.result) == 0 {
|
|
|
|
|
return // Manually pass the test, because this is the expected behavior
|
|
|
|
|
} else {
|
|
|
|
|
t.Errorf("Wanted no match Got %v\n", groupIndex)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if groupIndex != test.result[0] {
|
|
|
|
|
t.Errorf("Wanted %v Got %v\n", test.result, groupIndex)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFindAll(t *testing.T) {
|
|
|
|
|
for _, test := range reTests {
|
|
|
|
|
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
|
|
|
|
regComp, err := Compile(test.re, test.flags...)
|
|
|
|
@ -716,7 +742,7 @@ func TestFindString(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFindAllStrings(t *testing.T) {
|
|
|
|
|
func TestFindAllString(t *testing.T) {
|
|
|
|
|
for _, test := range reTests {
|
|
|
|
|
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
|
|
|
|
regComp, err := Compile(test.re, test.flags...)
|
|
|
|
@ -741,7 +767,7 @@ func TestFindAllStrings(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFindAllGroups(t *testing.T) {
|
|
|
|
|
func TestFindAllSubmatch(t *testing.T) {
|
|
|
|
|
for _, test := range groupTests {
|
|
|
|
|
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
|
|
|
|
regComp, err := Compile(test.re, test.flags...)
|
|
|
|
|