Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201105173854-bc9fc8d8c4bc / godoc / godoc17_test.go
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.
4
5 // +build go1.7
6
7 package godoc
8
9 import (
10         "bytes"
11         "fmt"
12         "testing"
13 )
14
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.
18 //
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} {
24                 n := n
25                 t.Run(fmt.Sprint(n), func(t *testing.T) {
26                         var buf bytes.Buffer
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)
30                         }
31                         fmt.Fprintf(&buf, "}\n")
32                         linkifySource(t, buf.Bytes())
33                 })
34         }
35 }