-
Notifications
You must be signed in to change notification settings - Fork 0
/
okurigana_test.go
67 lines (62 loc) · 1.27 KB
/
okurigana_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
package wanakana_test
import (
"testing"
"github.com/deelawn/wanakana"
)
func TestStripOkurigana(t *testing.T) {
var tests = []struct {
name string
input string
leading bool
matchKanji string
expected string
}{
{
name: "empty string",
},
{
name: "trailing 1",
input: "踏み込む",
expected: "踏み込",
},
{
name: "trailing 2",
input: "お祝い",
expected: "お祝",
},
{
name: "leading",
input: "お腹",
leading: true,
expected: "腹",
},
{
name: "match kanji trailing",
input: "ふみこむ",
matchKanji: "踏み込む",
expected: "ふみこ",
},
{
name: "match kanji leading",
input: "おみまい",
leading: true,
matchKanji: "お祝い",
expected: "みまい",
},
{
// Invalid match kanji results in this spitting out the input.
name: "invalid match kanji",
input: "おみまい",
matchKanji: "おみまい",
expected: "おみまい",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := wanakana.StripOkurigana(tt.input, tt.leading, tt.matchKanji)
if result != tt.expected {
t.Errorf("expected %v, actual %v", tt.expected, result)
}
})
}
}