Coverage report for gui


src/
File: src/parser/Map.cpp
Date: 2024-06-25 10:57:02
Lines:
19/22
86.4%
Functions:
3/4
75.0%
Branches:
20/28
71.4%

Line Branch Exec Source
1 #include "Map.hpp"
2 #include "../utils/GuiException.hpp"
3
4
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
18 std::vector<int> Map::getSize()
5 {
6
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
18 if (this->map.size() == 0) {
7 3 return {0, 0};
8 }
9 15 int x = static_cast<int>(this->map.size());
10 15 int y = static_cast<int>(this->map.at(0).size());
11 15 std::vector<int> size = {x, y};
12
13 return size;
14 }
15
16 7 void Map::updateTile(int x, int y, std::vector<int> values)
17 {
18
8/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 2 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 1 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
12 if (x >= static_cast<int>(this->getSize()[0]) || y >= static_cast<int>(this->getSize()[1])) {
19
2/4
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
6 throw guiException("Invalid tile position");
20 }
21 4 map[x][y].setRessources(values);
22 4 }
23
24
25 10 void Map::fillMap(int x, int y)
26 {
27
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 10 times.
72 for (; x > 0; x--) {
28 62 std::vector<Tile> row;
29
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 62 times.
516 for (int i = 0;i < y; i++) {
30
1/2
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
908 row.push_back(Tile(x, y));
31 }
32
1/2
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
62 this->map.push_back(row);
33 62 }
34 10 }
35
36 void Map::resetMap()
37 {
38 this->map.clear();
39 }
40