1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
15 // Verify that scanIdentifier isn't quadratic.
16 // This doesn't actually measure and fail on its own, but it was previously
17 // very obvious when running by hand.
19 // TODO: if there's a reliable and non-flaky way to test this, do so.
20 // Maybe count user CPU time instead of wall time? But that's not easy
21 // to do portably in Go.
22 func TestStructField(t *testing.T) {
23 for _, n := range []int{10, 100, 1000, 10000} {
25 t.Run(fmt.Sprint(n), func(t *testing.T) {
27 fmt.Fprintf(&buf, "package foo\n\ntype T struct {\n")
28 for i := 0; i < n; i++ {
29 fmt.Fprintf(&buf, "\t// Field%d is foo.\n\tField%d int\n\n", i, i)
31 fmt.Fprintf(&buf, "}\n")
32 linkifySource(t, buf.Bytes())