From d172a58258cc62523a78264e754ff3ddc6e3c42f Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sun, 9 Feb 2025 09:13:29 -0500 Subject: [PATCH] Throw error if match isn't found but test.result has >0 elements --- regex/re_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/regex/re_test.go b/regex/re_test.go index b8b1381..de6aaba 100644 --- a/regex/re_test.go +++ b/regex/re_test.go @@ -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] {