forked from hirochachacha/go-smb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_test.go
49 lines (44 loc) · 789 Bytes
/
path_test.go
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
47
48
49
package smb2
import (
"testing"
)
var testBase = []struct {
Path string
Base string
}{
{"", ""},
{`\`, ""},
{`\foo`, "foo"},
{`\foo\bar`, "bar"},
{`foo\bar`, "bar"},
{`foo\bar\`, "bar"},
{`foo\bar\\`, "bar"},
{`foo`, "foo"},
}
func TestBase(t *testing.T) {
for _, c := range testBase {
if base(c.Path) != c.Base {
t.Errorf("path: %v, expected: %v, got: %v", c.Path, c.Base, base(c.Path))
}
}
}
var testDir = []struct {
Path string
Dir string
}{
{"", ""},
{`\`, `\`},
{`\foo`, `\`},
{`\foo\bar`, `\foo`},
{`foo\bar`, "foo"},
{`foo\bar\`, "foo"},
{`foo\bar\\`, "foo"},
{`foo`, ""},
}
func TestDir(t *testing.T) {
for _, c := range testDir {
if dir(c.Path) != c.Dir {
t.Errorf("path: %v, expected: %v, got: %v", c.Path, c.Dir, base(c.Path))
}
}
}