Source file
src/cmd/cover/pkgname_test.go
1
2
3
4
5 package main
6
7 import "testing"
8
9 func TestPackageName(t *testing.T) {
10 var tests = []struct {
11 fileName, pkgName string
12 }{
13 {"", ""},
14 {"///", ""},
15 {"fmt", ""},
16 {"fmt/foo.go", "fmt"},
17 {"encoding/binary/foo.go", "binary"},
18 {"encoding/binary/////foo.go", "binary"},
19 }
20 var tf templateFile
21 for _, test := range tests {
22 tf.Name = test.fileName
23 td := templateData{
24 Files: []*templateFile{&tf},
25 }
26 got := td.PackageName()
27 if got != test.pkgName {
28 t.Errorf("%s: got %s want %s", test.fileName, got, test.pkgName)
29 }
30 }
31 }
32
View as plain text