-
Notifications
You must be signed in to change notification settings - Fork 2
/
nabeatsu_test.go
128 lines (124 loc) · 2.89 KB
/
nabeatsu_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
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
package nabeatsu
import (
"testing"
)
func TestIsFool(t *testing.T) {
tests := []struct {
name string
input string
want bool
}{
{
name: "3の倍数",
input: "1221",
want: true,
},
{
name: "3の倍数ではない",
input: "1222",
want: false,
},
{
name: "3の倍数ではないが3を含む",
input: "13",
want: true,
},
{
name: "3の倍数で3を含む",
input: "33",
want: true,
},
{
name: "数字ではない",
input: "nabeatsu",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsFool(tt.input); got != tt.want {
t.Errorf("IsFool() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetFoolExpression(t *testing.T) {
tests := []struct {
name string
input string
want string
}{
{
name: "3の倍数以外",
input: "1",
want: "1",
},
{
name: "阿呆になる数字(1桁)",
input: "3",
want: "サァンwww",
},
{
name: "阿呆になる数字(2桁)",
input: "24",
want: "ニジュウヨンwww",
},
{
name: "阿呆になる数字(3桁)",
input: "489",
want: "ヨンヒャクハチジュウキュウwww",
},
{
name: "阿呆になる数字(4桁)",
input: "6570",
want: "ロクセンゴヒャクナナジュウwww",
},
{
name: "接頭辞の読み方が変わる場合(千, 百)",
input: "3300",
want: "サァンゼンサァンビャクwww",
},
{
name: "1は発音しない",
input: "1110",
want: "センヒャクジュウwww",
},
{
name: "接頭辞、数字両方の読み方が変わる場合(六百)",
input: "600",
want: "ロッピャクwww",
},
{
name: "接頭辞、数字両方の読み方が変わる場合(八千八百)",
input: "8802",
want: "ハッセンハッピャクニwww",
},
{
name: "追加の接頭辞がつく数字",
input: "865433100001", // 865,433,100,001 (八千六百五十四億 三千三百十万 一)
want: "ハッセンロッピャクゴジュウヨンオクサァンゼンサァンビャクジュウマンイチwww",
},
{
name: "1,000のときは特別な読み方をする",
input: "181001000003", // 181,001,000,003 (一千八百十億 百万 三)
want: "イッセンハッピャクジュウオクヒャクマンサァンwww",
},
{
name: "ゼロ埋めの接頭辞は省略する",
input: "1000000002", // 1,000,000,002 (十億 二)
want: "ジュウオクニwww",
},
{
name: "スペック外の数字",
input: "1000000000000000000000000000000000000000000000000000000000000000000000002",
want: "ムゲンダァイwww",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetFoolExpression(tt.input); got != tt.want {
t.Errorf("BuildFoolMessage() = %v, want %v", got, tt.want)
}
})
}
}