-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine_test.go
More file actions
75 lines (61 loc) · 1.41 KB
/
engine_test.go
File metadata and controls
75 lines (61 loc) · 1.41 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
package poetryengine
import "fmt"
import "testing"
var s *Suit
var p = []Poem{
{
Title: "第一籤",
Gua: []string{"上上", "○○○○○"},
Poem: []string{"彩鳳呈祥瑞", "麒麟降帝都", "禍除迎福至", "喜氣自然生"},
Item: []string{"禍消福至", "求官得位", "求財大利", "婚姻成就", "出行大吉", "占病得安", "作事大吉", "考試得意"},
},
{
Title: "第二籤",
Gua: []string{"上平", "○●●●●"},
Poem: []string{"從革宜更變", "時來合動遷", "龍門魚躍出", "凡骨作神仙"},
Item: []string{"行事得利", "作事可成", "占訟和吉", "求官得位", "走失見近", "婚姻成吉", "運途漸吉", "作事如意"},
},
}
func init() {
s = New(p)
}
func TestNew(t *testing.T) {
New(p)
}
func TestGet(t *testing.T) {
fmt.Println(s.Get(0).Title)
}
func TestTotal(t *testing.T) {
fmt.Println(s.Total())
}
func TestGetList(t *testing.T) {
fmt.Printf("%T\n", s.GetList())
}
func TestDraw(t *testing.T) {
fmt.Println(s.Draw().Title)
}
func BenchmarkNew(b *testing.B) {
for i := 0; i < b.N; i++ {
New(p)
}
}
func BenchmarkGet(b *testing.B) {
for i := 0; i < b.N; i++ {
s.Get(1)
}
}
func BenchmarkTotal(b *testing.B) {
for i := 0; i < b.N; i++ {
s.Total()
}
}
func BenchmarkGetList(b *testing.B) {
for i := 0; i < b.N; i++ {
s.GetList()
}
}
func BenchmarkDraw(b *testing.B) {
for i := 0; i < b.N; i++ {
s.Draw()
}
}