-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cpp
More file actions
79 lines (61 loc) · 1.61 KB
/
Test.cpp
File metadata and controls
79 lines (61 loc) · 1.61 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
#include "sources/player.hpp"
#include "sources/game.hpp"
#include "sources/card.hpp"
#include "doctest.h"
#include <iostream>
#include <string>
using namespace ariel;
using namespace std;
TEST_CASE("Initial game"){
Player p1("Alice");
Player p2("Bob");
Game game(p1,p2);
CHECK(p1.stacksize()==26);
CHECK(p2.stacksize()==26);
CHECK(p1.cardesTaken()==0);
CHECK(p2.cardesTaken()==0);
}
TEST_CASE("Playing game"){
Player p1("Alice");
Player p2("Bob");
Game game(p1,p2);
game.playAll();
CHECK(p1.stacksize()==0);
CHECK(p2.stacksize()==0);
CHECK(p1.cardesTaken()+p2.cardesTaken()==52);
}
TEST_CASE("Checking that there are always 52 cards"){
Player p1("Alice");
Player p2("Bob");
Game game(p1,p2);
for(int i=0;i<5;i++){
game.playTurn();
CHECK(p1.stacksize()+p1.cardesTaken()+p2.stacksize()+p2.cardesTaken()==52);
}
}
TEST_CASE("Check the functions no throw exception"){
Player p1("Alice");
Player p2("Bob");
Game game(p1,p2);
CHECK_NOTHROW(game.printWiner());
CHECK_NOTHROW(game.printStats());
CHECK_NOTHROW(game.printLog());
CHECK_NOTHROW(game.printLastTurn());
}
TEST_CASE ("Check the players that created are the players that play"){
Player p1("Alice");
Player p2("Bob");
Game game(p1,p2);
CHECK(game.p1.name == "Alice");
CHECK(game.p2.name == "Bob");
}
TEST_CASE("Check there is no errors at the middle of the game"){
Player p1("Alice");
Player p2("Bob");
Game game(p1, p2);
int i=0;
while(i< 5&& p2.stacksize()>0 && p1.stacksize()>0){
CHECK_NOTHROW(game.playTurn());
i++;
}
}