first version of sanity tests passing

This commit is contained in:
Jeffrey Paul 2019-03-23 20:59:45 -07:00
parent 032b64b4cb
commit 6d2c71663c
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 package pokercore
import "github.com/stretchr/testify/assert"
import "testing" import "testing"
type ShuffleTestResults []struct { type ShuffleTestResults []struct {
@ -14,14 +15,16 @@ func TestPokerHand(t *testing.T) {
cards := d.Deal(7) cards := d.Deal(7)
//expected := "7C,5S,QS,2D,6D,QC,3H" //expected := "7C,5S,QS,2D,6D,QC,3H"
expected := "7♣,5♠,Q♠,2♦,6♦,Q♣,3♥" expected := "7♣,5♠,Q♠,2♦,6♦,Q♣,3♥"
if s := cards.String(); s != expected { assert.Equal(t, cards.String(), expected)
t.Errorf("didn't get expected cards, got %s", s)
} else {
t.Logf("got expected cards %s", s)
}
x := d.Remaining() x := d.Remaining()
if x != 45 { assert.Equal(t, 45, x)
t.Errorf("expected 45 left, got %d", 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)
} }