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
diff --git a/src/pkg/regexp/find_test.go b/src/pkg/regexp/find_test.go
index 9909303..83b249e 100644
--- a/src/pkg/regexp/find_test.go
+++ b/src/pkg/regexp/find_test.go
@@ -6,6 +6,7 @@
import (
"fmt"
+ "strings"
"testing"
)
@@ -191,6 +192,12 @@
}
}
+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 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) {