diff --git a/regex/re_test.go b/regex/re_test.go index ce2ed69..1ce9136 100644 --- a/regex/re_test.go +++ b/regex/re_test.go @@ -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) { for _, test := range groupTests { t.Run(test.re+" "+test.str, func(t *testing.T) {