-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_test.go
40 lines (33 loc) · 853 Bytes
/
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
package main
import (
"testing"
)
func TestPlayerCreation(t *testing.T) {
p := NewPlayer("Player1")
if p.Name != "Player1" {
t.Error("Player's name was not \"Player1\"")
}
}
// Draw card
func TestDrawingAndDiscardingCard(t *testing.T) {
princess := Card{8, "Princess", "Discarding this card loses the game"}
players := []*Player{NewPlayer("Player1")}
p := players[0]
NewRound(players)
p.ReceiveCard(princess)
if len(p.Hand) != 2 {
t.Errorf("Expected player to have 2 card in their hand, but they had %d", len(p.Hand))
}
err := p.Discard()
if err != nil {
t.Fatal(err)
}
if len(p.Hand) != 1 {
t.Errorf("Expected player to have 1 card in their hand, but they had %d", len(p.Hand))
}
}
// func TestCardInHand(t *testing.T) {
// players := []*Player{NewPlayer("Player1")}
// p1 := players[0]
// r := NewRound(players)
// }