2019-03-23 09:43:25 +00:00
|
|
|
package pokercore
|
|
|
|
|
2019-03-24 04:13:06 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
2019-03-23 09:43:25 +00:00
|
|
|
|
2019-03-23 11:21:03 +00:00
|
|
|
type ShuffleTestResults []struct {
|
|
|
|
SeedVal int64
|
|
|
|
Expected string
|
|
|
|
}
|
|
|
|
|
2019-03-24 04:12:40 +00:00
|
|
|
func TestPokerDeck(t *testing.T) {
|
2019-03-23 11:21:03 +00:00
|
|
|
d := NewDeck()
|
2019-03-24 04:13:06 +00:00
|
|
|
fmt.Printf("newdeck: %+v\n", d)
|
2019-03-23 11:21:03 +00:00
|
|
|
d.ShuffleDeterministically(437)
|
2019-03-24 04:13:06 +00:00
|
|
|
fmt.Printf("deterministically shuffled deck: %+v\n", d)
|
2019-03-23 11:21:03 +00:00
|
|
|
cards := d.Deal(7)
|
2019-03-24 04:13:06 +00:00
|
|
|
expected := "6♥,A♦,7♥,9♣,6♠,9♥,8♣"
|
|
|
|
fmt.Printf("deterministically shuffled deck after dealing: %+v\n", d)
|
|
|
|
fmt.Printf("cards: %+v\n", cards)
|
|
|
|
assert.Equal(t, expected, cards.String())
|
2019-03-23 11:21:03 +00:00
|
|
|
|
2019-03-24 04:13:06 +00:00
|
|
|
x := d.Count()
|
2019-03-24 03:59:45 +00:00
|
|
|
assert.Equal(t, 45, x)
|
|
|
|
|
|
|
|
d.ShuffleDeterministically(123456789)
|
|
|
|
cards = d.Deal(10)
|
2019-03-24 04:13:06 +00:00
|
|
|
expected = "A♣,7♠,8♠,4♠,7♦,K♠,2♣,J♦,A♠,2♦"
|
2019-03-24 03:59:45 +00:00
|
|
|
assert.Equal(t, expected, cards.String())
|
2019-03-24 04:13:06 +00:00
|
|
|
x = d.Count()
|
|
|
|
assert.Equal(t, 35, x)
|
2019-03-24 03:59:45 +00:00
|
|
|
|
2019-03-23 09:43:25 +00:00
|
|
|
}
|
2019-03-24 04:13:06 +00:00
|
|
|
|
|
|
|
func TestDealing(t *testing.T) {
|
|
|
|
d := NewDeckFromCards(Cards{
|
|
|
|
Card{Rank: ACE, Suit: HEART},
|
|
|
|
Card{Rank: DEUCE, Suit: HEART},
|
|
|
|
Card{Rank: THREE, Suit: HEART},
|
|
|
|
Card{Rank: FOUR, Suit: HEART},
|
|
|
|
Card{Rank: FIVE, Suit: HEART},
|
|
|
|
})
|
|
|
|
cards := d.Deal(5)
|
|
|
|
expected := "A♥,2♥,3♥,4♥,5♥"
|
|
|
|
assert.Equal(t, expected, cards.String())
|
|
|
|
x := d.Count()
|
|
|
|
assert.Equal(t, 0, x)
|
|
|
|
}
|