-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
121 lines (108 loc) · 2.59 KB
/
Copy pathtest.cpp
File metadata and controls
121 lines (108 loc) · 2.59 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
#define DOCTEST_CONFIG_IMPLEMENT
#include <chrono>
#include <time.h>
#include <thread>
#include "doctest.h"
#include "coord.hpp"
#include "jeu.hpp"
#include "animal.hpp"
#include "population.hpp"
#include "grille.hpp"
TEST_CASE("Coord test")
{
Coord c1{5,6};
Coord c2{5,5};
Coord c3{5,5};
Coord c4{19,19};
Coord c5{390};
CHECK(c1 != c2);
CHECK(c3 == c2);
CHECK(c4.toInt() == 969);
CHECK(c5 == *(new Coord{7,40}) );
}
void voisin_vide_affichage()
{
Jeu j {};
Coord c1{5,6};
vector<Coord> helper = j.voisinsVides(c1);
for(int i = 0; i < helper.size(); i++)
{
cout << helper[i];
}
}
void animal_testing()
{
Animal a{20, Espece::lapin, *(new Coord{10,11})};
cout << a.getId() << endl;
cout << a.getCoord().getCol() << " " << a.getCoord().getLin() << endl;
cout << a.toString() << endl;
}
/*
//No longer work, need to set jPop in Jeu.hpp and pop in population.hpp to public for testing
void jeu_deplacement_testing()
{
Jeu j{};
for(int i = 0; i < 10; i++)
{
cout << j.jPop.pop[i].getCoord() << endl;
}
for(int i = 0; i < TAILLEGRILLE*TAILLEGRILLE; i++)
{
Animal a = j.jPop.getIndex(i);
if(a.getEspece() != Espece::rien)
{
Coord c = a.getCoord();
int id = a.getId();
vector<Coord> videc = j.voisinsVides(c);
int choix = rand() % videc.size();
Coord newc = videc[choix];
j.jPop.changeCoord(id, newc);
}
}
cout << endl << endl;
for(int i = 0; i < 10; i++)
{
cout << j.jPop.pop[i].getCoord() << endl;
}
for(int i = 0; i < 10; i++)
{
cout << j.jGri.printCase(* (new Coord{0, i}) ) <<" ";
}
cout << endl;
j.jGri = *(new Grille{});
for(int i = 0; i < TAILLEGRILLE*TAILLEGRILLE; i++)
{
Animal a = j.jPop.getIndex(i);
if(a.getEspece() != Espece::rien)
{
Coord c = a.getCoord();
j.jGri.setCase(a.getId(), a.getEspece(), c);
}
}
cout << endl;
for(int i = 0; i < 10; i++)
{
cout << j.jGri.printCase(* (new Coord{0, i}) ) <<" ";
}
cout << endl;
}
*/
void jeu_basic_testing() {
Jeu j{};
while(j.verifieGrille())
{
system("cls");
j.affiche();
chrono::seconds dura(1);
this_thread::sleep_for( dura );
j.deplace();
}
}
int main(int argc, const char **argv)
{
doctest::Context context(argc, argv);
int test_result = context.run();
if (context.shouldExit()) return test_result;
//jeu_basic_testing();
return 0;
}