-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcac_test.go
68 lines (63 loc) · 1.05 KB
/
cac_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
57
58
59
60
61
62
63
64
65
66
67
68
package cac
import (
"strings"
"testing"
)
func TestParse(t *testing.T) {
tt := []struct {
name string
content string
pass func(list []string) bool
}{
{
name: "Just space",
content: "command1 command2 command3",
pass: func(list []string) bool {
return len(list) == 3
},
},
{
name: "Just line",
content: `
Monday
Tuesday
Thursday
Fri\
day`,
pass: func(list []string) bool {
return len(list) == 4
},
},
{
name: "With command",
content: `
frog
# Frog also called "the chicken in the filed" in Chinese
# beacuse it taste like chicken.
chicken`,
pass: func(list []string) bool {
return len(list) == 2
},
},
{
name: "Mix",
content: `
# some command
fun today
rig\
ht
lsll`,
pass: func(list []string) bool {
return len(list) == 4
},
},
}
for _, test := range tt {
result := Parse(test.content)
if !test.pass(result) {
t.Errorf("Failed to parse %s, got: %v", test.name, strings.Join(result, " "))
continue
}
t.Logf("%s passed", test.name)
}
}