(b *testing.B)
| 10 | var lintResult *lint.Result |
| 11 | |
| 12 | func BenchmarkParseAndLint(b *testing.B) { |
| 13 | linter, err := config.NewLinter(config.NewDefault()) |
| 14 | if err != nil { |
| 15 | b.Fatal(err) |
| 16 | } |
| 17 | for _, tt := range []struct { |
| 18 | name, input string |
| 19 | invalid bool |
| 20 | }{ |
| 21 | {"header", "feat: expose records", false}, |
| 22 | {"body", "feat: expose records\n\nRetain records.", false}, |
| 23 | {"footers", "feat: expose records\n\nRetain records.\n\nRefs #9", false}, |
| 24 | {"recovery", " unknown:reload\nBody text.", true}, |
| 25 | } { |
| 26 | b.Run(tt.name, func(b *testing.B) { |
| 27 | b.ReportAllocs() |
| 28 | for i := 0; i < b.N; i++ { |
| 29 | lintResult, err = linter.ParseAndLint(tt.input) |
| 30 | if err != nil { |
| 31 | b.Fatal(err) |
| 32 | } |
| 33 | } |
| 34 | if (len(lintResult.Issues()) > 0) != tt.invalid { |
| 35 | b.Fatal("incorrect lint result") |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected