crowns/game_test.go

45 lines
924 B
Go
Raw Normal View History

2024-01-07 00:09:47 +00:00
package main
import (
"math/rand"
2024-01-07 00:09:47 +00:00
"testing"
"github.com/stretchr/testify/assert"
2024-01-07 00:09:47 +00:00
)
func TestPlayRound(t *testing.T) {
entropy := rand.New(rand.NewSource(0xdeadbeef))
rr := NewRound(5, 4, entropy)
nextPlayer, scores := rr.Play(0)
assert.EqualValues(t, 0, nextPlayer)
assert.EqualValues(t, []int{0, 28, 6, 6}, scores)
2024-01-07 00:09:47 +00:00
}
func TestDrawDiscard(t *testing.T) {
entropy := rand.New(rand.NewSource(0xdeadbeef))
rr := NewRound(5, 4, entropy)
assert.EqualValues(t, []Card{50, 47, 24, 25, 22}, rr.hands[0])
c := rr.DrawFromDeck()
assert.EqualValues(t, Card(15), c)
rr.AddToHand(0, c)
assert.EqualValues(t, []Card{50, 47, 24, 25, 22, 15}, rr.hands[0])
rr.Discard(0, 2)
assert.EqualValues(t, []Card{50, 47, 15, 25, 22}, rr.hands[0])
assert.EqualValues(t, Card(24), rr.PeekFromDiscard())
c = rr.DrawFromDiscard()
rr.AddToHand(0, c)
assert.EqualValues(t, []Card{50, 47, 15, 25, 22, 24}, rr.hands[0])
}