Throw error if match isn't found but test.result has >0 elements

This commit is contained in:
2025-02-09 09:13:29 -05:00
parent 7231169270
commit d172a58258

View File

@@ -790,6 +790,13 @@ func TestFindSubmatch(t *testing.T) {
}
}
match, err := regComp.FindSubmatch(test.str)
if err != nil {
if len(test.result) != 0 {
t.Errorf("Wanted %v got no match\n", test.result[0])
}
} else if len(test.result) == 0 {
t.Errorf("Wanted no match got %v\n", match)
}
for i := range match {
if match[i].IsValid() {
if test.result[0][i] != match[i] {