]> Cypherpunks.ru repositories - gostls13.git/blob - src/internal/godebugs/godebugs_test.go
cmd/go: add check for unknown godebug setting
[gostls13.git] / src / internal / godebugs / godebugs_test.go
1 // Copyright 2023 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 package godebugs_test
6
7 import (
8         "internal/godebugs"
9         "os"
10         "strings"
11         "testing"
12 )
13
14 func TestAll(t *testing.T) {
15         data, err := os.ReadFile("../../../doc/godebug.md")
16         if err != nil {
17                 t.Fatal(err)
18         }
19         doc := string(data)
20
21         last := ""
22         for _, info := range godebugs.All {
23                 if info.Name <= last {
24                         t.Errorf("All not sorted: %s then %s", last, info.Name)
25                 }
26                 last = info.Name
27
28                 if info.Package == "" {
29                         t.Errorf("Name=%s missing Package", info.Name)
30                 }
31                 if info.Changed != 0 && info.Old == "" {
32                         t.Errorf("Name=%s has Changed, missing Old", info.Name)
33                 }
34                 if info.Old != "" && info.Changed == 0 {
35                         t.Errorf("Name=%s has Old, missing Changed", info.Name)
36                 }
37                 if !strings.Contains(doc, "`"+info.Name+"`") {
38                         t.Errorf("Name=%s not documented in doc/godebug.md", info.Name)
39                 }
40         }
41 }