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

implementPCREMatchingRules
Aadhavan Srinivasan 4 weeks ago
parent 7231169270
commit d172a58258

@ -790,6 +790,13 @@ func TestFindSubmatch(t *testing.T) {
} }
} }
match, err := regComp.FindSubmatch(test.str) 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 { for i := range match {
if match[i].IsValid() { if match[i].IsValid() {
if test.result[0][i] != match[i] { if test.result[0][i] != match[i] {

Loading…
Cancel
Save