-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution_test.go
56 lines (49 loc) · 867 Bytes
/
solution_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
50
51
52
53
54
55
56
package lc0071
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_simplifyPath(t *testing.T) {
t.Parallel()
type args struct {
path string
}
tests := []struct {
name string
args args
want string
}{
{
args: args{path: "/home/"},
want: "/home",
},
{
args: args{path: "/../"},
want: "/",
},
{
args: args{path: "/home//foo/"},
want: "/home/foo",
},
{
args: args{path: "/a/./b/../../c/"},
want: "/c",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, simplifyPath(tt.args.path))
})
}
}
func Test_splitter_next(t *testing.T) {
t.Parallel()
t.Run(``, func(t *testing.T) {
s := newSplitter("/path/../to//dir/")
for i := 0; i < 10; i++ {
text, found := s.next()
fmt.Printf("text = [%s]; found = %v\n", text, found)
}
})
}