Wrote test for 'FindSubmatch'
This commit is contained in:
@@ -767,6 +767,26 @@ func TestFindAllString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFindSubmatch(t *testing.T) {
|
||||||
|
for _, test := range groupTests {
|
||||||
|
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(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match, err := regComp.FindSubmatch(test.str)
|
||||||
|
for i := range match {
|
||||||
|
if match[i].IsValid() {
|
||||||
|
if test.result[0][i] != match[i] {
|
||||||
|
t.Errorf("Wanted %v Got %v\n", test.result[0], match)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
func TestFindAllSubmatch(t *testing.T) {
|
func TestFindAllSubmatch(t *testing.T) {
|
||||||
for _, test := range groupTests {
|
for _, test := range groupTests {
|
||||||
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
t.Run(test.re+" "+test.str, func(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user