crowns/game_test.go

56 lines
1.2 KiB
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, 36, 6, 26}, scores)
2024-01-07 00:09:47 +00:00
}
2024-01-07 03:00:29 +00:00
func TestPlayRound2(t *testing.T) {
entropy := rand.New(rand.NewSource(1704595947230690673))
rr := NewRound(3, 4, entropy)
nextPlayer, scores := rr.Play(0)
assert.EqualValues(t, 1, nextPlayer)
assert.EqualValues(t, []int{21, 0, 16, 26}, scores)
2024-01-07 03:00:29 +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])
}