-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwar_test.go
54 lines (48 loc) · 963 Bytes
/
war_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
package main
import (
"testing"
"./deck"
)
func TestDeckInit(t *testing.T) {
d := deck.DeckInit()
if len(d.PlayingCards) != 52 {
t.FailNow()
}
}
func TestDeckDraw(t *testing.T) {
d := deck.DeckInit()
deck.Draw(d)
if len(d.PlayingCards) != 51 {
t.FailNow()
}
deck.Draw(d)
deck.Draw(d)
if len(d.PlayingCards) != 49 {
t.FailNow()
}
}
func TestDeckSplit(t *testing.T) {
d := deck.DeckInit()
d1, d2 := deck.SplitCards(d)
if len(d1.PlayingCards) != 26 || len(d2.PlayingCards) != 26 {
t.Log("Split Deck Failure")
t.FailNow()
}
for _, c1 := range d1.PlayingCards {
for _, c2 := range d2.PlayingCards {
if c1.ToStr() == c2.ToStr() {
t.Log("There should be no duplicate cards.")
t.FailNow()
}
}
}
}
func TestDeckSplitAndDraw(t *testing.T) {
d := deck.DeckInit()
d1, d2 := deck.SplitCards(d)
deck.Draw(d1)
if len(d1.PlayingCards) != 25 || len(d2.PlayingCards) != 26 {
t.Log("Split Deck Failure")
t.FailNow()
}
}