-
Notifications
You must be signed in to change notification settings - Fork 0
/
state_test.go
67 lines (56 loc) · 1.15 KB
/
state_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 main
import (
"math/rand"
"testing"
"time"
)
/*
func TestDrawAndDiscard(t *testing.T) {
rand.Seed(time.Now().UnixNano())
s := new(State)
s.Init()
vic := s.TotalVictory()
if vic != 3 {
t.Errorf("Victory points: %d. Want: 3", vic)
} else {
t.Logf("Victory points initially: %d", vic)
}
for i := 0; i < 100; i++ {
s.DrawHand()
s.Discard()
}
vic = s.TotalVictory()
if vic != 3 {
t.Errorf("Victory points: %d. Want: 3", vic)
}
}
*/
func TestAddCard(t *testing.T) {
rand.Seed(time.Now().UnixNano())
s := new(State)
s.Init()
vic := s.TotalVictory()
if vic != 3 {
t.Errorf("Victory points: %d. Want: 3", vic)
}
for i := 0; i < 100; i++ {
s.DrawHand()
s.AddCardAndDiscardHand("copper")
c := s.TotalCardsByName("copper")
if c != 8+i {
t.Errorf("[%d] Total coppers: %d. Want: %d\n", i, c, 8+i)
}
}
cards := s.TotalCards()
if cards != 110 {
t.Errorf("Total cards: %d. Want: 110", cards)
}
coppers := s.TotalCardsByName("copper")
if coppers != 107 {
t.Errorf("Total coppers: %d. Want: 107", coppers)
}
estates := s.TotalCardsByName("estate")
if estates != 3 {
t.Errorf("Total estates: %d. Want: 3", estates)
}
}