TEST(Hand, stringToHand) { CardConverter converter; Hand hand; converter.stringToHand("7S 5S 9S JD KD", hand); hand.computeRank(); EXPECT_EQ(RankHighCard, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(5, pts.size()); EXPECT_EQ(13, pts[0]); EXPECT_EQ(11, pts[1]); EXPECT_EQ(9, pts[2]); EXPECT_EQ(7, pts[3]); EXPECT_EQ(5, pts[4]); }
TEST(Hand, computeRank_straight) { // 3H 4C 5S 6D 7D Hand hand; hand.add(Card(3, SuitHeart)); hand.add(Card(4, SuitClub)); hand.add(Card(5, SuitSpade)); hand.add(Card(6, SuitDiamond)); hand.add(Card(7, SuitDiamond)); hand.computeRank(); EXPECT_EQ(RankStraight, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(1, pts.size()); EXPECT_EQ(7, pts[0]); }
TEST(Hand, computeRank_straightFlush) { // 3C 4C 5C 6C 7C Hand hand; hand.add(Card(3, SuitClub)); hand.add(Card(4, SuitClub)); hand.add(Card(5, SuitClub)); hand.add(Card(6, SuitClub)); hand.add(Card(7, SuitClub)); hand.computeRank(); EXPECT_EQ(RankStraightFlush, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(1, pts.size()); EXPECT_EQ(7, pts[0]); }
TEST(Hand, computeRank_fourOfaKind) { // 5H 5C 5S 5D KD Hand hand; hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitClub)); hand.add(Card(5, SuitSpade)); hand.add(Card(5, SuitDiamond)); hand.add(Card(13, SuitDiamond)); hand.computeRank(); EXPECT_EQ(RankFourOfaKind, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(2, pts.size()); EXPECT_EQ(5, pts[0]); EXPECT_EQ(13, pts[1]); }
TEST(Hand, computeRank_fullHouse) { // 5H 5C 5D 9H 9S Hand hand; hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitClub)); hand.add(Card(5, SuitDiamond)); hand.add(Card(9, SuitHeart)); hand.add(Card(9, SuitSpade)); hand.computeRank(); EXPECT_EQ(RankFullHouse, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(2, pts.size()); EXPECT_EQ(5, pts[0]); EXPECT_EQ(9, pts[1]); }
TEST(Hand, computeRank_twoPairs) { // 5H 5C 6S 6D KD Hand hand; hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitClub)); hand.add(Card(6, SuitSpade)); hand.add(Card(6, SuitDiamond)); hand.add(Card(13, SuitDiamond)); hand.computeRank(); EXPECT_EQ(RankTwoPairs, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(3, pts.size()); EXPECT_EQ(6, pts[0]); EXPECT_EQ(5, pts[1]); EXPECT_EQ(13, pts[2]); }
TEST(Hand, computeRank_onePair) { // 5H 5C 6S 7S KD Hand hand; hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitClub)); hand.add(Card(6, SuitSpade)); hand.add(Card(7, SuitSpade)); hand.add(Card(13, SuitDiamond)); hand.computeRank(); EXPECT_EQ(RankOnePair, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(4, pts.size()); EXPECT_EQ(5, pts[0]); EXPECT_EQ(13, pts[1]); EXPECT_EQ(7, pts[2]); EXPECT_EQ(6, pts[3]); }
TEST(Hand, computeRank_highcard) { // 7S 5S 9S JD KD Hand hand; hand.add(Card(7, SuitSpade)); hand.add(Card(5, SuitSpade)); hand.add(Card(9, SuitSpade)); hand.add(Card(11, SuitDiamond)); hand.add(Card(13, SuitDiamond)); hand.computeRank(); EXPECT_EQ(RankHighCard, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(5, pts.size()); EXPECT_EQ(13, pts[0]); EXPECT_EQ(11, pts[1]); EXPECT_EQ(9, pts[2]); EXPECT_EQ(7, pts[3]); EXPECT_EQ(5, pts[4]); }
TEST(Hand, computeRank_flush) { // 5H 5H 5H 6H KH Hand hand; hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitHeart)); hand.add(Card(5, SuitHeart)); hand.add(Card(6, SuitHeart)); hand.add(Card(13, SuitHeart)); hand.computeRank(); EXPECT_EQ(RankFlush, hand.rank()); std::vector<int> pts; hand.points(pts); ASSERT_EQ(5, pts.size()); EXPECT_EQ(13, pts[0]); EXPECT_EQ(6, pts[1]); EXPECT_EQ(5, pts[2]); EXPECT_EQ(5, pts[3]); EXPECT_EQ(5, pts[4]); }