github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/go/match_test.go (about) 1 // Copyright 2012 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 package main 6 7 import "testing" 8 9 var matchTests = []struct { 10 pattern string 11 path string 12 match bool 13 }{ 14 {"...", "foo", true}, 15 {"net", "net", true}, 16 {"net", "net/http", false}, 17 {"net/http", "net", false}, 18 {"net/http", "net/http", true}, 19 {"net...", "netchan", true}, 20 {"net...", "net", true}, 21 {"net...", "net/http", true}, 22 {"net...", "not/http", false}, 23 {"net/...", "netchan", false}, 24 {"net/...", "net", true}, 25 {"net/...", "net/http", true}, 26 {"net/...", "not/http", false}, 27 } 28 29 func TestMatchPattern(t *testing.T) { 30 for _, tt := range matchTests { 31 match := matchPattern(tt.pattern)(tt.path) 32 if match != tt.match { 33 t.Errorf("matchPattern(%q)(%q) = %v, want %v", tt.pattern, tt.path, match, tt.match) 34 } 35 } 36 }