LEFT | RIGHT |
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 ( |
8 "testing" | 8 "testing" |
9 ) | 9 ) |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 {"/abc/def/../../..", "/"}, | 56 {"/abc/def/../../..", "/"}, |
57 {"abc/def/../../../ghi/jkl/../../../mno", "../../mno"}, | 57 {"abc/def/../../../ghi/jkl/../../../mno", "../../mno"}, |
58 | 58 |
59 // Combinations | 59 // Combinations |
60 {"abc/./../def", "def"}, | 60 {"abc/./../def", "def"}, |
61 {"abc//./../def", "def"}, | 61 {"abc//./../def", "def"}, |
62 {"abc/../../././../def", "../../def"}, | 62 {"abc/../../././../def", "../../def"}, |
63 } | 63 } |
64 | 64 |
65 func TestClean(t *testing.T) { | 65 func TestClean(t *testing.T) { |
66 const N = 100 | |
67 | |
68 for _, test := range cleantests { | 66 for _, test := range cleantests { |
69 if s := Clean(test.path); s != test.result { | 67 if s := Clean(test.path); s != test.result { |
70 t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.r
esult) | 68 t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.r
esult) |
71 } | 69 } |
72 if s := Clean(test.result); s != test.result { | 70 if s := Clean(test.result); s != test.result { |
73 t.Errorf("Clean(%q) = %q, want %q", test.result, s, test
.result) | 71 t.Errorf("Clean(%q) = %q, want %q", test.result, s, test
.result) |
74 } | 72 } |
75 } | 73 } |
76 | 74 |
77 for _, test := range cleantests { | 75 for _, test := range cleantests { |
78 » » allocs := testing.AllocsPerRun(N, func() { | 76 » » allocs := testing.AllocsPerRun(100, func() { Clean(test.result)
}) |
79 » » » Clean(test.result) | |
80 » » }) | |
81 if allocs > 0 { | 77 if allocs > 0 { |
82 t.Errorf("Clean(%q): %v allocs, want zero", test.result,
allocs) | 78 t.Errorf("Clean(%q): %v allocs, want zero", test.result,
allocs) |
83 } | 79 } |
84 } | 80 } |
85 } | 81 } |
86 | 82 |
87 type SplitTest struct { | 83 type SplitTest struct { |
88 path, dir, file string | 84 path, dir, file string |
89 } | 85 } |
90 | 86 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 {"lala", false}, | 221 {"lala", false}, |
226 } | 222 } |
227 | 223 |
228 func TestIsAbs(t *testing.T) { | 224 func TestIsAbs(t *testing.T) { |
229 for _, test := range isAbsTests { | 225 for _, test := range isAbsTests { |
230 if r := IsAbs(test.path); r != test.isAbs { | 226 if r := IsAbs(test.path); r != test.isAbs { |
231 t.Errorf("IsAbs(%q) = %v, want %v", test.path, r, test.i
sAbs) | 227 t.Errorf("IsAbs(%q) = %v, want %v", test.path, r, test.i
sAbs) |
232 } | 228 } |
233 } | 229 } |
234 } | 230 } |
LEFT | RIGHT |