From cc58f090b9dcc63df1c1515eb8164bf3951be45d Mon Sep 17 00:00:00 2001
From: Flavia Taras <flaviataras@student-net-cx-0991.intern.ethz.ch>
Date: Wed, 25 May 2022 09:00:18 +0200
Subject: [PATCH] small fixes

---
 CMakeLists.txt                           |  4 +--
 source/general/game_state/game_state.cpp |  2 +-
 source/general/game_state/hand.hpp       |  2 +-
 unit-tests/hand.cpp                      | 32 ++++++++++++++++++++++--
 4 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 060e39e..34b7ab7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,8 +117,8 @@ else()
     set(THREADS_PREFER_PTHREAD_FLAG ON)
     find_package(Threads REQUIRED)
 
-    target_link_libraries(Blackjack-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads)
-    target_link_libraries(Blackjack-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads)
+    target_link_libraries(Blackjack-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads)
+    target_link_libraries(Blackjack-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads)
 endif()
 
 # copy assets (images) to binary directory
diff --git a/source/general/game_state/game_state.cpp b/source/general/game_state/game_state.cpp
index 91d26ff..d44cf5b 100644
--- a/source/general/game_state/game_state.cpp
+++ b/source/general/game_state/game_state.cpp
@@ -136,7 +136,7 @@ bool game_state::everyone_finished() const {
 bool game_state::round_begin() const {
     unsigned int s = _players.size();
     for(unsigned int i = 0; i < s; ++i) {
-        if(!(_players[i]->get_bet_size() == 0) && !(_players[i]->is_broke()))
+        if(_players[i]->get_bet_size() != 0 && !(_players[i]->is_broke()))
             return false;
     }
     return true;
diff --git a/source/general/game_state/hand.hpp b/source/general/game_state/hand.hpp
index 793f3ec..4d76b9a 100644
--- a/source/general/game_state/hand.hpp
+++ b/source/general/game_state/hand.hpp
@@ -27,7 +27,7 @@ public:
     const std::vector<card*> get_cards() const; //checked
 
 // state update functions
-    void setup_round(std::string& err); //TODO
+    void setup_round(std::string& err); //checked
     bool add_card(card* card, std::string& err); //checked
 
     int get_points(std::string &err); //checked
diff --git a/unit-tests/hand.cpp b/unit-tests/hand.cpp
index 14a4caa..43eb459 100644
--- a/unit-tests/hand.cpp
+++ b/unit-tests/hand.cpp
@@ -223,12 +223,40 @@ TEST_F(HandTest, CountManyCardsWithDuplicates) {
     EXPECT_EQ(6, player_hand.get_nof_cards());
 }
 
+// The setup function has to remove the card in a hand if here is only one
+TEST_F(HandTest, SetupRoundOneCard) {
+    player_hand.add_card(cards[1][0], err);
+    player_hand.setup_round(err);
+    std::vector<card*> expected_hand = {};
+    EXPECT_EQ(expected_hand, player_hand.get_cards());
+}
+
+// Adding no cards and calling the setup function should also result in an empty hand
+TEST_F(HandTest, SetupRoundNoCards) {
+    player_hand.setup_round(err);
+    std::vector<card*> expected_hand = {};
+    EXPECT_EQ(expected_hand, player_hand.get_cards());
+}
+
 // The setup function has to remove all cards in a hand
-TEST_F(HandTest, SetupRound) {
+TEST_F(HandTest, SetupRoundManyCards) {
     player_hand.add_card(cards[1][0], err);
     player_hand.add_card(cards[7][0], err);
     player_hand.add_card(cards[9][0], err);
     player_hand.setup_round(err);
     std::vector<card*> expected_hand = {};
-    EXPECT_EQ(expected_hand, player_hand);
+    EXPECT_EQ(expected_hand, player_hand.get_cards());
+}
+
+// Adding no cards and calling the setup function should also result in an empty hand
+TEST_F(HandTest, SetupRoundManyCardsWithDuplicates) {
+    player_hand.add_card(cards[1][0], err);
+    player_hand.add_card(cards[1][1], err);
+    player_hand.add_card(cards[1][2], err);
+    player_hand.add_card(cards[7][0], err);
+    player_hand.add_card(cards[7][0], err);
+    player_hand.add_card(cards[9][0], err);
+    player_hand.setup_round(err);
+    std::vector<card*> expected_hand = {};
+    EXPECT_EQ(expected_hand, player_hand.get_cards());
 }
\ No newline at end of file
-- 
GitLab