LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package path | 5 package path |
6 | 6 |
7 import ( | 7 import "testing" |
8 » "os" | |
9 » "testing" | |
10 ) | |
11 | 8 |
12 type MatchTest struct { | 9 type MatchTest struct { |
13 pattern, s string | 10 pattern, s string |
14 match bool | 11 match bool |
15 » err os.Error | 12 » err error |
16 } | 13 } |
17 | 14 |
18 var matchTests = []MatchTest{ | 15 var matchTests = []MatchTest{ |
19 {"abc", "abc", true, nil}, | 16 {"abc", "abc", true, nil}, |
20 {"*", "abc", true, nil}, | 17 {"*", "abc", true, nil}, |
21 {"*c", "abc", true, nil}, | 18 {"*c", "abc", true, nil}, |
22 {"a*", "a", true, nil}, | 19 {"a*", "a", true, nil}, |
23 {"a*", "abc", true, nil}, | 20 {"a*", "abc", true, nil}, |
24 {"a*", "ab/c", false, nil}, | 21 {"a*", "ab/c", false, nil}, |
25 {"a*/b", "abc/b", true, nil}, | 22 {"a*/b", "abc/b", true, nil}, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 65 } |
69 | 66 |
70 func TestMatch(t *testing.T) { | 67 func TestMatch(t *testing.T) { |
71 for _, tt := range matchTests { | 68 for _, tt := range matchTests { |
72 ok, err := Match(tt.pattern, tt.s) | 69 ok, err := Match(tt.pattern, tt.s) |
73 if ok != tt.match || err != tt.err { | 70 if ok != tt.match || err != tt.err { |
74 t.Errorf("Match(%#q, %#q) = %v, %v want %v, nil", tt.pat
tern, tt.s, ok, err, tt.match) | 71 t.Errorf("Match(%#q, %#q) = %v, %v want %v, nil", tt.pat
tern, tt.s, ok, err, tt.match) |
75 } | 72 } |
76 } | 73 } |
77 } | 74 } |
LEFT | RIGHT |