import (
"strings";
- "testing";
)
var good_re = []string{
tester{ `a*(|(b))c*`, "aacc", vec{0,4, 2,2, -1,-1} },
}
-func compileTest(t *testing.T, expr string, error string) *Regexp {
+func compileTest(t *T, expr string, error string) *Regexp {
re, err := CompileRegexp(expr);
if err != error {
t.Error("compiling `", expr, "`; unexpected error: ", err);
return re
}
-func printVec(t *testing.T, m []int) {
+func printVec(t *T, m []int) {
l := len(m);
if l == 0 {
t.Log("\t<no match>");
}
}
-func printStrings(t *testing.T, m []string) {
+func printStrings(t *T, m []string) {
l := len(m);
if l == 0 {
t.Log("\t<no match>");
}
}
-func printBytes(t *testing.T, b [][]byte) {
+func printBytes(t *T, b [][]byte) {
l := len(b);
if l == 0 {
t.Log("\t<no match>");
return true
}
-func executeTest(t *testing.T, expr string, str string, match []int) {
+func executeTest(t *T, expr string, str string, match []int) {
re := compileTest(t, expr, "");
if re == nil {
return
}
}
-func TestGoodCompile(t *testing.T) {
+func TestGoodCompile(t *T) {
for i := 0; i < len(good_re); i++ {
compileTest(t, good_re[i], "");
}
}
-func TestBadCompile(t *testing.T) {
+func TestBadCompile(t *T) {
for i := 0; i < len(bad_re); i++ {
compileTest(t, bad_re[i].re, bad_re[i].err)
}
}
-func TestExecute(t *testing.T) {
+func TestExecute(t *T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
executeTest(t, test.re, test.text, test.match)
}
}
-func matchTest(t *testing.T, expr string, str string, match []int) {
+func matchTest(t *T, expr string, str string, match []int) {
re := compileTest(t, expr, "");
if re == nil {
return
}
}
-func TestMatch(t *testing.T) {
+func TestMatch(t *T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchTest(t, test.re, test.text, test.match)
}
}
-func matchStringsTest(t *testing.T, expr string, str string, match []int) {
+func matchStringsTest(t *T, expr string, str string, match []int) {
re := compileTest(t, expr, "");
if re == nil {
return
}
}
-func TestMatchStrings(t *testing.T) {
+func TestMatchStrings(t *T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchTest(t, test.re, test.text, test.match)
}
}
-func matchFunctionTest(t *testing.T, expr string, str string, match []int) {
+func matchFunctionTest(t *T, expr string, str string, match []int) {
m, err := MatchString(expr, str);
if err == "" {
return
}
}
-func TestMatchFunction(t *testing.T) {
+func TestMatchFunction(t *T) {
for i := 0; i < len(matches); i++ {
test := &matches[i];
matchFunctionTest(t, test.re, test.text, test.match)