-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
The output of hand ranking is offset by 1.
package card
import (
"encoding/json"
"testing"
"github.com/notnil/joker/hand"
)
type MyData struct {
Cards []hand.Card `json:"cards"`
}
func TestStringOutput(t *testing.T) {
s1 := `
{
"cards": ["3♠", "3♣", "5♣", "6♣", "9♣"]
}
`
s2 := `
{
"cards": ["3♣", "5♣", "6♣", "7♣", "9♣"]
}
`
data := &MyData{}
if err := json.Unmarshal([]byte(s1), data); err != nil {
t.Fatalf("Failed to unmarshal: %+v", err)
}
t.Log(data.Cards)
t.Log(hand.New(data.Cards).Ranking().String())
if err := json.Unmarshal([]byte(s2), data); err != nil {
t.Fatalf("Failed to unmarshal: %+v", err)
}
t.Log(data.Cards)
t.Log(hand.New(data.Cards).Ranking().String())
}The output is
$ go test ./... -v -run TestStringOutput
=== RUN TestStringOutput
--- PASS: TestStringOutput (0.00s)
my_test.go:30: [3♠ 3♣ 5♣ 6♣ 9♣]
my_test.go:31: TwoPair
my_test.go:36: [3♣ 5♣ 6♣ 7♣ 9♣]
my_test.go:37: FullHouse
PASSMetadata
Metadata
Assignees
Labels
No labels