-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertTests.cpp
More file actions
69 lines (61 loc) · 1.88 KB
/
AssertTests.cpp
File metadata and controls
69 lines (61 loc) · 1.88 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
//
// Created by vb-jakub on 25.06.24.
//
#include "AssertTests.h"
#include "Player.h"
#include "Board.h"
#include <cassert>
void AssertTests::playTests() const {
playerTests();
boardTests();
}
void AssertTests::playerTests() const {
Player player(DEBUG);
assert(player.getGameMode()==DEBUG);
assert(player.getPlayerSide()==RIGHT);
player.turn(LEFT);
assert(player.getPlayerSide()==LEFT);
player.turn(RIGHT);
assert(player.getPlayerSide()==RIGHT);
assert(player.getScore()==0);
player.addPoint();
assert(player.getScore()==1);
}
void AssertTests::boardTests() const {
Player player(DEBUG);
Board board(player,12);
assert(board.getGameState()==RUNNING);
assert(board.getTimeToMove()==8);
assert(board.getTreeHeight()==12);
assert(board.getBranchSide(0)==NONE);
assert(board.getBranchSide(1)==RIGHT);
player.turn(LEFT);
board.update();
assert(board.getBranchSide(0)==RIGHT);
assert(player.getScore()==1);
assert(board.getGameState()==RUNNING);
for(int counter=0; counter<9; ++counter)
board.update();
assert(player.getScore()==10);
assert(board.getTimeToMove()==8.0f*0.9f);
//finish game by move to tree side with branch
player.turn(RIGHT);
board.update();
assert(player.getPlayerSide()==RIGHT);
assert(board.getBranchSide(0)==RIGHT);
assert(board.getGameState()==FINISHED);
//finish game by being smashed by a branch
player.turn(RIGHT);
Board board2(player,3);
board2.update();
assert(player.getPlayerSide()==RIGHT);
assert(board2.getBranchSide(0)==RIGHT);
assert(board2.getGameState()==FINISHED);
//finish game by the end of time
player.turn(RIGHT);
Board board3(player,5);
board3.checkTimeRemaining(1);
assert(board3.getGameState()==RUNNING);
board3.checkTimeRemaining(10);
assert(board3.getGameState()==FINISHED);
}