crowns/game_test.go

56 lines
1.2 KiB
Go

package main
import (
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
)
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)
}
func TestPlayRound2(t *testing.T) {
entropy := rand.New(rand.NewSource(1704595947230690673))
rr := NewRound(3, 4, entropy)
nextPlayer, scores := rr.Play(0)
assert.EqualValues(t, 0, nextPlayer)
assert.EqualValues(t, []int{0, 28, 6, 6}, scores)
}
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])
}