Repository navigation
Expand file tree
/
Copy pathTest.cpp
More file actions
178 lines (142 loc) · 4.78 KB
/
Copy pathTest.cpp
File metadata and controls
178 lines (142 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "catan.hpp"
#include "player.hpp"
#include "board.hpp"
/*-------------------------------------------------CATAN--------------------------------------------------------*/
TEST_CASE("Catan Class") {
Player p1("Alice");
Player p2("Bob");
Player p3("Charlie");
Catan catan(p1, p2, p3);
SUBCASE("Initialization") {
CHECK(catan.getPlayers().size() == 3);
}
SUBCASE("Initializing Development Cards") {
catan.initializeDevelopmentCard();
CHECK(catan.getDevelopmentCards().size() == 25); // Assuming there are 25 development cards
}
SUBCASE("Choosing Starting Player") {
std::string startingPlayer = catan.ChooseStartingPlayer();
CHECK((startingPlayer == "Alice" || startingPlayer == "Bob" || startingPlayer == "Charlie"));
}
SUBCASE("Getting Development Card") {
std::string card = catan.getDevelopmentCard();
CHECK(!card.empty()); // Assuming a card is drawn if the deck is not empty
}
SUBCASE("Using Knight Card") {
bool result = catan.Knight("wood", 6, true);
CHECK(result); // Assuming the function returns true on success
}
SUBCASE("Printing Winner") {
bool hasWinner = catan.printWinner();
CHECK(!hasWinner); // Initially there should be no winner
}
}
TEST_CASE("Development Card Functionality") {
Player p1("Alice");
Player p2("Bob");
Player p3("Charlie");
Catan catan(p1, p2, p3);
catan.initializeDevelopmentCard();
SUBCASE("Drawing Cards") {
for (int i = 0; i < 25; ++i) {
CHECK(!catan.getDevelopmentCard().empty());
}
CHECK(catan.getDevelopmentCard().empty()); // Deck should be empty now
}
SUBCASE("Using Knight Card") {
std::string card = catan.getDevelopmentCard();
if (card == "Knight") {
bool result = catan.Knight("wood", 6, true);
CHECK(result);
}
}
}
TEST_CASE("Player Class") {
Player player("Alice");
SUBCASE("Initialization") {
CHECK(player.getName() == "Alice");
CHECK(player.getPoints() == 0);
CHECK(player.getKnights() == 0);
}
SUBCASE("Placing Settlements") {
Board board;
player.placeSettelemnt(board);
CHECK(board.getSettlements().size() == 1); // Assuming there's a way to get the number of settlements
}
SUBCASE("Rolling Dice") {
Board board;
Catan catan(player, player, player);
player.rollDice(catan, board);
}
SUBCASE("Placing Roads") {
Board board;
player.placeRoad(board);
}
SUBCASE("Buying Development Cards") {
Board board;
Catan catan(player, player, player);
player.buyDevelopmentCard(catan);
CHECK(player.getDevelopment().size() == 1); // Assuming there's a way to get the number of dev cards
}
SUBCASE("Trading with Other Player") {
Player other("Bob");
player.trade(other);
}
SUBCASE("Using Development Cards") {
Board board;
Catan catan(player, player, player);
player.useDevelopmentCard(catan, board);
}
SUBCASE("Setting Turn") {
player.setTurn();
CHECK(player.isTurn());
}
SUBCASE("Ending Turn") {
player.endTurn();
CHECK(!player.isTurn());
}
}
TEST_CASE("Game Flow") {
Player p1("Alice");
Player p2("Bob");
Player p3("Charlie");
Catan catan(p1, p2, p3);
SUBCASE("Initial Setup") {
catan.ChooseStartingPlayer();
Board& board = catan.getBoard();
p1.placeSettelemnt(board);
p2.placeSettelemnt(board);
p3.placeSettelemnt(board);
CHECK(board.getSettlements().size() == 3);
p1.placeSettelemnt(board);
p2.placeSettelemnt(board);
p3.placeSettelemnt(board);
CHECK(board.getSettlements().size() == 6);
}
SUBCASE("Rolling Dice and Resource Distribution") {
Board& board = catan.getBoard();
for (auto player : catan.getPlayers()) {
player->setTurn();
player->rollDice(catan, board);
player->endTurn();
}
}
SUBCASE("Buying and Using Development Cards") {
p1.setTurn();
p1.buyDevelopmentCard(catan);
p1.useDevelopmentCard(catan, catan.getBoard());
p1.endTurn();
CHECK(!p1.getDevelopment().empty());
}
SUBCASE("Trading Between Players") {
p1.setTurn();
p1.trade(p2);
p1.endTurn();
}
SUBCASE("End Game Conditions") {
p1.setPoints(10);
CHECK(catan.printWinner());
}
}