1 // Copyright 2015 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.
15 "golang.org/x/tools/go/buildutil"
18 func testContainingPackageCaseFold(file, want string) error {
19 bp, err := buildutil.ContainingPackage(&build.Default, ".", file)
23 if got := bp.ImportPath; got != want {
24 return fmt.Errorf("ContainingPackage(%q) = %s, want %s", file, got, want)
29 func TestContainingPackageCaseFold(t *testing.T) {
30 path := filepath.Join(runtime.GOROOT(), `src\fmt\print.go`)
31 err := testContainingPackageCaseFold(path, "fmt")
35 vol := filepath.VolumeName(path)
36 if len(vol) != 2 || vol[1] != ':' {
37 t.Fatalf("GOROOT path has unexpected volume name: %v", vol)
39 rest := path[len(vol):]
40 err = testContainingPackageCaseFold(strings.ToUpper(vol)+rest, "fmt")
44 err = testContainingPackageCaseFold(strings.ToLower(vol)+rest, "fmt")