Rewrote to use new API for compiling and finding matches

master
Aadhavan Srinivasan 4 weeks ago
parent 644ed15af0
commit 8e8067482a

@ -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() {

Loading…
Cancel
Save