secure/bidirule: Use testtext testing harness Change-Id: I8e9fec1fc51d38a1950f95be63e07fb80d9949e6 Reviewed-on: https://go-review.googlesource.com/30712 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/secure/bidirule/go1_7_test.go b/secure/bidirule/bench_test.go similarity index 75% rename from secure/bidirule/go1_7_test.go rename to secure/bidirule/bench_test.go index ae5a169..2db922b 100644 --- a/secure/bidirule/go1_7_test.go +++ b/secure/bidirule/bench_test.go
@@ -2,25 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.7 - package bidirule import ( - "fmt" "testing" -) -func doTests(t *testing.T, fn func(t *testing.T, tc ruleTest)) { - for rule, cases := range testCases { - for i, tc := range cases { - name := fmt.Sprintf("%d/%d:%+q:%s", rule, i, tc.in, tc.in) - t.Run(name, func(t *testing.T) { - fn(t, tc) - }) - } - } -} + "golang.org/x/text/internal/testtext" +) var benchData = []struct{ name, data string }{ {"ascii", "Scheveningen"}, @@ -30,7 +18,7 @@ func doBench(b *testing.B, fn func(b *testing.B, data string)) { for _, d := range benchData { - b.Run(d.name, func(b *testing.B) { fn(b, d.data) }) + testtext.Bench(b, d.name, func(b *testing.B) { fn(b, d.data) }) } }
diff --git a/secure/bidirule/bidirule_test.go b/secure/bidirule/bidirule_test.go index df866e6..f3cc251 100644 --- a/secure/bidirule/bidirule_test.go +++ b/secure/bidirule/bidirule_test.go
@@ -5,8 +5,10 @@ package bidirule import ( + "fmt" "testing" + "golang.org/x/text/internal/testtext" "golang.org/x/text/transform" "golang.org/x/text/unicode/bidi" ) @@ -602,6 +604,17 @@ } } +func doTests(t *testing.T, fn func(t *testing.T, tc ruleTest)) { + for rule, cases := range testCases { + for i, tc := range cases { + name := fmt.Sprintf("%d/%d:%+q:%s", rule, i, tc.in, tc.in) + testtext.Run(t, name, func(t *testing.T) { + fn(t, tc) + }) + } + } +} + func TestDirection(t *testing.T) { doTests(t, func(t *testing.T, tc ruleTest) { dir, err := Direction([]byte(tc.in))
diff --git a/secure/bidirule/go1_6_test.go b/secure/bidirule/go1_6_test.go deleted file mode 100644 index a7799cd..0000000 --- a/secure/bidirule/go1_6_test.go +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.7 - -package bidirule - -import ( - "fmt" - "testing" -) - -// doTests runs all tests without using t.Run. As a result, context may be -// missing, but at least all tests are run. -func doTests(t *testing.T, fn func(t *testing.T, tc ruleTest)) { - for rule, cases := range testCases { - for i, tc := range cases { - name := fmt.Sprintf("%d/%d:%+q:%s", rule, i, tc.in, tc.in) - t.Log("Testing ", name) - fn(t, tc) - } - } -}