Skip to content
Snippets Groups Projects
Commit c3215407 authored by Flavia Taras's avatar Flavia Taras
Browse files

finished hand tests

parent cc58f090
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
bool add_card(card* card, std::string& err); //checked bool add_card(card* card, std::string& err); //checked
int get_points(std::string &err); //checked int get_points(std::string &err); //checked
bool is_over_21(std::string &err); //TODO bool is_over_21(std::string &err); //checked
std::vector<card*>::iterator get_card_iterator(); std::vector<card*>::iterator get_card_iterator();
}; };
......
...@@ -259,4 +259,61 @@ TEST_F(HandTest, SetupRoundManyCardsWithDuplicates) { ...@@ -259,4 +259,61 @@ TEST_F(HandTest, SetupRoundManyCardsWithDuplicates) {
player_hand.setup_round(err); player_hand.setup_round(err);
std::vector<card*> expected_hand = {}; std::vector<card*> expected_hand = {};
EXPECT_EQ(expected_hand, player_hand.get_cards()); EXPECT_EQ(expected_hand, player_hand.get_cards());
}
// An empty hand will not have a score of over 21
TEST_F(HandTest, IsOver21NoCards) {
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand with only one card will not have a score of over 21
TEST_F(HandTest, IsOver21OneCard) {
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand with less than 21 points will not have a score of over 21
TEST_F(HandTest, IsOver21ManyCardsFalse) {
player_hand.add_card(cards[2][0], err);
player_hand.add_card(cards[7][0], err);
player_hand.add_card(cards[9][0], err);
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand (including an ace) with less than 21 points will not have a score of over 21
TEST_F(HandTest, IsOver21ManyCardsWithAceFalse) {
player_hand.add_card(cards[1][0], err);
player_hand.add_card(cards[7][0], err);
player_hand.add_card(cards[9][0], err);
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand of 21 points will not have a score of over 21
TEST_F(HandTest, IsOver21Exactly) {
player_hand.add_card(cards[4][0], err);
player_hand.add_card(cards[7][0], err);
player_hand.add_card(cards[10][0], err);
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand of 21 points (one ace and a face card) will not have a score of over 21
TEST_F(HandTest, IsOver21ExactlyWithAce) {
player_hand.add_card(cards[1][0], err);
player_hand.add_card(cards[13][0], err);
EXPECT_FALSE(player_hand.is_over_21(err));
}
// A hand of over 21 points will return true for is_over_21()
TEST_F(HandTest, IsOver21ManyCardsTrue) {
player_hand.add_card(cards[10][0], err);
player_hand.add_card(cards[4][0], err);
player_hand.add_card(cards[13][0], err);
EXPECT_TRUE(player_hand.is_over_21(err));
}
// A hand of over 21 points (with ace) will return true for is_over_21()
TEST_F(HandTest, IsOver21TrueWithAce) {
player_hand.add_card(cards[1][0], err);
player_hand.add_card(cards[7][0], err);
player_hand.add_card(cards[13][0], err);
player_hand.add_card(cards[5][0], err);
EXPECT_TRUE(player_hand.is_over_21(err));
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment