Skip to content

Commit

Permalink
Add test for matching "std"
Browse files Browse the repository at this point in the history
  • Loading branch information
kisielk committed Jul 10, 2016
1 parent 3597762 commit 94d5dba
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

package gotool

import "testing"
import (
"sort"
"testing"
)

// This file contains code from the Go distribution.

Expand Down Expand Up @@ -112,3 +115,20 @@ func testStringPairs(t *testing.T, name string, tests []stringPairTest, f func(s
}
}
}

// containsString reports whether strings contains x. strings is assumed to be sorted.
func containsString(strings []string, x string) bool {
return strings[sort.SearchStrings(strings, x)] == x
}

func TestMatchStdPackages(t *testing.T) {
packages := DefaultContext.matchPackages("std")
sort.Strings(packages)
// some common packages all Go versions should have
commonPackages := []string{"bufio", "bytes", "crypto", "fmt", "io", "os"}
for _, p := range commonPackages {
if !containsString(packages, p) {
t.Errorf("std package set doesn't contain expected package %s", p)
}
}
}

0 comments on commit 94d5dba

Please sign in to comment.