-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame_test.go
More file actions
38 lines (30 loc) · 799 Bytes
/
game_test.go
File metadata and controls
38 lines (30 loc) · 799 Bytes
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
package main
import (
"strconv"
"testing"
)
func TestSummeryCardsInHand(t *testing.T) {
deck := newDeck()
if summeryCardsInHand(deck) != 220 {
t.Errorf("Expected summery on card values to be 220, but got: %v", summeryCardsInHand(deck))
}
}
func TestPlayCards(t *testing.T) {
testPlayer1 := createTestPlayer(1)
testPlayer2 := createTestPlayer(2)
winner := playCards(testPlayer1, testPlayer2)
if winner.firstName != "Name2" {
t.Errorf("Expected winner to be Player two, but got: %v", winner.firstName)
}
}
func createTestPlayer(value int) player {
player := createPlayer("Name"+strconv.Itoa(value), "Last")
playerHnd := deck{}
playerCard := card{
Value: value,
Suit: "",
}
playerHnd.Cards = append(playerHnd.Cards, playerCard)
player.hand = playerHnd
return player
}