-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeck_test.go
39 lines (26 loc) · 895 Bytes
/
deck_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewDeck(t *testing.T) {
deck := newDeck()
assert.Equal(t, 52, len(deck), "Deck should have 52 cards")
assert.Equal(t, "Spades", deck[0].Suit, "First card should be Spades")
assert.Equal(t, "Ace", deck[0].Rank, "First card should be Ace")
assert.Equal(t, "Clubs", deck[51].Suit, "Last card should be Clubs")
assert.Equal(t, "King", deck[51].Rank, "Last card should be King")
}
func TestDeal(t *testing.T) {
deck := newDeck()
hand := deck.deal(7)
assert.Equal(t, 7, len(hand), "Hand should have 7 cards")
assert.Equal(t, 45, len(deck), "Deck should have 45 cards")
}
func TestShuffle(t *testing.T) {
deck := newDeck()
anotherDeck := newDeck()
assert.Equal(t, deck, anotherDeck, "Decks should be equal")
deck.shuffle()
assert.NotEqual(t, deck, anotherDeck, "Decks should not be equal")
}