Commit 7db904c1 authored by Rob Pike's avatar Rob Pike

regexp: add support for matching text read from things that implement

ReadRune.  (If you have a Reader but not a RuneReader, use bufio.)

The matching code is a few percent slower but significantly cleaner.

R=rsc
CC=golang-dev
https://golang.org/cl/4125046
parent 63457d08
......@@ -6,6 +6,7 @@ package regexp
import (
"fmt"
"strings"
"testing"
)
......@@ -191,6 +192,12 @@ func TestFindStringIndex(t *testing.T) {
}
}
func TestFindReaderIndex(t *testing.T) {
for _, test := range findTests {
testFindIndex(&test, MustCompile(test.pat).FindReaderIndex(strings.NewReader(test.text)), t)
}
}
// Now come the simple All cases.
func TestFindAll(t *testing.T) {
......@@ -387,6 +394,12 @@ func TestFindStringSubmatchIndex(t *testing.T) {
}
}
func TestFindReaderSubmatchIndex(t *testing.T) {
for _, test := range findTests {
testFindSubmatchIndex(&test, MustCompile(test.pat).FindReaderSubmatchIndex(strings.NewReader(test.text)), t)
}
}
// Now come the monster AllSubmatch cases.
func TestFindAllSubmatch(t *testing.T) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment