-
Notifications
You must be signed in to change notification settings - Fork 0
/
gomamayo_test.go
executable file
·131 lines (125 loc) · 2.22 KB
/
gomamayo_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
129
130
131
package gomamayo
import (
"fmt"
"testing"
)
type testcase struct {
input string
expect *Result
}
func TestAnalyze(t *testing.T) {
g, err := Init()
if err != nil {
panic(err)
}
trueGomamayo := []testcase{
{
input: "ゴママヨサラダ",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 1,
},
},
{
input: "ゴママヨ",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 1,
},
},
{
input: "サイレンススズカ",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 1,
},
},
{
input: "ハースストーン",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 1,
},
},
{
input: "部分分数分解",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 2,
},
},
{
input: "オレンジレンジ",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 3,
},
},
{
input: "太鼓公募募集終了",
expect: &Result{
IsGomamayo: true,
Ary: 3,
Degree: 2,
},
},
{
input: "多項高次ゴママヨ",
expect: &Result{
IsGomamayo: true,
Degree: 2,
Ary: 2,
},
},
{
input: "福山雅治",
expect: &Result{
IsGomamayo: true,
Degree: 1,
Ary: 1,
},
},
{
input: "長期金利",
expect: &Result{
IsGomamayo: true,
Degree: 1,
Ary: 1,
},
},
{
input: "株式公開買い付け",
expect: &Result{
IsGomamayo: true,
Ary: 1,
Degree: 2,
},
},
}
falseGomamayo := []string{
"パパイヤ",
"パパイヤジュース",
"オレンジジュース",
}
for _, sample := range trueGomamayo {
if r := g.Analyze(sample.input); !r.IsGomamayo {
fmt.Printf("%#v\n", r)
t.Errorf("%s is Gomamayo", sample.input)
} else if r.Degree != sample.expect.Degree || r.Ary != sample.expect.Ary {
fmt.Printf("%#v\n", r)
t.Errorf("%s is %d ary %d degree Gomamayo", sample.input, sample.expect.Ary, sample.expect.Degree)
}
}
for _, sample := range falseGomamayo {
if r := g.Analyze(sample); r.IsGomamayo {
fmt.Printf("%#v\n", r)
t.Errorf("%s is not Gomamayo", sample)
}
}
}