-
Notifications
You must be signed in to change notification settings - Fork 13
/
package_test.go
40 lines (34 loc) · 994 Bytes
/
package_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
package main
import (
"testing"
)
func TestPackageChecks(t *testing.T) {
var pkg, subpkg string
checkResult := func(pkg, subpkg string, want bool) {
got := IsInternal(pkg, subpkg)
if got != want {
t.Fatalf("Expecting IsInternal to return %v in this case: (%s, %s)", want, pkg, subpkg)
}
}
pkg, subpkg = "github.com/divan/depscheck", "github.com/divan/depscheck/foo"
checkResult(pkg, subpkg, true)
pkg, subpkg = "github.com/divan/depscheck/bar", "github.com/divan/depscheck/foo"
checkResult(pkg, subpkg, true)
pkg, subpkg = "github.com/divan/package1", "github.com/divan/package2"
checkResult(pkg, subpkg, false)
}
func BenchmarkIsStdlibTrue(b *testing.B) {
for i := 0; i < b.N; i++ {
IsStdlib("fmt")
}
}
func BenchmarkIsStdlibFalse(b *testing.B) {
for i := 0; i < b.N; i++ {
IsStdlib("github.com/divan/package")
}
}
func BenchmarkIsInternal(b *testing.B) {
for i := 0; i < b.N; i++ {
IsInternal("github.com/divan/package1", "github.com/divan/package2")
}
}