-
Notifications
You must be signed in to change notification settings - Fork 0
/
shape_test.go
78 lines (70 loc) · 1.6 KB
/
shape_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
76
77
78
package gopersian
import (
"testing"
)
func TestShape(t *testing.T) {
cases := []struct {
tag string
in string
want string
}{
{"t1", "", ""},
{"t2", "سلام مهران", "\ufeb3\ufee0\ufe8e\ufee1 \ufee3\ufeec\ufeae\u0627\ufee5"},
{"t3", "سلام مهران abc", "\ufeb3\ufee0\ufe8e\ufee1 \ufee3\ufeec\ufeae\u0627\ufee5 abc"},
}
for _, c := range cases {
t.Run(c.tag, func(t *testing.T) {
got := Shape(c.in)
//for _, r := range got {
// fmt.Printf("%+q", r)
//}
if got != c.want {
t.Errorf("invalid shape result, wanted: %s, got: %s", c.want, got)
}
})
}
}
func TestReorder(t *testing.T) {
tests := []struct {
Tag string
in, want string
}{
{"t1", "Hello, world", "Hello, world"},
{"t1", "خوبی", "یبوخ"},
{"t6", "خوبی؟ drink water 1234 چ خبر؟", "؟ربخ چ drink water 1234 ؟یبوخ"},
{"t10", "", ""},
}
for _, c := range tests {
t.Run(c.Tag, func(t *testing.T) {
got, err := Reorder(c.in)
if err != nil {
t.Error("got error", err)
return
}
if got != c.want {
t.Errorf("invalid reverse result, input; %s, wanted:%s, got: %s", c.in, c.want, got)
}
})
}
}
func TestBidi(t *testing.T) {
tests := []struct {
Tag string
in string
want string
}{
{"t1", "سلام مهران", "\ufee5\u0627\ufeae\ufeec\ufee3 \ufee1\ufe8e\ufee0\ufeb3"},
{"t2", "", ""},
}
for _, c := range tests {
t.Run(c.Tag, func(t *testing.T) {
got, err := Bidi(c.in)
if err != nil {
t.Error("got error", err)
}
if got != c.want {
t.Errorf("invalid result, wanted: %s, got: %s", c.want, got)
}
})
}
}