From 375baa172229976a47acffbc01f8659c490462a7 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 12 Feb 2025 07:51:20 -0500 Subject: [PATCH] Wrote more backreference tests --- regex/re_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/regex/re_test.go b/regex/re_test.go index c751c26..1b717c4 100644 --- a/regex/re_test.go +++ b/regex/re_test.go @@ -604,6 +604,10 @@ var groupTests = []struct { {`(?:(cat)|(dog))\2`, nil, `catdog`, []Match{}}, {`(?:a)\1`, nil, `aa`, nil}, {`((cat)|(dog)|(cow)|(bat))\4`, nil, `cowcow`, []Match{[]Group{{0, 6}, {0, 3}, {-1, -1}, {-1, -1}, {0, 3}, {-1, -1}}}}, + {`(a|b)*\1`, nil, `abb`, []Match{[]Group{{0, 3}, {1, 2}}}}, + {`(a|b)*\1`, nil, `aba`, []Match{}}, + {`(a|b)*\1`, nil, `bab`, []Match{}}, + {`(a|b)*\1`, nil, `baa`, []Match{[]Group{{0, 3}, {1, 2}}}}, {`(a)(b)c|ab`, nil, `ab`, []Match{[]Group{{0, 2}}}}, {`(a)+x`, nil, `aaax`, []Match{[]Group{{0, 4}, {2, 3}}}},