Rewrote to use new API for compiling and finding matches
This commit is contained in:
16
re_test.go
16
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() {
|
||||
|
Reference in New Issue
Block a user