GoPLS Viewer

Home|gopls/go/buildutil/util_windows_test.go
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.
4
5package buildutil_test
6
7import (
8    "fmt"
9    "go/build"
10    "path/filepath"
11    "runtime"
12    "strings"
13    "testing"
14
15    "golang.org/x/tools/go/buildutil"
16)
17
18func testContainingPackageCaseFold(filewant stringerror {
19    bperr := buildutil.ContainingPackage(&build.Default"."file)
20    if err != nil {
21        return err
22    }
23    if got := bp.ImportPathgot != want {
24        return fmt.Errorf("ContainingPackage(%q) = %s, want %s"filegotwant)
25    }
26    return nil
27}
28
29func TestContainingPackageCaseFold(t *testing.T) {
30    path := filepath.Join(runtime.GOROOT(), `src\fmt\print.go`)
31    err := testContainingPackageCaseFold(path"fmt")
32    if err != nil {
33        t.Error(err)
34    }
35    vol := filepath.VolumeName(path)
36    if len(vol) != 2 || vol[1] != ':' {
37        t.Fatalf("GOROOT path has unexpected volume name: %v"vol)
38    }
39    rest := path[len(vol):]
40    err = testContainingPackageCaseFold(strings.ToUpper(vol)+rest"fmt")
41    if err != nil {
42        t.Error(err)
43    }
44    err = testContainingPackageCaseFold(strings.ToLower(vol)+rest"fmt")
45    if err != nil {
46        t.Error(err)
47    }
48}
49
MembersX
testContainingPackageCaseFold.file
testContainingPackageCaseFold.want
TestContainingPackageCaseFold
TestContainingPackageCaseFold.t
TestContainingPackageCaseFold.path
TestContainingPackageCaseFold.err
testContainingPackageCaseFold
testContainingPackageCaseFold.bp
testContainingPackageCaseFold.err
testContainingPackageCaseFold.got
TestContainingPackageCaseFold.vol
Members
X