GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/gui/fonts/textchunklist.cc Lines: 352 352 100.0 %
Date: 2021-03-17 Branches: 995 2578 38.6 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2013-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 "gui/fonts/font.h"
25
#include "gui/fonts/textchunk.h"
26
27
#include "debug.h"
28
29
✓✗
3
TEST_CASE("TextChunkList empty", "TextChunkList")
30
{
31
2
    TextChunkList list;
32
33
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
34
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
35
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
36
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
37
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
38
1
}
39
40
✓✗
3
TEST_CASE("TextChunkList add 1", "TextChunkList")
41
{
42
2
    TextChunkList list;
43
44
    TextChunk *const chunk = new TextChunk("test",
45
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 3, 4, 255U), nullptr);
46
47
✓✗
1
    list.insertFirst(chunk);
48
49
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(1 == list.size);
50
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk == list.start);
51
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk == list.end);
52
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk->prev);
53
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk->next);
54
55
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.search.size());
56
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
7
    REQUIRE(chunk == (*list.search.find(TextChunkSmall(
57
        chunk->text, chunk->color, chunk->color2))).second);
58
59
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.searchWidth.size());
60
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
6
    REQUIRE(chunk == (*list.searchWidth.find(chunk->text)).second);
61
✓✗
1
    delete chunk;
62
1
}
63
64
✓✗
3
TEST_CASE("TextChunkList add 2", "TextChunkList")
65
{
66
2
    TextChunkList list;
67
68
    TextChunk *const chunk1 = new TextChunk("test",
69
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(3, 4, 5, 255U), nullptr);
70
    TextChunk *const chunk2 = new TextChunk("test",
71
✓✗✓✗
✓✗
6
        Color(2, 3, 4, 255U), Color(4, 5, 6, 255U), nullptr);
72
73
✓✗
1
    list.insertFirst(chunk2);
74
✓✗
1
    list.insertFirst(chunk1);
75
76
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(2 == list.size);
77
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
78
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == list.end);
79
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
80
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk1->next);
81
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == chunk2->prev);
82
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk2->next);
83
84
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.search.size());
85
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
7
    REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
86
        chunk1->text, chunk1->color, chunk1->color2))).second);
87
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
7
    REQUIRE(chunk2 == (*list.search.find(TextChunkSmall(
88
        chunk2->text, chunk2->color, chunk2->color2))).second);
89
90
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.searchWidth.size());
91
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
6
    REQUIRE(chunk1 == (*list.searchWidth.find(chunk1->text)).second);
92
✓✗
1
    delete chunk1;
93
✓✗
1
    delete chunk2;
94
1
}
95
96
✓✗
3
TEST_CASE("TextChunkList addRemoveBack 1", "TextChunkList")
97
{
98
2
    TextChunkList list;
99
100
    TextChunk *const chunk = new TextChunk("test",
101
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
102
103
✓✗
1
    list.insertFirst(chunk);
104
✓✗
1
    list.removeBack();
105
106
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
107
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
108
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
109
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
110
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
111
1
}
112
113
✓✗
3
TEST_CASE("TextChunkList addRemoveBack 2", "TextChunkList")
114
{
115
2
    TextChunkList list;
116
117
    TextChunk *const chunk1 = new TextChunk("test",
118
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
119
    TextChunk *const chunk2 = new TextChunk("test2",
120
✓✗✓✗
✓✗
6
        Color(1, 2, 4, 255U), Color(1, 2, 5, 255U), nullptr);
121
122
✓✗
1
    list.insertFirst(chunk2);
123
✓✗
1
    list.insertFirst(chunk1);
124
✓✗
1
    list.removeBack();
125
126
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(1 == list.size);
127
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
128
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.end);
129
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
130
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->next);
131
132
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.search.size());
133
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
7
    REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
134
        chunk1->text, chunk1->color, chunk1->color2))).second);
135
136
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.searchWidth.size());
137
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
6
    REQUIRE(chunk1 == (*list.searchWidth.find(chunk1->text)).second);
138
✓✗
1
    delete chunk1;
139
1
}
140
141
✓✗
3
TEST_CASE("TextChunkList addRemoveBack 3", "TextChunkList")
142
{
143
2
    TextChunkList list;
144
145
    TextChunk *const chunk1 = new TextChunk("test",
146
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
147
    TextChunk *const chunk2 = new TextChunk("test2",
148
✓✗✓✗
✓✗
6
        Color(2, 3, 4, 255U), Color(2, 3, 4, 255U), nullptr);
149
150
✓✗
1
    list.insertFirst(chunk2);
151
✓✗
1
    list.insertFirst(chunk1);
152
✓✗
1
    list.removeBack(2);
153
154
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
155
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
156
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
157
158
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
159
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
160
1
}
161
162
✓✗
3
TEST_CASE("TextChunkList addRemoveBack 4", "TextChunkList")
163
{
164
2
    TextChunkList list;
165
166
    TextChunk *const chunk1 = new TextChunk("test",
167
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
168
    TextChunk *const chunk2 = new TextChunk("test2",
169
✓✗✓✗
✓✗
6
        Color(2, 3, 4, 255U), Color(2, 3, 4, 255U), nullptr);
170
    TextChunk *const chunk3 = new TextChunk("test",
171
✓✗✓✗
✓✗
6
        Color(3, 4, 5, 255U), Color(3, 4, 5, 255U), nullptr);
172
173
✓✗
1
    list.insertFirst(chunk3);
174
✓✗
1
    list.insertFirst(chunk2);
175
✓✗
1
    list.insertFirst(chunk1);
176
✓✗
1
    list.removeBack();
177
✓✗
1
    list.removeBack();
178
179
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(1 == list.size);
180
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
181
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.end);
182
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
183
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->next);
184
185
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.search.size());
186
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
7
    REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
187
        chunk1->text, chunk1->color, chunk1->color2))).second);
188
189
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
190
✓✗
1
    delete chunk1;
191
1
}
192
193
✓✗
3
TEST_CASE("TextChunkList moveToFirst 1", "TextChunkList")
194
{
195
2
    TextChunkList list;
196
197
    TextChunk *const chunk = new TextChunk("test",
198
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 3, 4, 255U), nullptr);
199
200
✓✗
1
    list.insertFirst(chunk);
201
✓✗
1
    list.moveToFirst(chunk);
202
203
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(1 == list.size);
204
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk == list.start);
205
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk == list.end);
206
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk->prev);
207
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk->next);
208
✓✗
1
    delete chunk;
209
1
}
210
211
✓✗
3
TEST_CASE("TextChunkList moveToFirst 2", "TextChunkList")
212
{
213
2
    TextChunkList list;
214
215
    TextChunk *const chunk1 = new TextChunk("test",
216
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
217
    TextChunk *const chunk2 = new TextChunk("test",
218
✓✗✓✗
✓✗
6
        Color(2, 3, 4, 255U), Color(1, 2, 3, 255U), nullptr);
219
220
✓✗
1
    list.insertFirst(chunk1);
221
✓✗
1
    list.insertFirst(chunk2);
222
✓✗
1
    list.moveToFirst(chunk1);
223
224
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(2 == list.size);
225
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
226
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == list.end);
227
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
228
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk1->next);
229
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == chunk2->prev);
230
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk2->next);
231
✓✗
1
    delete chunk1;
232
✓✗
1
    delete chunk2;
233
1
}
234
235
✓✗
3
TEST_CASE("TextChunkList moveToFirst 3", "TextChunkList")
236
{
237
2
    TextChunkList list;
238
239
    TextChunk *const chunk1 = new TextChunk("test",
240
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U), nullptr);
241
    TextChunk *const chunk2 = new TextChunk("test",
242
✓✗✓✗
✓✗
6
        Color(1, 2, 4, 255U), Color(1, 2, 3, 255U), nullptr);
243
    TextChunk *const chunk3 = new TextChunk("test",
244
✓✗✓✗
✓✗
6
        Color(1, 2, 5, 255U), Color(1, 2, 3, 255U), nullptr);
245
246
✓✗
1
    list.insertFirst(chunk3);
247
✓✗
1
    list.insertFirst(chunk1);
248
✓✗
1
    list.insertFirst(chunk2);
249
✓✗
1
    list.moveToFirst(chunk1);
250
251
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(3 == list.size);
252
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
253
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == list.end);
254
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
255
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk1->next);
256
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == chunk2->prev);
257
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == chunk2->next);
258
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk3->prev);
259
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk3->next);
260
✓✗
1
    delete chunk1;
261
✓✗
1
    delete chunk2;
262
✓✗
1
    delete chunk3;
263
1
}
264
265
✓✗
3
TEST_CASE("TextChunkList moveToFirst 4", "TextChunkList")
266
{
267
2
    TextChunkList list;
268
269
    TextChunk *const chunk1 = new TextChunk("test",
270
✓✗✓✗
✓✗
6
        Color(), Color(), nullptr);
271
    TextChunk *const chunk2 = new TextChunk("test2",
272
✓✗✓✗
✓✗
6
        Color(), Color(), nullptr);
273
    TextChunk *const chunk3 = new TextChunk("test3",
274
✓✗✓✗
✓✗
6
        Color(), Color(), nullptr);
275
276
✓✗
1
    list.insertFirst(chunk1);
277
✓✗
1
    list.insertFirst(chunk3);
278
✓✗
1
    list.insertFirst(chunk2);
279
✓✗
1
    list.moveToFirst(chunk1);
280
281
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(3 == list.size);
282
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.start);
283
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == list.end);
284
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk1->prev);
285
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk1->next);
286
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == chunk2->prev);
287
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == chunk2->next);
288
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == chunk3->prev);
289
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == chunk3->next);
290
✓✗
1
    delete chunk1;
291
✓✗
1
    delete chunk2;
292
✓✗
1
    delete chunk3;
293
1
}
294
295
✓✗
3
TEST_CASE("TextChunkList clear 1", "TextChunkList")
296
{
297
2
    TextChunkList list;
298
1
    const int chunksLeft = textChunkCnt;
299
300
    TextChunk *const chunk = new TextChunk("test",
301
✓✗✓✗
✓✗
6
        Color(), Color(), nullptr);
302
303
✓✗
1
    list.insertFirst(chunk);
304
✓✗
1
    list.clear();
305
306
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
307
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
308
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
309
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunksLeft == textChunkCnt);
310
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
311
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
312
1
}
313
314
✓✗
3
TEST_CASE("TextChunkList clear 2", "TextChunkList")
315
{
316
2
    TextChunkList list;
317
1
    const int chunksLeft = textChunkCnt;
318
319
    TextChunk *const chunk1 = new TextChunk("test",
320
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 0, 255U), nullptr);
321
    TextChunk *const chunk2 = new TextChunk("test",
322
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 1, 255U), nullptr);
323
    TextChunk *const chunk3 = new TextChunk("test",
324
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 2, 255U), nullptr);
325
326
✓✗
1
    list.insertFirst(chunk1);
327
✓✗
1
    list.insertFirst(chunk2);
328
✓✗
1
    list.insertFirst(chunk3);
329
✓✗
1
    list.clear();
330
331
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
332
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
333
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
334
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunksLeft == textChunkCnt);
335
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
336
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
337
1
}
338
339
✓✗
3
TEST_CASE("TextChunkList clear 3", "TextChunkList")
340
{
341
2
    TextChunkList list;
342
1
    const int chunksLeft = textChunkCnt;
343
344
    TextChunk *const chunk1 = new TextChunk("test",
345
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 0, 255U), nullptr);
346
    TextChunk *const chunk2 = new TextChunk("test",
347
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 1, 255U), nullptr);
348
    TextChunk *const chunk3 = new TextChunk("test",
349
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 2, 255U), nullptr);
350
351
✓✗
1
    list.insertFirst(chunk1);
352
✓✗
1
    list.insertFirst(chunk2);
353
✓✗
1
    list.insertFirst(chunk3);
354
✓✗
1
    list.moveToFirst(chunk1);
355
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 3) == textChunkCnt);
356
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(3 == list.search.size());
357
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.searchWidth.size());
358
359
✓✗
1
    list.removeBack();
360
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 2) == textChunkCnt);
361
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.search.size());
362
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
363
364
✓✗
1
    list.clear();
365
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunksLeft == textChunkCnt);
366
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
367
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
368
1
}
369
370
✓✗
3
TEST_CASE("TextChunkList clear 4", "TextChunkList")
371
{
372
2
    TextChunkList list;
373
1
    const int chunksLeft = textChunkCnt;
374
375
    TextChunk *const chunk1 = new TextChunk("test",
376
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 0, 255U), nullptr);
377
    TextChunk *const chunk2 = new TextChunk("test",
378
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 1, 255U), nullptr);
379
    TextChunk *const chunk3 = new TextChunk("test3",
380
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 2, 255U), nullptr);
381
382
✓✗
1
    list.insertFirst(chunk1);
383
✓✗
1
    list.insertFirst(chunk2);
384
✓✗
1
    list.insertFirst(chunk3);
385
✓✗
1
    list.moveToFirst(chunk2);
386
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 3) == textChunkCnt);
387
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(3 == list.search.size());
388
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.searchWidth.size());
389
390
✓✗
1
    list.removeBack(2);
391
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 1) == textChunkCnt);
392
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(1 == list.search.size());
393
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
394
395
✓✗
1
    list.clear();
396
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunksLeft == textChunkCnt);
397
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
398
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
399
1
}
400
401
✓✗
3
TEST_CASE("TextChunkList remove 1", "TextChunkList")
402
{
403
2
    TextChunkList list;
404
1
    const int chunksLeft = textChunkCnt;
405
406
    TextChunk *const chunk = new TextChunk("test",
407
✓✗✓✗
✓✗
6
        Color(), Color(), nullptr);
408
409
✓✗
1
    list.insertFirst(chunk);
410
✓✗
1
    list.remove(chunk);
411
✓✗
1
    delete chunk;
412
413
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(0 == list.size);
414
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.start);
415
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(nullptr == list.end);
416
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunksLeft == textChunkCnt);
417
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.search.empty());
418
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(list.searchWidth.empty());
419
1
}
420
421
✓✗
3
TEST_CASE("TextChunkList remove 2", "TextChunkList")
422
{
423
2
    TextChunkList list;
424
1
    const int chunksLeft = textChunkCnt;
425
426
    TextChunk *const chunk1 = new TextChunk("test1",
427
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 0, 255U), nullptr);
428
    TextChunk *const chunk2 = new TextChunk("test2",
429
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 1, 255U), nullptr);
430
    TextChunk *const chunk3 = new TextChunk("test3",
431
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 2, 255U), nullptr);
432
433
✓✗
1
    list.insertFirst(chunk1);
434
✓✗
1
    list.insertFirst(chunk2);
435
✓✗
1
    list.insertFirst(chunk3);
436
✓✗
1
    list.remove(chunk1);
437
✓✗
1
    delete chunk1;
438
439
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(2 == list.size);
440
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == list.start);
441
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk2 == list.end);
442
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 2) == textChunkCnt);
443
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.search.size());
444
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.searchWidth.size());
445
✓✗
1
    delete chunk2;
446
✓✗
1
    delete chunk3;
447
1
}
448
449
✓✗
3
TEST_CASE("TextChunkList remove 3", "TextChunkList")
450
{
451
2
    TextChunkList list;
452
1
    const int chunksLeft = textChunkCnt;
453
454
    TextChunk *const chunk1 = new TextChunk("test1",
455
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 0, 255U), nullptr);
456
    TextChunk *const chunk2 = new TextChunk("test2",
457
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 1, 255U), nullptr);
458
    TextChunk *const chunk3 = new TextChunk("test3",
459
✓✗✓✗
✓✗
6
        Color(1, 2, 3, 255U), Color(2, 0, 2, 255U), nullptr);
460
461
✓✗
1
    list.insertFirst(chunk1);
462
✓✗
1
    list.insertFirst(chunk2);
463
✓✗
1
    list.insertFirst(chunk3);
464
✓✗
1
    list.remove(chunk2);
465
✓✗
1
    delete chunk2;
466
467
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(2 == list.size);
468
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk3 == list.start);
469
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(chunk1 == list.end);
470
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE((chunksLeft + 2) == textChunkCnt);
471
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.search.size());
472
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
5
    REQUIRE(2 == list.searchWidth.size());
473
✓✗
1
    delete chunk1;
474
✓✗
1
    delete chunk3;
475
1
}
476
477
✓✗
3
TEST_CASE("TextChunkList sort 1", "TextChunkList")
478
{
479
    TextChunkSmall item1("test line1",
480
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
481
    TextChunkSmall item2("test line1",
482
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
483
    TextChunkSmall item3("test line2",
484
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
485
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item1 < item2));
486
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
487
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item3);
488
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item3 < item1));
489
1
}
490
491
✓✗
3
TEST_CASE("TextChunkList sort 2", "TextChunkList")
492
{
493
    TextChunkSmall item1("test line1",
494
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
495
    TextChunkSmall item2("test line1",
496
✓✗✓✗
6
        Color(2, 3, 4, 255U), Color(1, 2, 3, 255U));
497
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
498
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
499
1
}
500
501
✓✗
3
TEST_CASE("TextChunkList sort 3", "TextChunkList")
502
{
503
    TextChunkSmall item1("test line1",
504
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
505
    TextChunkSmall item2("test line1",
506
✓✗✓✗
6
        Color(1, 3, 4, 255U), Color(1, 2, 3, 255U));
507
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
508
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
509
1
}
510
511
✓✗
3
TEST_CASE("TextChunkList sort 4", "TextChunkList")
512
{
513
    TextChunkSmall item1("test line1",
514
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
515
    TextChunkSmall item2("test line1",
516
✓✗✓✗
6
        Color(1, 2, 4, 255U), Color(1, 2, 3, 255U));
517
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
518
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
519
1
}
520
521
✓✗
3
TEST_CASE("TextChunkList sort 5", "TextChunkList")
522
{
523
    TextChunkSmall item1("test line1",
524
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
525
    TextChunkSmall item2("test line1",
526
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(2, 2, 3, 255U));
527
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
528
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
529
1
}
530
531
✓✗
3
TEST_CASE("TextChunkList sort 6", "TextChunkList")
532
{
533
    TextChunkSmall item1("test line1",
534
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
535
    TextChunkSmall item2("test line1",
536
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 3, 3, 255U));
537
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
538
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
539
1
}
540
541
✓✗
3
TEST_CASE("TextChunkList sort 7", "TextChunkList")
542
{
543
    TextChunkSmall item1("test line1",
544
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 3, 255U));
545
    TextChunkSmall item2("test line1",
546
✓✗✓✗
6
        Color(1, 2, 3, 255U), Color(1, 2, 4, 255U));
547
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
    REQUIRE(item1 < item2);
548
✓✗✓✗
✓✗✓✗
✓✗✓✗
✗✗✗✗
4
    REQUIRE(false == (item2 < item1));
549
✓✗✓✗
4
}