-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools_test.go
75 lines (69 loc) · 1.28 KB
/
tools_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
69
70
71
72
73
74
75
package slug
import (
"testing"
"github.com/goloop/t13n/lang"
)
// TestSlugRules tests slugRules function.
func TestSlugRules(t *testing.T) {
tests := []struct {
item lang.TransState
value string
seek int
ok bool
}{
{
item: lang.TransState{Curr: ' ', Value: " "},
value: "-",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: '@', Value: "@"},
value: "at",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: '#', Value: "#"},
value: "sharp",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: '%', Value: "%"},
value: "pct",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: 'i', Value: "i"},
value: "i",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: '世', Value: "shi"},
value: "shi",
seek: 0,
ok: true,
},
{
item: lang.TransState{Curr: '㹏', Next: '㹐', Value: "jin "},
value: "jin-",
seek: 0,
ok: true,
},
}
for _, test := range tests {
value, seek, ok := slugRules(test.item)
if value != test.value {
t.Errorf("expected %s but %s", test.value, value)
}
if seek != test.seek {
t.Errorf("expected %d but %d", test.seek, seek)
}
if ok != test.ok {
t.Errorf("expected %t but %t", test.ok, ok)
}
}
}