-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath_test.go
More file actions
46 lines (43 loc) · 864 Bytes
/
Copy pathpath_test.go
File metadata and controls
46 lines (43 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package grasp
import "testing"
func TestCleanPath(t *testing.T) {
tests := []struct {
in, want string
}{
{"", "/"},
{".", "/"},
{"/", "/"},
{"/foo", "/foo"},
{"/foo/", "/foo"},
{"/foo/bar", "/foo/bar"},
{"/foo//bar", "/foo/bar"},
{"/foo/../bar", "/bar"},
{"foo", "/foo"},
{"foo/bar", "/foo/bar"},
{`foo\bar`, "/foo/bar"},
{`\foo\bar\`, "/foo/bar"},
{"/foo/./bar", "/foo/bar"},
}
for _, tt := range tests {
got := CleanPath(tt.in)
if got != tt.want {
t.Errorf("CleanPath(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestBaseName(t *testing.T) {
tests := []struct {
in, want string
}{
{"/", "/"},
{"/foo", "foo"},
{"/foo/bar", "bar"},
{"/a/b/c", "c"},
}
for _, tt := range tests {
got := baseName(tt.in)
if got != tt.want {
t.Errorf("baseName(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}