secure/precis: Use internal/testtext runner Change-Id: I73658f436dda909986b6a847c54945ec91a39744 Reviewed-on: https://go-review.googlesource.com/30253 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/precis/benchmark_test.go b/secure/precis/benchmark_test.go index 83bae4b..6337d00 100644 --- a/secure/precis/benchmark_test.go +++ b/secure/precis/benchmark_test.go
@@ -6,7 +6,11 @@ package precis -import "testing" +import ( + "testing" + + "golang.org/x/text/internal/testtext" +) var benchData = []struct{ name, str string }{ {"ASCII", "Malvolio"}, @@ -29,7 +33,7 @@ func doBench(b *testing.B, f func(b *testing.B, p *Profile, s string)) { for _, bp := range benchProfiles { for _, d := range benchData { - b.Run(bp.name+"/"+d.name, func(b *testing.B) { + testtext.Bench(b, bp.name+"/"+d.name, func(b *testing.B) { f(b, bp.p, d.str) }) }
diff --git a/secure/precis/enforce_test.go b/secure/precis/enforce_test.go index f60f4e3..15d7876 100644 --- a/secure/precis/enforce_test.go +++ b/secure/precis/enforce_test.go
@@ -5,9 +5,11 @@ package precis import ( + "fmt" "reflect" "testing" + "golang.org/x/text/internal/testtext" "golang.org/x/text/secure/bidirule" ) @@ -17,7 +19,7 @@ err error } -var testCases = []struct { +var enforceTestCases = []struct { name string p *Profile cases []testCase @@ -248,6 +250,17 @@ }}, } +func doTests(t *testing.T, fn func(t *testing.T, p *Profile, tc testCase)) { + for _, g := range enforceTestCases { + for i, tc := range g.cases { + name := fmt.Sprintf("%s:%d:%+q", g.name, i, tc.input) + testtext.Run(t, name, func(t *testing.T) { + fn(t, g.p, tc) + }) + } + } +} + func TestString(t *testing.T) { doTests(t, func(t *testing.T, p *Profile, tc testCase) { if e, err := p.String(tc.input); tc.err != err || e != tc.output {
diff --git a/secure/precis/go1_6_test.go b/secure/precis/go1_6_test.go deleted file mode 100644 index 663617d..0000000 --- a/secure/precis/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 precis - -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, p *Profile, tc testCase)) { - for _, g := range testCases { - for i, tc := range g.cases { - name := fmt.Sprintf("%s:%d:%+q", g.name, i, tc.input) - t.Log("Testing ", name) - fn(t, g.p, tc) - } - } -}
diff --git a/secure/precis/go1_7_test.go b/secure/precis/go1_7_test.go deleted file mode 100644 index 05779f3..0000000 --- a/secure/precis/go1_7_test.go +++ /dev/null
@@ -1,23 +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 precis - -import ( - "fmt" - "testing" -) - -func doTests(t *testing.T, fn func(t *testing.T, p *Profile, tc testCase)) { - for _, g := range testCases { - for i, tc := range g.cases { - name := fmt.Sprintf("%s:%d:%+q", g.name, i, tc.input) - t.Run(name, func(t *testing.T) { - fn(t, g.p, tc) - }) - } - } -}