Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Side by Side Diff: src/pkg/path/filepath/match_test.go

Issue 5294074: code review 5294074: src/pkg/[n-z]*: gofix -r error (Closed)
Patch Set: diff -r b78bb4f2d2a3 https://go.googlecode.com/hg/ Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/path/filepath/match.go ('k') | src/pkg/path/filepath/path.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 filepath_test 5 package filepath_test
6 6
7 import ( 7 import (
8 "os"
9 . "path/filepath" 8 . "path/filepath"
10 "testing" 9 "testing"
11 "runtime" 10 "runtime"
12 ) 11 )
13 12
14 type MatchTest struct { 13 type MatchTest struct {
15 pattern, s string 14 pattern, s string
16 match bool 15 match bool
17 » err os.Error 16 » err error
18 } 17 }
19 18
20 var matchTests = []MatchTest{ 19 var matchTests = []MatchTest{
21 {"abc", "abc", true, nil}, 20 {"abc", "abc", true, nil},
22 {"*", "abc", true, nil}, 21 {"*", "abc", true, nil},
23 {"*c", "abc", true, nil}, 22 {"*c", "abc", true, nil},
24 {"a*", "a", true, nil}, 23 {"a*", "a", true, nil},
25 {"a*", "abc", true, nil}, 24 {"a*", "abc", true, nil},
26 {"a*", "ab/c", false, nil}, 25 {"a*", "ab/c", false, nil},
27 {"a*/b", "abc/b", true, nil}, 26 {"a*/b", "abc/b", true, nil},
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 {"[x-]", "-", false, ErrBadPattern}, 61 {"[x-]", "-", false, ErrBadPattern},
63 {"[x-]", "z", false, ErrBadPattern}, 62 {"[x-]", "z", false, ErrBadPattern},
64 {"[-x]", "x", false, ErrBadPattern}, 63 {"[-x]", "x", false, ErrBadPattern},
65 {"[-x]", "-", false, ErrBadPattern}, 64 {"[-x]", "-", false, ErrBadPattern},
66 {"[-x]", "a", false, ErrBadPattern}, 65 {"[-x]", "a", false, ErrBadPattern},
67 {"\\", "a", false, ErrBadPattern}, 66 {"\\", "a", false, ErrBadPattern},
68 {"[a-b-c]", "a", false, ErrBadPattern}, 67 {"[a-b-c]", "a", false, ErrBadPattern},
69 {"*x", "xxx", true, nil}, 68 {"*x", "xxx", true, nil},
70 } 69 }
71 70
72 func errp(e os.Error) string { 71 func errp(e error) string {
73 if e == nil { 72 if e == nil {
74 return "<nil>" 73 return "<nil>"
75 } 74 }
76 » return e.String() 75 » return e.Error()
77 } 76 }
78 77
79 func TestMatch(t *testing.T) { 78 func TestMatch(t *testing.T) {
80 if runtime.GOOS == "windows" { 79 if runtime.GOOS == "windows" {
81 // XXX: Don't pass for windows. 80 // XXX: Don't pass for windows.
82 return 81 return
83 } 82 }
84 for _, tt := range matchTests { 83 for _, tt := range matchTests {
85 ok, err := Match(tt.pattern, tt.s) 84 ok, err := Match(tt.pattern, tt.s)
86 if ok != tt.match || err != tt.err { 85 if ok != tt.match || err != tt.err {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 134 }
136 } 135 }
137 } 136 }
138 137
139 func TestGlobError(t *testing.T) { 138 func TestGlobError(t *testing.T) {
140 _, err := Glob("[7]") 139 _, err := Glob("[7]")
141 if err != nil { 140 if err != nil {
142 t.Error("expected error for bad pattern; got none") 141 t.Error("expected error for bad pattern; got none")
143 } 142 }
144 } 143 }
OLDNEW
« no previous file with comments | « src/pkg/path/filepath/match.go ('k') | src/pkg/path/filepath/path.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b