forked from rainycape/unidecode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unidecode_test.go
57 lines (48 loc) · 976 Bytes
/
unidecode_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
package unidecode
import (
"testing"
)
func testTransliteration(original string, decoded string, t *testing.T) {
if r := Unidecode(original); r != decoded {
t.Errorf("Expected '%s', got '%s'\n", decoded, r)
}
}
func TestASCII(t *testing.T) {
s := "ABCDEF"
testTransliteration(s, s, t)
}
func TestKnosos(t *testing.T) {
o := "Κνωσός"
d := "Knosos"
testTransliteration(o, d, t)
}
func TestBeiJing(t *testing.T) {
o := "\u5317\u4EB0"
d := "Bei Jing "
testTransliteration(o, d, t)
}
func TestEmoji(t *testing.T) {
o := "Hey Luna t belle 😵😂"
d := "Hey Luna t belle "
testTransliteration(o, d, t)
}
func BenchmarkUnidecode(b *testing.B) {
cases := []string{
"ABCDEF",
"Κνωσός",
"\u5317\u4EB0",
}
for ii := 0; ii < b.N; ii++ {
for _, v := range cases {
_ = Unidecode(v)
}
}
}
func BenchmarkDecodeTable(b *testing.B) {
for ii := 0; ii < b.N; ii++ {
decodeTransliterations()
}
}
func init() {
decodeTransliterations()
}