Skip to content

Commit 07ed4cc

Browse files
committed
Made a branch I can work in.
1 parent 9ea7c3b commit 07ed4cc

File tree

10 files changed

+294
-289
lines changed

10 files changed

+294
-289
lines changed

tests/main.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#include "gtest/gtest.h"
1+
#include <UnitTest++.h>
22

3-
int main(int argc, char** argv) {
4-
::testing::InitGoogleTest(&argc, argv);
5-
6-
return RUN_ALL_TESTS();
3+
int main() {
4+
return UnitTest::RunAllTests();
75
}
86

tests/testConfig.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
1-
#include <stdexcept>
2-
3-
#include "gtest/gtest.h"
4-
1+
#include "UnitTest++.h"
52
#include "Config.h"
63

4+
#include <stdexcept>
75

86
using std::string;
97
using std::stringstream;
108

11-
TEST(ConfigTest, readOneString) {
9+
TEST(readOneString) {
1210
stringstream file("variable=value");
1311
Config config(file);
1412

15-
ASSERT_EQ((string)config["variable"], "value");
13+
CHECK((string)config["variable"] == "value");
1614
}
1715

18-
TEST(ConfigTest, readTwoStrings) {
16+
TEST(readTwoStrings) {
1917
stringstream file("var_a=val_a\nvar_b=val_b\n");
2018
Config config(file);
2119

22-
ASSERT_EQ((string)config["var_a"], "val_a");
23-
ASSERT_EQ((string)config["var_b"], "val_b");
20+
CHECK((string)config["var_a"] == "val_a");
21+
CHECK((string)config["var_b"] == "val_b");
2422
}
2523

26-
TEST(ConfigTest, readFloat) {
24+
TEST(readFloat) {
2725
stringstream file("float=5.0\n");
2826
Config config(file);
2927

30-
ASSERT_EQ((float)config["float"], 5.0f);
28+
CHECK((float)config["float"] == 5.0f);
3129
}
3230

33-
TEST(ConfigTest, readCommentsEmptyLines) {
31+
TEST(readCommentsEmptyLines) {
3432
stringstream file("#this is a string\nstring=hello\n#we just had a string\n\n\n\n\n");
3533
Config config(file);
3634

37-
ASSERT_EQ((string)config["string"], "hello");
35+
CHECK((string)config["string"] == "hello");
3836
}
3937

40-
TEST(ConfigTest, readInvalid) {
38+
TEST(readInvalid) {
4139
stringstream file("variable=value");
4240
Config config(file);
4341

44-
ASSERT_THROW((string)config["string"] == "hello", std::runtime_error);
42+
CHECK_THROW((string)config["string"] == "hello", std::runtime_error);
4543
}
4644

47-
TEST(ConfigTest, readCoordinate) {
45+
TEST(readCoordinate) {
4846
stringstream file("coord=(1,2)");
4947
Config config(file);
5048

51-
ASSERT_EQ(Coordinate({1, 2}), (Coordinate)config["coord"]);
49+
CHECK(Coordinate({1, 2}) == (Coordinate)config["coord"]);
5250
}
5351

54-
TEST(ConfigTest, readScreenCoordinate) {
52+
TEST(readScreenCoordinate) {
5553
stringstream file("coord=(1.5,2.5)");
5654
Config config(file);
5755

58-
ASSERT_EQ(ScreenCoordinate({1.5, 2.5}), (ScreenCoordinate)config["coord"]);
56+
CHECK(ScreenCoordinate({1.5, 2.5}) == (ScreenCoordinate)config["coord"]);
5957
}

tests/testRenderer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#include <iostream>
22

3-
#include "gtest/gtest.h"
4-
3+
#include "UnitTest++.h"
54
#include "Renderer.h"
65

76
using std::make_pair;
87

9-
TEST(RendererTest, coordToScreen) {
8+
TEST(coordToScreen) {
109
for(int x = -5; x < 5; x++) {
1110
for(auto y = -5; y < 5; y++) {
1211
auto original = make_pair(x, y);
1312
auto screen = coordToScreen(original);
1413
auto back = screenToCoord(screen);
15-
ASSERT_EQ(original.first, back.first);
16-
ASSERT_EQ(original.second, back.second);
14+
CHECK(original.first == back.first);
15+
CHECK(original.second == back.second);
1716
}
1817
}
1918
}

tests/testSerialization.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
#include <iostream>
2-
#include <sstream>
3-
#include <memory>
4-
#include <vector>
5-
6-
#include "gtest/gtest.h"
1+
#include <UnitTest++.h>
72

83
#include "Serialization.h"
94
#include "GameBoard.h"
@@ -12,31 +7,37 @@
127

138
#include "tinyxml2.h"
149

10+
#include <iostream>
11+
#include <sstream>
12+
#include <memory>
13+
#include <vector>
14+
1515
using std::vector;
1616
using std::unique_ptr;
1717
using std::stringstream;
1818

19-
TEST(SerializationTest, emptyBoardSerialization) {
19+
TEST(emptyBoardSerialization) {
2020
GameBoard testBoard({});
2121

2222
stringstream stream;
2323
testBoard.save(stream);
2424

2525
GameBoard copyBoard(stream);
26-
ASSERT_EQ(testBoard, copyBoard);
26+
27+
CHECK(testBoard == copyBoard);
2728
}
2829

29-
TEST(SerializationTest, multiplePlayerSerialization) {
30+
TEST(multiplePlayerSerialization) {
3031
GameBoard testBoard({"test", "test2"});
3132
stringstream stream;
3233
testBoard.save(stream);
3334

3435
GameBoard copyBoard(stream);
35-
36-
ASSERT_EQ(testBoard, copyBoard);
36+
37+
CHECK(testBoard == copyBoard);
3738
}
3839

39-
TEST(SerializationTest, testCardSerialization) {
40+
TEST(testCardSerialization) {
4041
GameBoard testBoard({"test"});
4142
Player& testPlayer = testBoard.getPlayer(0);
4243

@@ -57,10 +58,11 @@ TEST(SerializationTest, testCardSerialization) {
5758
testBoard.save(stream);
5859

5960
GameBoard copyBoard(stream);
60-
ASSERT_EQ(testBoard, copyBoard);
61+
62+
CHECK(testBoard == copyBoard);
6163
}
6264

63-
TEST(SerializationTest, roadSerialization) {
65+
TEST(roadSerialization) {
6466
GameBoard testBoard({"test", "test2"});
6567
Player& firstPlayer = testBoard.getPlayer(0);
6668
Player& secondPlayer = testBoard.getPlayer(1);
@@ -74,10 +76,11 @@ TEST(SerializationTest, roadSerialization) {
7476
testBoard.save(stream);
7577

7678
GameBoard copyBoard(stream);
77-
ASSERT_EQ(testBoard, copyBoard);
79+
80+
CHECK(testBoard == copyBoard);
7881
}
7982

80-
TEST(SerializationTest, settlementSerialization) {
83+
TEST(settlementSerialization) {
8184
GameBoard testBoard({"test"});
8285
Player& player = testBoard.getPlayer(0);
8386

@@ -88,5 +91,6 @@ TEST(SerializationTest, settlementSerialization) {
8891
testBoard.save(stream);
8992

9093
GameBoard copyBoard(stream);
91-
ASSERT_EQ(testBoard, copyBoard);
94+
95+
CHECK(testBoard == copyBoard);
9296
}

tests/test_CornerPiece.cpp

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Author: Kyle Grage
66
*/
77

8-
#include "gtest/gtest.h"
9-
8+
#include "UnitTest++.h"
109
#include "CornerPiece.h"
1110
#include "Settlement.h"
1211
#include "City.h"
@@ -15,129 +14,129 @@
1514
#include "Player.h"
1615

1716
//TEST CONSTRUCTORS
18-
TEST(CornerPieceTest, Settlement_constructor){
17+
TEST(Settlement_constructor){
1918
Coordinate loc = Coordinate(0,0);
2019
GameBoard board({"test board"});
2120
Player& test_player = board.getPlayer(0);
2221

2322
Settlement test_cp(board, loc, test_player);
24-
ASSERT_EQ(loc, test_cp.getLocation());
25-
ASSERT_EQ(board, test_cp.getBoard());
26-
ASSERT_EQ(1, test_cp.getVictoryPoints());
23+
CHECK(loc==test_cp.getLocation());
24+
CHECK(board==test_cp.getBoard());
25+
CHECK_EQUAL(1, test_cp.getVictoryPoints());
2726
}
2827

29-
TEST(CornerPieceTest, City_constructor){
28+
TEST(City_constructor){
3029
Coordinate loc = Coordinate(0,0);
3130
GameBoard board({"test board"});
3231
Player& test_player = board.getPlayer(0);
3332

3433
City test_cp(board, loc, test_player);
35-
ASSERT_EQ(loc, test_cp.getLocation());
36-
ASSERT_EQ(board, test_cp.getBoard());
37-
ASSERT_EQ(2, test_cp.getVictoryPoints());
34+
CHECK(loc==test_cp.getLocation());
35+
CHECK(board==test_cp.getBoard());
36+
CHECK_EQUAL(2, test_cp.getVictoryPoints());
3837
}
3938

40-
TEST(CornerPieceTest, Wonder_constructor){
39+
TEST(Wonder_constructor){
4140
Coordinate loc = Coordinate(0,0);
4241
GameBoard board({"test board"});
4342
Player& test_player = board.getPlayer(0);
4443

4544
Wonder test_cp(board, loc, test_player);
46-
ASSERT_EQ(loc, test_cp.getLocation());
47-
ASSERT_EQ(board, test_cp.getBoard());
48-
ASSERT_EQ(10, test_cp.getVictoryPoints());
45+
CHECK(loc==test_cp.getLocation());
46+
CHECK(board==test_cp.getBoard());
47+
CHECK_EQUAL(10, test_cp.getVictoryPoints());
4948
}
5049

51-
TEST(CornerPieceTest, City_upgrade_constructor){
50+
TEST(City_upgrade_constructor){
5251
Coordinate loc = Coordinate(0,0);
5352
GameBoard board({"test board"});
5453
Player& test_player = board.getPlayer(0);
5554

5655
Settlement intermediate_cp(board, loc, test_player);
5756
City test_cp(intermediate_cp);
58-
ASSERT_EQ(loc, test_cp.getLocation());
59-
ASSERT_EQ(board, test_cp.getBoard());
60-
ASSERT_EQ(2, test_cp.getVictoryPoints());
57+
CHECK(loc==test_cp.getLocation());
58+
CHECK(board==test_cp.getBoard());
59+
CHECK_EQUAL(2, test_cp.getVictoryPoints());
6160
}
6261

63-
TEST(CornerPieceTest, Wonder_upgrade_settlement_constructor){
62+
TEST(Wonder_upgrade_settlement_constructor){
6463
Coordinate loc = Coordinate(0,0);
6564
GameBoard board({"test board"});
6665
Player& test_player = board.getPlayer(0);
6766

6867
Settlement intermediate_cp(board, loc, test_player);
6968
Wonder test_cp(intermediate_cp);
70-
ASSERT_EQ(loc, test_cp.getLocation());
71-
ASSERT_EQ(board, test_cp.getBoard());
72-
ASSERT_EQ(10, test_cp.getVictoryPoints());
69+
CHECK(loc==test_cp.getLocation());
70+
CHECK(board==test_cp.getBoard());
71+
CHECK_EQUAL(10, test_cp.getVictoryPoints());
7372
}
7473

75-
TEST(CornerPieceTest, Wonder_upgrade_city_constructor){
74+
TEST(Wonder_upgrade_city_constructor){
7675
Coordinate loc = Coordinate(0,0);
7776
GameBoard board({"test board"});
7877
Player& test_player = board.getPlayer(0);
7978

8079
City intermediate_cp(board, loc, test_player);
8180
Wonder test_cp(intermediate_cp);
82-
ASSERT_EQ(loc, test_cp.getLocation());
83-
ASSERT_EQ(board, test_cp.getBoard());
84-
ASSERT_EQ(10, test_cp.getVictoryPoints());
81+
CHECK(loc==test_cp.getLocation());
82+
CHECK(board==test_cp.getBoard());
83+
CHECK_EQUAL(10, test_cp.getVictoryPoints());
8584
}
8685

8786
//TEST RESOURCE MODIFIERS
88-
TEST(CornerPieceTest, Settlement_Resource_Mod){
87+
TEST(Settlement_Resource_Mod){
8988
Coordinate loc = Coordinate(0,0);
9089
GameBoard board({"test board"});
9190
Player& test_player = board.getPlayer(0);
9291

9392
Settlement test_cp(board, loc, test_player);
94-
ASSERT_EQ(1, test_cp.getResourceModifier());
93+
CHECK_EQUAL(1, test_cp.getResourceModifier());
9594
}
9695

97-
TEST(CornerPieceTest, City_Resource_Mod){
96+
TEST(City_Resource_Mod){
9897
Coordinate loc = Coordinate(0,0);
9998
GameBoard board({"test board"});
10099
Player& test_player = board.getPlayer(0);
101100

102101
City test_cp(board, loc, test_player);
103-
ASSERT_EQ(2, test_cp.getResourceModifier());
102+
CHECK_EQUAL(2, test_cp.getResourceModifier());
104103
}
105104

106-
TEST(CornerPieceTest, Wonder_Resource_Mod){
105+
TEST(Wonder_Resource_Mod){
107106
Coordinate loc = Coordinate(0,0);
108107
GameBoard board({"test board"});
109108
Player& test_player = board.getPlayer(0);
110109

111110
Wonder test_cp(board, loc, test_player);
112-
ASSERT_EQ(10, test_cp.getResourceModifier());
111+
CHECK_EQUAL(10, test_cp.getResourceModifier());
113112
}
114113

115114
//TEST VICTORY POINTS
116-
TEST(CornerPieceTest, Settlement_Victory_Pts){
115+
TEST(Settlement_Victory_Pts){
117116
Coordinate loc = Coordinate(0,0);
118117
GameBoard board({"test board"});
119118
Player& test_player = board.getPlayer(0);
120119

121120
Settlement test_cp(board, loc, test_player);
122-
ASSERT_EQ(1, test_cp.getVictoryPoints());
121+
CHECK_EQUAL(1, test_cp.getVictoryPoints());
123122
}
124123

125-
TEST(CornerPieceTest, City_Victory_Pts){
124+
TEST(City_Victory_Pts){
126125
Coordinate loc = Coordinate(0,0);
127126
GameBoard board({"test board"});
128127
Player& test_player = board.getPlayer(0);
129128

130129
City test_cp(board, loc, test_player);
131-
ASSERT_EQ(2, test_cp.getVictoryPoints());
130+
CHECK_EQUAL(2, test_cp.getVictoryPoints());
132131
}
133132

134-
TEST(CornerPieceTest, Wonder_Victory_Pts){
133+
TEST(Wonder_Victory_Pts){
135134
Coordinate loc = Coordinate(0,0);
136135
GameBoard board({"test board"});
137136
Player& test_player = board.getPlayer(0);
138137

139138
Wonder test_cp(board, loc, test_player);
140-
ASSERT_EQ(10, test_cp.getVictoryPoints());
139+
CHECK_EQUAL(10, test_cp.getVictoryPoints());
141140
}
142141

143142

0 commit comments

Comments
 (0)