GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* The ManaPlus Client |
||
3 |
* Copyright (C) 2016-2019 The ManaPlus Developers |
||
4 |
* Copyright (C) 2019-2021 Andrei Karas |
||
5 |
* |
||
6 |
* This file is part of The ManaPlus Client. |
||
7 |
* |
||
8 |
* This program is free software; you can redistribute it and/or modify |
||
9 |
* it under the terms of the GNU General Public License as published by |
||
10 |
* the Free Software Foundation; either version 2 of the License, or |
||
11 |
* any later version. |
||
12 |
* |
||
13 |
* This program is distributed in the hope that it will be useful, |
||
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 |
* GNU General Public License for more details. |
||
17 |
* |
||
18 |
* You should have received a copy of the GNU General Public License |
||
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
20 |
*/ |
||
21 |
|||
22 |
#include "unittests/unittests.h" |
||
23 |
|||
24 |
#include "configmanager.h" |
||
25 |
#include "dirs.h" |
||
26 |
|||
27 |
#include "resources/image/image.h" |
||
28 |
|||
29 |
#include "resources/map/maplayer.h" |
||
30 |
|||
31 |
#include "debug.h" |
||
32 |
|||
33 |
✓✗ | 6 |
TEST_CASE("MapLayer getEmptyTileDrawWidth", "") |
34 |
{ |
||
35 |
4 |
Dirs::initRootDir(); |
|
36 |
4 |
Dirs::initHomeDir(); |
|
37 |
|||
38 |
4 |
ConfigManager::initConfiguration(); |
|
39 |
|||
40 |
✓✗ | 4 |
Image *const img1 = new Image(32, 32); |
41 |
✓✗ | 4 |
Image *const img2 = new Image(32, 32); |
42 |
✓✗ | 4 |
Image *const img3 = new Image(32, 32); |
43 |
4 |
MapLayer *layer = nullptr; |
|
44 |
int nextTile; |
||
45 |
|||
46 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
28 |
SECTION("simple 2") |
47 |
{ |
||
48 |
1 |
layer = new MapLayer("test", |
|
49 |
0, 0, |
||
50 |
2, 1, |
||
51 |
false, |
||
52 |
0, |
||
53 |
✓✗✓✗ ✓✗ |
3 |
0); |
54 |
2 |
layer->setTile(0, 0, img1); |
|
55 |
1 |
TileInfo *const tiles = layer->getTiles(); |
|
56 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1, |
57 |
1, |
||
58 |
nextTile) == 0); |
||
59 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
60 |
} |
||
61 |
|||
62 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
28 |
SECTION("simple 4") |
63 |
{ |
||
64 |
1 |
layer = new MapLayer("test", |
|
65 |
0, 0, |
||
66 |
3, 1, |
||
67 |
false, |
||
68 |
0, |
||
69 |
✓✗✓✗ ✓✗ |
3 |
0); |
70 |
2 |
layer->setTile(0, 0, img1); |
|
71 |
2 |
layer->setTile(2, 0, img1); |
|
72 |
1 |
TileInfo *const tiles = layer->getTiles(); |
|
73 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1, |
74 |
2, |
||
75 |
nextTile) == 0); |
||
76 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
77 |
} |
||
78 |
|||
79 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
28 |
SECTION("simple 5") |
80 |
{ |
||
81 |
1 |
layer = new MapLayer("test", |
|
82 |
0, 0, |
||
83 |
3, 1, |
||
84 |
false, |
||
85 |
0, |
||
86 |
✓✗✓✗ ✓✗ |
3 |
0); |
87 |
2 |
layer->setTile(0, 0, img1); |
|
88 |
2 |
layer->setTile(1, 0, img1); |
|
89 |
1 |
TileInfo *const tiles = layer->getTiles(); |
|
90 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 2, |
91 |
1, |
||
92 |
nextTile) == 0); |
||
93 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
94 |
} |
||
95 |
|||
96 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
28 |
SECTION("normal 1") |
97 |
{ |
||
98 |
1 |
layer = new MapLayer("test", |
|
99 |
0, 0, |
||
100 |
100, 100, |
||
101 |
false, |
||
102 |
0, |
||
103 |
✓✗✓✗ ✓✗ |
3 |
0); |
104 |
2 |
layer->setTile(1, 10, img1); |
|
105 |
2 |
layer->setTile(2, 10, img1); |
|
106 |
2 |
layer->setTile(3, 10, img1); |
|
107 |
2 |
layer->setTile(4, 10, img2); |
|
108 |
2 |
layer->setTile(5, 10, nullptr); |
|
109 |
2 |
layer->setTile(6, 10, img2); |
|
110 |
2 |
layer->setTile(7, 10, nullptr); |
|
111 |
2 |
layer->setTile(8, 10, nullptr); |
|
112 |
2 |
layer->setTile(9, 10, img2); |
|
113 |
2 |
layer->setTile(10, 10, img2); |
|
114 |
2 |
layer->setTile(11, 10, img3); |
|
115 |
2 |
layer->setTile(12, 10, nullptr); |
|
116 |
2 |
layer->setTile(13, 10, nullptr); |
|
117 |
2 |
layer->setTile(14, 10, nullptr); |
|
118 |
2 |
layer->setTile(15, 10, img1); |
|
119 |
2 |
layer->setTile(16, 10, img1); |
|
120 |
2 |
layer->setTile(17, 10, img1); |
|
121 |
1 |
TileInfo *const tiles = layer->getTiles(); |
|
122 |
|||
123 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 0, |
124 |
100 - 0, |
||
125 |
nextTile) == 0); |
||
126 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
127 |
|||
128 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 5, |
129 |
100 - 5, |
||
130 |
nextTile) == 0); |
||
131 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
132 |
|||
133 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 7, |
134 |
100 - 7, |
||
135 |
nextTile) == 1); |
||
136 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 1); |
137 |
|||
138 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 8, |
139 |
100 - 8, |
||
140 |
nextTile) == 0); |
||
141 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
142 |
|||
143 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 12, |
144 |
100 - 12, |
||
145 |
nextTile) == 2); |
||
146 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 2); |
147 |
|||
148 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 13, |
149 |
100 - 13, |
||
150 |
nextTile) == 1); |
||
151 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 1); |
152 |
|||
153 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 14, |
154 |
100 - 14, |
||
155 |
nextTile) == 0); |
||
156 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(nextTile == 0); |
157 |
} |
||
158 |
|||
159 |
✓✗ | 4 |
delete layer; |
160 |
✓✗ | 4 |
delete img1; |
161 |
✓✗ | 4 |
delete img2; |
162 |
✓✗ | 4 |
delete img3; |
163 |
✓✗✓✗ |
7 |
} |
Generated by: GCOVR (Version 3.3) |