-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc2py_test.go
96 lines (90 loc) · 2.04 KB
/
cc2py_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"testing"
)
type testCase struct {
got string
want string
}
func testPinyin(t *testing.T, d []testCase) {
for _, tc := range d {
if tc.got != tc.want {
t.Errorf(`Expected "%s", got "%s"`, tc.want, tc.got)
}
}
}
func TestConvert(t *testing.T) {
hans := "〖中国银行〗,很行。"
Separator := " "
testData := []testCase{
// 0: normal. mnemonic~ nothing
{
cc2py(hans, 0, 0, Separator, false, false),
"〖zhong guo yin xing 〗,hen xing 。",
},
{
cc2py(hans, 0, 1, Separator, false, false),
"〖z g y x 〗,h x 。",
},
{
cc2py(hans, 0, 2, Separator, false, false),
"〖zh g y x 〗,h x 。",
},
{
cc2py(hans, 0, 9, Separator, false, false),
"〖ong uo in ing 〗,en ing 。",
},
// 1: tone at the end. mnemonic~ single sided
{
cc2py(hans, 1, 0, Separator, false, false),
"〖zhong1 guo2 yin2 xing2 〗,hen3 xing2 。",
},
{
cc2py(hans, 1, 1, Separator, false, false),
"〖z g y x 〗,h x 。",
},
{
cc2py(hans, 1, 2, Separator, false, false),
"〖zh g y x 〗,h x 。",
},
{
cc2py(hans, 1, 9, Separator, false, false),
"〖ong1 uo2 in2 ing2 〗,en3 ing2 。",
},
// 2: tone after yunmu. mnemonic~ double sided
{
cc2py(hans, 2, 0, Separator, false, false),
"〖zho1ng guo2 yi2n xi2ng 〗,he3n xi2ng 。",
},
{
cc2py(hans, 2, 1, Separator, false, false),
"〖z g y x 〗,h x 。",
},
{
cc2py(hans, 2, 2, Separator, false, false),
"〖zh g y x 〗,h x 。",
},
{
cc2py(hans, 2, 9, Separator, false, false),
"〖o1ng uo2 i2n i2ng 〗,e3n i2ng 。",
},
// 3: tone on yunmu. mnemonic~ fancy
{
cc2py(hans, 0, 0, Separator, false, false),
"〖zhong guo yin xing 〗,hen xing 。",
},
{
cc2py(hans, 0, 1, Separator, false, false),
"〖z g y x 〗,h x 。",
},
{
cc2py(hans, 0, 2, Separator, false, false),
"〖zh g y x 〗,h x 。",
},
{
cc2py(hans, 0, 9, Separator, false, false),
"〖ong uo in ing 〗,en ing 。",
},
}
testPinyin(t, testData)
}