From 8e8067482ab0a24a26f19909da8e908f57d10d4b Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Mon, 6 Jan 2025 20:12:18 -0600 Subject: [PATCH] Rewrote to use new API for compiling and finding matches --- re_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/re_test.go b/re_test.go index 9fdee67..2367df5 100644 --- a/re_test.go +++ b/re_test.go @@ -187,9 +187,11 @@ var groupTests = []struct { func TestFindAllMatches(t *testing.T) { for _, test := range reTests { t.Run(test.re+" "+test.str, func(t *testing.T) { - re_postfix := shuntingYard(test.re) - startState, numGroups := thompson(re_postfix) - matchIndices := findAllMatches(startState, []rune(test.str), numGroups) + regComp, err := Compile(test.re) + if err != nil { + panic(err) + } + matchIndices := findAllMatches(regComp, test.str) zeroGroups := make([]Group, len(matchIndices)) for i, m := range matchIndices { zeroGroups[i] = m[0] @@ -204,9 +206,11 @@ func TestFindAllMatches(t *testing.T) { func TestFindAllGroups(t *testing.T) { for _, test := range groupTests { t.Run(test.re+" "+test.str, func(t *testing.T) { - re_postfix := shuntingYard(test.re) - startState, numGroups := thompson(re_postfix) - matchIndices := findAllMatches(startState, []rune(test.str), numGroups) + regComp, err := Compile(test.re) + if err != nil { + panic(err) + } + matchIndices := findAllMatches(regComp, test.str) for i := range matchIndices { for j := range matchIndices[i] { if matchIndices[i][j].isValid() {