package entity import ( "testing" ) func TestHandAllCards(t *testing.T) { t.Run("all pub", func(t *testing.T) { hand := Hand{ Public: []Card{ Card{Value: 1}, Card{Value: 2}, }, } all := hand.AllCards() if len(all) != 2 { t.Fatal(all) } }) t.Run("all pri", func(t *testing.T) { hand := Hand{ Private: []Card{ Card{Value: 1}, Card{Value: 2}, }, } all := hand.AllCards() if len(all) != 2 { t.Fatal(all) } }) t.Run("both", func(t *testing.T) { hand := Hand{ Public: []Card{ Card{Value: 3}, Card{Value: 4}, }, Private: []Card{ Card{Value: 1}, Card{Value: 2}, }, } all := hand.AllCards() if len(all) != 4 { t.Fatal(all) } }) } func TestHandStraight(t *testing.T) { cases := map[string]struct { public []Card private []Card want bool }{ "empty": { want: false, }, "one public card": { public: []Card{Card{Value: 3}}, want: false, }, "one private card": { private: []Card{Card{Value: 3}}, want: false, }, "two public card nonseq": { public: []Card{Card{Value: 3}, Card{Value: 1}}, want: false, }, "two private card nonseq": { private: []Card{Card{Value: 3}, Card{Value: 1}}, want: false, }, "one public card one private card nonseq": { public: []Card{Card{Value: 3}}, private: []Card{Card{Value: 1}}, want: false, }, "two public card seq": { public: []Card{Card{Value: 3}, Card{Value: 2}}, want: true, }, "two private card seq": { private: []Card{Card{Value: 3}, Card{Value: 2}}, want: true, }, "one public card one private card seq": { public: []Card{Card{Value: 2}}, private: []Card{Card{Value: 1}}, want: true, }, } for name, d := range cases { c := d t.Run(name, func(t *testing.T) { hand := Hand{Public: c.public, Private: c.private} got := hand.Straight() if got != c.want { t.Fatal(c.want, got) } }) } }