github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/tools/go/buildutil/allpackages_test.go (about)

     1  // Copyright 2014 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  
     5  // Incomplete source tree on Android.
     6  
     7  // +build !android
     8  
     9  package buildutil_test
    10  
    11  import (
    12  	"go/build"
    13  	"testing"
    14  
    15  	"golang.org/x/tools/go/buildutil"
    16  )
    17  
    18  func TestAllPackages(t *testing.T) {
    19  	all := buildutil.AllPackages(&build.Default)
    20  
    21  	set := make(map[string]bool)
    22  	for _, pkg := range all {
    23  		set[pkg] = true
    24  	}
    25  
    26  	const wantAtLeast = 250
    27  	if len(all) < wantAtLeast {
    28  		t.Errorf("Found only %d packages, want at least %d", len(all), wantAtLeast)
    29  	}
    30  
    31  	for _, want := range []string{"fmt", "crypto/sha256", "golang.org/x/tools/go/buildutil"} {
    32  		if !set[want] {
    33  			t.Errorf("Package %q not found; got %s", want, all)
    34  		}
    35  	}
    36  }