-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_test.go
87 lines (75 loc) · 2.43 KB
/
player_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
package main
import (
"testing"
)
func TestToggleReady(t *testing.T) {
player := Player{IsReady: false}
player.toggleReady()
want := true
got := player.IsReady
if got != want {
t.Errorf("toggleReady(). Got %v, want %v", got, want)
}
player.toggleReady()
want = false
got = player.IsReady
if got != want {
t.Errorf("toggleReady(). Got %v, want %v", got, want)
}
}
func TestPlayerHasPriorityCard(t *testing.T) {
player := Player{Species: []Species{{Traits: []Card{{IsPrior: false}, {IsPrior: true}, {IsPrior: false}}}}}
want := true
got := player.hasPriorityCard()
if got != want {
t.Errorf("hasPriorityCard(). Got %v, want %v", got, want)
}
player = Player{Species: []Species{{Traits: []Card{{IsPrior: false}, {IsPrior: false}, {IsPrior: false}}}}}
want = false
got = player.hasPriorityCard()
if got != want {
t.Errorf("hasPriorityCard(). Got %v, want %v", got, want)
}
}
func TestAreSpeciesFed(t *testing.T) {
player := Player{Species: []Species{{Food: 3, Population: 3}, {Food: 3, Population: 3}}}
want := true
got := player.areSpeciesFed()
if got != want {
t.Errorf("areSpeciesFed(). Got %v, want %v", got, want)
}
player = Player{Species: []Species{{Food: 3, Population: 3}, {Food: 3, Population: 4}}}
want = false
got = player.areSpeciesFed()
if got != want {
t.Errorf("areSpeciesFed(). Got %v, want %v", got, want)
}
}
func TestArePlayersReady(t *testing.T) {
players := []Player{{IsReady: true}, {IsReady: true}, {IsReady: true}}
want := true
got := arePlayersReady(players, false)
if got != want {
t.Errorf("arePlayersReady(). Got %v, want %v", got, want)
}
players = []Player{{IsReady: true}, {IsReady: false}, {IsReady: true}}
want = false
got = arePlayersReady(players, false)
if got != want {
t.Errorf("arePlayersReady(). Got %v, want %v", got, want)
}
}
func TestArePlayersReadyPriority(t *testing.T) {
players := []Player{{IsReady: false, Species: []Species{{Traits: []Card{{IsPrior: true}}}}}, {IsReady: true, Species: []Species{{Traits: []Card{{IsPrior: false}}}}}}
want := false
got := arePlayersReady(players, true)
if got != want {
t.Errorf("arePlayersReady(). Got %v, want %v", got, want)
}
players = []Player{{IsReady: true, Species: []Species{{Traits: []Card{{IsPrior: false}}}}}, {IsReady: true, Species: []Species{{Traits: []Card{{IsPrior: false}}}}}}
want = true
got = arePlayersReady(players, true)
if got != want {
t.Errorf("arePlayersReady(). Got %v, want %v", got, want)
}
}