-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_compat_test.go
More file actions
194 lines (191 loc) · 5.62 KB
/
convert_compat_test.go
File metadata and controls
194 lines (191 loc) · 5.62 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package kana_test
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/wantedly/kana-go"
)
func TestCompatConvert(t *testing.T) {
var testcases = []struct {
name string
input string
options kana.ConvertOptions
expect string
}{
{
name: "With FullwidthToNarrow, Without CompatQuotes",
input: "´‘’“”"'",
options: kana.FullwidthToNarrow,
expect: "´‘’“”\"'",
},
{
name: "With FullwidthToNarrow, With CompatQuotes",
input: "´‘’“”"'",
options: kana.FullwidthToNarrow | kana.CompatQuotes,
expect: "'`'\"\""'",
},
{
name: "Without CompatMinus",
input: "—―−-",
options: 0,
expect: "—―−-",
},
{
name: "With CompatMinus",
input: "—―−-",
options: kana.CompatMinus,
expect: "——−−",
},
{
name: "With FullwidthToNarrow, Without CompatMinus",
input: "—―−-",
options: kana.FullwidthToNarrow,
expect: "—―−-",
},
{
name: "With FullwidthToNarrow, With CompatMinus",
input: "—―−-",
options: kana.FullwidthToNarrow | kana.CompatMinus,
expect: "----",
},
{
name: "Without CompatOverline",
input: " ̄~",
options: 0,
expect: " ̄~",
},
{
name: "With CompatOverline",
input: " ̄~",
options: kana.CompatOverline,
expect: "‾~",
},
{
name: "With FullwidthToNarrow, Without CompatOverline",
input: " ̄~",
options: kana.FullwidthToNarrow,
expect: "¯~",
},
{
name: "With FullwidthToNarrow, With CompatOverline",
input: " ̄~",
options: kana.FullwidthToNarrow | kana.CompatOverline,
expect: "‾~",
},
{
name: "Without CompatCurrency",
input: "¢£¥₩",
options: 0,
expect: "¢£¥₩",
},
{
name: "With CompatCurrency",
input: "¢£¥₩",
options: kana.CompatCurrency,
expect: "¢£¥₩",
},
{
name: "Without CompatOtherSymbols",
input: "∥¬¦",
options: 0,
expect: "∥¬¦",
},
{
name: "With CompatOtherSymbols",
input: "∥¬¦",
options: kana.CompatOtherSymbols,
expect: "‖¬¦",
},
{
name: "With FullwidthToNarrow, Without CompatCurrency",
input: "¢£¥₩",
options: kana.FullwidthToNarrow,
expect: "¢£¥₩",
},
{
name: "With FullwidthToNarrow, With CompatCurrency",
input: "¢£¥₩",
options: kana.FullwidthToNarrow | kana.CompatCurrency,
expect: "¢£¥₩",
},
{
name: "With FullwidthToNarrow, Without CompatBracket",
input: "〈〉⦅⦆",
options: kana.FullwidthToNarrow,
expect: "〈〉⦅⦆",
},
{
name: "With FullwidthToNarrow, With CompatBracket",
input: "〈〉⦅⦆",
options: kana.FullwidthToNarrow | kana.CompatBrackets,
expect: "<>⦅⦆",
},
{
name: "With HalfwidthToWide, Without CompatVoicedSoundMarks",
input: "゙゚",
options: kana.HalfwidthToWide,
expect: "\u3099\u309A",
},
{
name: "With HalfwidthToWide, With CompatVoicedSoundMarks",
input: "゙゚",
options: kana.HalfwidthToWide | kana.CompatVoicedSoundMarks,
expect: "゛゜",
},
{
name: "With HalfwidthToWide, Without CompatKeepHalfwidthHangul",
input: "\uFFA0ᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑ하ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ",
options: kana.HalfwidthToWide,
expect: "\u3164ㄱㄲㄳㄴㄵㄶㄷㄸㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅃㅄㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ",
},
{
name: "With HalfwidthToWide, With CompatKeepHalfwidthHangul",
input: "\uFFA0ᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑ하ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ",
options: kana.HalfwidthToWide | kana.CompatKeepHalfwidthHangul,
expect: "\uFFA0ᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑ하ᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ",
},
{
name: "With HalfwidthToWide, Without CompatKeepHalfwidthSymbols",
input: "│←↑→↓■○",
options: kana.HalfwidthToWide,
expect: "│←↑→↓■○",
},
{
name: "With HalfwidthToWide, With CompatKeepHalfwidthSymbols",
input: "│←↑→↓■○",
options: kana.HalfwidthToWide | kana.CompatKeepHalfwidthSymbols,
expect: "│←↑→↓■○",
},
{
name: "With KatakanaToHiragana, Without CompatKanaRestriction",
input: "ヵヶヷヸヹヺ𛅕𛅤𛅥𛅦",
options: kana.KatakanaToHiragana,
expect: "ゕゖわ\u3099ゐ\u3099ゑ\u3099を\u3099𛄲𛅐𛅑𛅒",
},
{
name: "With KatakanaToHiragana, With CompatKanaRestriction",
input: "ヵヶヷヸヹヺ𛅕𛅤𛅥𛅦",
options: kana.KatakanaToHiragana | kana.CompatKanaRestriction,
expect: "ヵヶヷヸヹヺ𛅕𛅤𛅥𛅦",
},
{
name: "With HiraganaToKatakana, Without CompatKanaRestriction",
input: "ゕゖ𛄲𛅐𛅑𛅒",
options: kana.HiraganaToKatakana,
expect: "ヵヶ𛅕𛅤𛅥𛅦",
},
{
name: "With HiraganaToKatakana, With CompatKanaRestriction",
input: "ゕゖ𛄲𛅐𛅑𛅒",
options: kana.HiraganaToKatakana | kana.CompatKanaRestriction,
expect: "ゕゖ𛄲𛅐𛅑𛅒",
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
actual := kana.Convert(tc.input, tc.options)
if diff := cmp.Diff(actual, tc.expect); diff != "" {
t.Errorf("diff (-actual +expect): %s", diff)
}
})
}
}