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.
16 // Verify that scanIdentifier isn't quadratic.
17 // This doesn't actually measure and fail on its own, but it was previously
18 // very obvious when running by hand.
20 // TODO: if there's a reliable and non-flaky way to test this, do so.
21 // Maybe count user CPU time instead of wall time? But that's not easy
22 // to do portably in Go.
23 func TestStructField(t *testing.T) {
24 for _, n := range []int{10, 100, 1000, 10000} {
26 t.Run(fmt.Sprint(n), func(t *testing.T) {
28 fmt.Fprintf(&buf, "package foo\n\ntype T struct {\n")
29 for i := 0; i < n; i++ {
30 fmt.Fprintf(&buf, "\t// Field%d is foo.\n\tField%d int\n\n", i, i)
32 fmt.Fprintf(&buf, "}\n")
33 linkifySource(t, buf.Bytes())