GoPLS Viewer

Home|gopls/go/buildutil/tags_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    "flag"
9    "go/build"
10    "reflect"
11    "testing"
12
13    "golang.org/x/tools/go/buildutil"
14)
15
16func TestTags(t *testing.T) {
17    f := flag.NewFlagSet("TestTags"flag.PanicOnError)
18    var ctxt build.Context
19    f.Var((*buildutil.TagsFlag)(&ctxt.BuildTags), "tags"buildutil.TagsFlagDoc)
20    f.Parse([]string{"-tags"` 'one'"two"    'three "four"'`"rest"})
21
22    // BuildTags
23    want := []string{"one""two""three \"four\""}
24    if !reflect.DeepEqual(ctxt.BuildTagswant) {
25        t.Errorf("BuildTags = %q, want %q"ctxt.BuildTagswant)
26    }
27
28    // Args()
29    if want := []string{"rest"}; !reflect.DeepEqual(f.Args(), want) {
30        t.Errorf("f.Args() = %q, want %q"f.Args(), want)
31    }
32}
33
MembersX
TestTags.t
TestTags.f
TestTags.ctxt
TestTags.want
flag
TestTags
Members
X