-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjapanese_test.go
65 lines (60 loc) · 1.14 KB
/
japanese_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
package wanakana_test
import (
"regexp"
"testing"
"github.com/deelawn/wanakana"
)
func TestIsJapanese(t *testing.T) {
var tests = []struct {
name string
input string
regex *regexp.Regexp
expected bool
}{
{
name: "empty string",
},
{
name: "crybaby",
input: "泣き虫",
expected: true,
},
{
name: "aa mixed hiragana katakana",
input: "あア",
expected: true,
},
{
name: "february with zenkaku number",
input: "2月",
expected: true,
},
{
name: "crybaby with zenkaku punctuation",
input: "泣き虫。!〜$",
expected: true,
},
{
name: "crybaby with latin punctuation",
input: "泣き虫.!~$",
},
{
name: "crybaby latin mix",
input: "A泣き虫",
},
{
name: "weird punctuation with regex",
input: "≪偽括弧≫",
regex: regexp.MustCompile(`[≪≫]`),
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := wanakana.IsJapanese(tt.input, tt.regex)
if result != tt.expected {
t.Errorf("expected %t, got %t", tt.expected, result)
}
})
}
}