Skip to content

Commit 0aee6e0

Browse files
committed
Replaced dynamic allocation in tests with static allocation
1 parent 4fd81e5 commit 0aee6e0

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/test_GameBoard.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,25 @@
1010

1111

1212
TEST(saveFile_simple){
13-
GameBoard * test_board = new GameBoard;
14-
CHECK(test_board->save_Board("test_1") == 0);
15-
delete(test_board);
13+
GameBoard test_board;
14+
CHECK(test_board.save_Board("test_1") == 0);
1615
}
1716

1817
TEST(loadFile_simple){
19-
GameBoard * test_board = new GameBoard;
20-
CHECK(test_board->load_Board("test_1") == 0);
21-
delete(test_board);
18+
GameBoard test_board;
19+
CHECK(test_board.load_Board("test_1") == 0);
2220
}
2321

2422
TEST(randomize_rolls_fail)
2523
{
26-
GameBoard * test_board = new GameBoard;
24+
GameBoard test_board;
2725
int badRolls[] = {0, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12};
28-
CHECK(test_board->testRollChecking(badRolls) == false);
29-
delete(test_board);
26+
CHECK(test_board.testRollChecking(badRolls) == false);
3027
}
3128

3229
TEST(randomize_rolls_pass)
3330
{
34-
GameBoard * test_board = new GameBoard;
31+
GameBoard test_board;
3532
int goodRolls[] = {9, 11, 5, 4, 0, 3, 4, 2, 10, 8, 3, 6, 9, 11, 5, 10, 6, 12, 8};
36-
CHECK(test_board->testRollChecking(goodRolls) == true);
37-
delete(test_board);
33+
CHECK(test_board.testRollChecking(goodRolls) == true);
3834
}

0 commit comments

Comments
 (0)