gopkg.in/tools/godep.v21@v21.0.0-20151104013723-2cf1d6e3f557/match_test.go (about)

     1  package main
     2  
     3  import "testing"
     4  
     5  func TestMatchPattern(t *testing.T) {
     6  	// Test cases from $GOROOT/src/cmd/go/match_test.go.
     7  	cases := []struct {
     8  		pat  string
     9  		path string
    10  		want bool
    11  	}{
    12  		{"...", "foo", true},
    13  		{"net", "net", true},
    14  		{"net", "net/http", false},
    15  		{"net/http", "net", false},
    16  		{"net/http", "net/http", true},
    17  		{"net...", "netchan", true},
    18  		{"net...", "net", true},
    19  		{"net...", "net/http", true},
    20  		{"net...", "not/http", false},
    21  		{"net/...", "netchan", false},
    22  		{"net/...", "net", true},
    23  		{"net/...", "net/http", true},
    24  		{"net/...", "not/http", false},
    25  	}
    26  	for _, test := range cases {
    27  		ok := matchPattern(test.pat)(test.path)
    28  		if ok != test.want {
    29  			t.Errorf("matchPackages(%q)(%q) = %v want %v", test.pat, test.path, ok, test.want)
    30  		}
    31  	}
    32  }