first version of sanity tests passing

This commit is contained in:
Jeffrey Paul 2019-03-23 20:59:45 -07:00
parent 032b64b4cb
commit ee32ef0cb1
4 changed files with 26 additions and 8 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
default: test
test:
cd pokercore && make test

10
pokercore/Makefile Normal file
View File

@ -0,0 +1,10 @@
default: test
.PHONY: pkgs test
fetch:
go get -t
test: *.go
go test -v

View File

@ -204,4 +204,5 @@ func scorePokerHand(input Cards) (score int) {
*/
return 1
}

View File

@ -1,5 +1,6 @@
package pokercore
import "github.com/stretchr/testify/assert"
import "testing"
type ShuffleTestResults []struct {
@ -14,14 +15,16 @@ func TestPokerHand(t *testing.T) {
cards := d.Deal(7)
//expected := "7C,5S,QS,2D,6D,QC,3H"
expected := "7♣,5♠,Q♠,2♦,6♦,Q♣,3♥"
if s := cards.String(); s != expected {
t.Errorf("didn't get expected cards, got %s", s)
} else {
t.Logf("got expected cards %s", s)
}
assert.Equal(t, cards.String(), expected)
x := d.Remaining()
if x != 45 {
t.Errorf("expected 45 left, got %d", x)
}
assert.Equal(t, 45, x)
d.ShuffleDeterministically(123456789)
cards = d.Deal(10)
expected = "2♣,T♠,4♥,Q♣,9♦,7♥,7♠,6♥,5♥,5♠"
assert.Equal(t, expected, cards.String())
x = d.Remaining()
assert.Equal(t, 42, x)
}