-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory_test.go
55 lines (51 loc) · 968 Bytes
/
history_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package mingo
import (
"fmt"
"testing"
)
func TestHistory(t *testing.T) {
h, err := readHist("")
if err != nil {
t.Fatal(err)
}
cases := []struct {
pkgpath, ident, typ string
want int
}{{
pkgpath: "os",
ident: "CreateTemp",
want: 16,
}, {
pkgpath: "errors",
ident: "Join",
want: 20,
}, {
pkgpath: "testing",
typ: "Cover",
ident: "Blocks",
want: 2,
}, {
pkgpath: "crypto/elliptic",
ident: "Curve",
want: 0,
}, {
// https://github.com/bobg/mingo/issues/14
pkgpath: "io",
ident: "NopCloser",
want: 16,
}}
for _, tc := range cases {
var name string
if tc.typ == "" {
name = fmt.Sprintf("%s.%s", tc.pkgpath, tc.ident)
} else {
name = fmt.Sprintf("%s.%s.%s", tc.pkgpath, tc.typ, tc.ident)
}
t.Run(name, func(t *testing.T) {
got := h.lookup(tc.pkgpath, tc.ident, tc.typ)
if got != tc.want {
t.Errorf("got %d, want %d", got, tc.want)
}
})
}
}