GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/resources/sdlimagehelper.cc Lines: 339 339 100.0 %
Date: 2021-03-17 Branches: 578 1458 39.6 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2014-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
#ifndef USE_SDL2
23
#include "localconsts.h"
24
PRAGMA48(GCC diagnostic push)
25
PRAGMA48(GCC diagnostic ignored "-Wshadow")
26
#include <SDL_endian.h>
27
PRAGMA48(GCC diagnostic pop)
28
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
29
30
#include "unittests/unittests.h"
31
32
#include "client.h"
33
#include "configmanager.h"
34
#include "configuration.h"
35
#include "dirs.h"
36
#include "graphicsmanager.h"
37
38
#include "being/actorsprite.h"
39
40
#include "fs/virtfs/fs.h"
41
42
#include "gui/userpalette.h"
43
#include "gui/theme.h"
44
45
#include "utils/delete2.h"
46
#include "utils/env.h"
47
48
#include "render/sdlgraphics.h"
49
50
#include "resources/sdlimagehelper.h"
51
52
#include "debug.h"
53
54
static SDL_Surface *createSoftware32BitSurface(int width,
55
                                               int height)
56
{
57
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
58
    const int rmask = 0xff000000;
59
    const int gmask = 0x00ff0000;
60
    const int bmask = 0x0000ff00;
61
    const int amask = 0x000000ff;
62
#else  // SDL_BYTEORDER == SDL_BIG_ENDIAN
63
64
22
    const int rmask = 0x000000ff;
65
22
    const int gmask = 0x0000ff00;
66
22
    const int bmask = 0x00ff0000;
67
22
    const int amask = 0xff000000;
68
#endif  // SDL_BYTEORDER == SDL_BIG_ENDIAN
69
70
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
✓✗✓✗
22
    return MSDL_CreateRGBSurface(SDL_SWSURFACE,
71
        width, height, 32, rmask, gmask, bmask, amask);
72
}
73
74
✓✗
13
TEST_CASE("sdlimagehelper combineSurface", "")
75
{
76
11
    setEnv("SDL_VIDEODRIVER", "dummy");
77
78
✓✗
11
    client = new Client;
79
✓✗
33
    VirtFs::mountDirSilent("data", Append_false);
80
✓✗
33
    VirtFs::mountDirSilent("../data", Append_false);
81
82
✓✗
11
    mainGraphics = new SDLGraphics;
83
22
    imageHelper = new SDLImageHelper;
84
85
11
    Dirs::initRootDir();
86
11
    Dirs::initHomeDir();
87
88
11
    setBrandingDefaults(branding);
89
11
    ConfigManager::initConfiguration();
90
91
11
    GraphicsManager::createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
92
93
✓✗
11
    userPalette = new UserPalette;
94
95
✓✗
11
    theme = new Theme;
96
11
    Theme::selectSkin();
97
98
11
    ActorSprite::load();
99
100
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy1")
101
    {
102
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
103
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
104
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
105
4
            ptr1[f] = 0xff000000;
106
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
107
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
108
109
1
        ptr2[0] = 0xff000000;
110
1
        ptr2[1] = 0x00ff0000;
111
1
        ptr2[2] = 0x0000ff00;
112
1
        ptr2[3] = 0x000000ff;
113
114
        SDLImageHelper::combineSurface(surface2,
115
            nullptr,
116
            surface1,
117
✓✗
1
            nullptr);
118
119
        // src image test
120
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr2[0] == 0xff000000);
121
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr2[1] == 0x00ff0000);
122
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr2[2] == 0x0000ff00);
123
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr2[3] == 0x000000ff);
124
125
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0xff000000);
126
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xff000000);
127
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xff000000);
128
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xff000000);
129
✓✗
1
        MSDL_FreeSurface(surface1);
130
✓✗
1
        MSDL_FreeSurface(surface2);
131
    }
132
133
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy2")
134
    {
135
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
136
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
137
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
138
4
            ptr1[f] = 0xff000000;
139
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
140
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
141
142
1
        ptr2[0] = 0xff112233;
143
1
        ptr2[1] = 0xff003344;
144
1
        ptr2[2] = 0xff330055;
145
1
        ptr2[3] = 0xff445500;
146
147
        SDLImageHelper::combineSurface(surface2,
148
            nullptr,
149
            surface1,
150
✓✗
1
            nullptr);
151
152
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0xff112233);
153
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xff003344);
154
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xff330055);
155
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xff445500);
156
✓✗
1
        MSDL_FreeSurface(surface1);
157
✓✗
1
        MSDL_FreeSurface(surface2);
158
    }
159
160
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy3")
161
    {
162
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
163
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
164
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
165
4
            ptr1[f] = 0x00000000;
166
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
167
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
168
169
1
        ptr2[0] = 0xff112233;
170
1
        ptr2[1] = 0xff003344;
171
1
        ptr2[2] = 0xff330055;
172
1
        ptr2[3] = 0xff445500;
173
174
        SDLImageHelper::combineSurface(surface2,
175
            nullptr,
176
            surface1,
177
✓✗
1
            nullptr);
178
179
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0xff112233);
180
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xff003344);
181
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xff330055);
182
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xff445500);
183
✓✗
1
        MSDL_FreeSurface(surface1);
184
✓✗
1
        MSDL_FreeSurface(surface2);
185
    }
186
187
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy4")
188
    {
189
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
190
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
191
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
192
4
            ptr1[f] = 0xff000000;
193
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
194
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
195
196
1
        ptr2[0] = 0x50112233;
197
1
        ptr2[1] = 0x50003344;
198
1
        ptr2[2] = 0x50330055;
199
1
        ptr2[3] = 0x50445500;
200
201
        SDLImageHelper::combineSurface(surface2,
202
            nullptr,
203
            surface1,
204
✓✗
1
            nullptr);
205
206
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0xff09121c);
207
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xff001c25);
208
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xff1c002f);
209
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xff252f00);
210
✓✗
1
        MSDL_FreeSurface(surface1);
211
✓✗
1
        MSDL_FreeSurface(surface2);
212
    }
213
214
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy5")
215
    {
216
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
217
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
218
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
219
4
            ptr1[f] = 0x00000000;
220
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
221
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
222
223
1
        ptr2[0] = 0x50112233;
224
1
        ptr2[1] = 0x50003344;
225
1
        ptr2[2] = 0x50330055;
226
1
        ptr2[3] = 0x50445500;
227
228
        SDLImageHelper::combineSurface(surface2,
229
            nullptr,
230
            surface1,
231
✓✗
1
            nullptr);
232
233
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x8e09121c);
234
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0x8e001c25);
235
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0x8e1c002f);
236
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0x8e252f00);
237
✓✗
1
        MSDL_FreeSurface(surface1);
238
✓✗
1
        MSDL_FreeSurface(surface2);
239
    }
240
241
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("empty copy6")
242
    {
243
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
244
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
245
1
        ptr1[0] = 0x50112233;
246
1
        ptr1[1] = 0x50003344;
247
1
        ptr1[2] = 0x50330055;
248
1
        ptr1[3] = 0x50445500;
249
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
250
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
251
252
✓✓
5
        for (int f = 0; f < 2 * 2; f ++)
253
4
            ptr2[f] = 0x00000000;
254
255
        SDLImageHelper::combineSurface(surface2,
256
            nullptr,
257
            surface1,
258
✓✗
1
            nullptr);
259
260
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x50112233);
261
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0x50003344);
262
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0x50330055);
263
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0x50445500);
264
✓✗
1
        MSDL_FreeSurface(surface1);
265
✓✗
1
        MSDL_FreeSurface(surface2);
266
    }
267
268
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("mix 1")
269
    {
270
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
271
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
272
1
        ptr1[0] = 0x50112233;
273
1
        ptr1[1] = 0x50003344;
274
1
        ptr1[2] = 0x50330055;
275
1
        ptr1[3] = 0x50445500;
276
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
277
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
278
279
1
        ptr2[0] = 0x50003344;
280
1
        ptr2[1] = 0x50330055;
281
1
        ptr2[2] = 0x50445500;
282
1
        ptr2[3] = 0x50112233;
283
284
        SDLImageHelper::combineSurface(surface2,
285
            nullptr,
286
            surface1,
287
✓✗
1
            nullptr);
288
289
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0xdf082b3c);
290
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xdf1d174d);
291
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xdf3d2f26);
292
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xdf29391c);
293
✓✗
1
        MSDL_FreeSurface(surface1);
294
✓✗
1
        MSDL_FreeSurface(surface2);
295
    }
296
297
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("mix 2")
298
    {
299
1
        SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
300
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
301
1
        ptr1[0] = 0x10112233;
302
1
        ptr1[1] = 0x20003344;
303
1
        ptr1[2] = 0x30330055;
304
1
        ptr1[3] = 0x40445500;
305
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
306
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
307
308
1
        ptr2[0] = 0x50003344;
309
1
        ptr2[1] = 0x60330055;
310
1
        ptr2[2] = 0x70445500;
311
1
        ptr2[3] = 0x80112233;
312
313
        SDLImageHelper::combineSurface(surface2,
314
            nullptr,
315
            surface1,
316
✓✗
1
            nullptr);
317
318
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x9f082b3c);
319
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xbd1f144e);
320
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0xb93f391e);
321
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0xf5213224);
322
✓✗
1
        MSDL_FreeSurface(surface1);
323
✓✗
1
        MSDL_FreeSurface(surface2);
324
    }
325
326
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("part mix 1")
327
    {
328
// 11 11 00 00
329
// 11 11 00 00
330
// 00 00 00 00
331
// 00 00 00 00
332
333
1
        SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
334
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
335
1
        ptr1[0] = 0x10112233;
336
1
        ptr1[1] = 0x20003344;
337
1
        ptr1[2] = 0x10203040;
338
1
        ptr1[3] = 0x20304050;
339
1
        ptr1[4] = 0x30330055;
340
1
        ptr1[5] = 0x40445500;
341
1
        ptr1[6] = 0x30405060;
342
1
        ptr1[7] = 0x708090a0;
343
344
1
        ptr1[8] = 0x8090a0b0;
345
1
        ptr1[9] = 0x90a0b0c0;
346
1
        ptr1[10] = 0xa0b0c0d0;
347
1
        ptr1[11] = 0xb0c0d0e0;
348
1
        ptr1[12] = 0xc0d0e0f0;
349
1
        ptr1[13] = 0xd0e0f000;
350
1
        ptr1[14] = 0xe0f00010;
351
1
        ptr1[15] = 0xf0001020;
352
353
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
354
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
355
356
1
        ptr2[0] = 0x50003344;
357
1
        ptr2[1] = 0x60330055;
358
1
        ptr2[2] = 0x70445500;
359
1
        ptr2[3] = 0x80112233;
360
361
        SDLImageHelper::combineSurface(surface2,
362
            nullptr,
363
            surface1,
364
✓✗
1
            nullptr);
365
366
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x9f082b3c);
367
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0xbd1f144e);
368
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0x10203040);
369
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0x20304050);
370
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[4] == 0xb93f391e);
371
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[5] == 0xf5213224);
372
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[6] == 0x30405060);
373
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[7] == 0x708090a0);
374
375
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[8] == 0x8090a0b0);
376
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[9] == 0x90a0b0c0);
377
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[10] == 0xa0b0c0d0);
378
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[11] == 0xb0c0d0e0);
379
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[12] == 0xc0d0e0f0);
380
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[13] == 0xd0e0f000);
381
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[14] == 0xe0f00010);
382
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[15] == 0xf0001020);
383
384
✓✗
1
        MSDL_FreeSurface(surface1);
385
✓✗
1
        MSDL_FreeSurface(surface2);
386
    }
387
388
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("part mix 2")
389
    {
390
// 00 00 00 00
391
// 00 11 11 00
392
// 00 11 11 00
393
// 00 00 00 00
394
395
1
        SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
396
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
397
398
1
        ptr1[0] = 0x10203040;
399
1
        ptr1[1] = 0x20304050;
400
1
        ptr1[2] = 0x30405060;
401
1
        ptr1[3] = 0x708090a0;
402
1
        ptr1[4] = 0x8090a0b0;
403
404
1
        ptr1[5] = 0x10112233;  // +
405
1
        ptr1[6] = 0x20003344;  // +
406
407
1
        ptr1[7] = 0x90a0b0c0;
408
1
        ptr1[8] = 0xa0b0c0d0;
409
410
1
        ptr1[9] = 0x30330055;  // +
411
1
        ptr1[10] = 0x40445500;  // +
412
413
1
        ptr1[11] = 0xb0c0d0e0;
414
1
        ptr1[12] = 0xc0d0e0f0;
415
1
        ptr1[13] = 0xd0e0f000;
416
1
        ptr1[14] = 0xe0f00010;
417
1
        ptr1[15] = 0xf0001020;
418
419
1
        SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
420
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
421
422
1
        ptr2[0] = 0x50003344;
423
1
        ptr2[1] = 0x60330055;
424
1
        ptr2[2] = 0x70445500;
425
1
        ptr2[3] = 0x80112233;
426
427
        SDL_Rect rect1;
428
        SDL_Rect rect2;
429
1
        rect1.x = 1;
430
1
        rect1.y = 1;
431
1
        rect1.w = 2;
432
1
        rect1.h = 2;
433
1
        rect2.x = 0;
434
1
        rect2.y = 0;
435
1
        rect2.w = 2;
436
1
        rect2.h = 2;
437
        SDLImageHelper::combineSurface(surface2,
438
            &rect2,
439
            surface1,
440
✓✗
1
            &rect1);
441
442
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x10203040);
443
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0x20304050);
444
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0x30405060);
445
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0x708090a0);
446
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[4] == 0x8090a0b0);
447
448
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[5] == 0x9f082b3c);  // +
449
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[6] == 0xbd1f144e);  // +
450
451
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[7] == 0x90a0b0c0);
452
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[8] == 0xa0b0c0d0);
453
454
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[9] == 0xb93f391e);  // +
455
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[10] == 0xf5213224);  // +
456
457
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[11] == 0xb0c0d0e0);
458
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[12] == 0xc0d0e0f0);
459
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[13] == 0xd0e0f000);
460
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[14] == 0xe0f00010);
461
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[15] == 0xf0001020);
462
463
✓✗
1
        MSDL_FreeSurface(surface1);
464
✓✗
1
        MSDL_FreeSurface(surface2);
465
    }
466
467
✓✗✓✗
✓✗✓✗
✓✗✓✓
77
    SECTION("part mix 3")
468
    {
469
1
        SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
470
1
        uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
471
472
1
        ptr1[0] = 0x10203040;
473
1
        ptr1[1] = 0x20304050;
474
1
        ptr1[2] = 0x30405060;
475
1
        ptr1[3] = 0x708090a0;
476
1
        ptr1[4] = 0x8090a0b0;
477
1
        ptr1[5] = 0x10112233;
478
1
        ptr1[6] = 0x20003344;
479
1
        ptr1[7] = 0x90a0b0c0;
480
1
        ptr1[8] = 0xa0b0c0d0;
481
1
        ptr1[9] = 0x30330055;
482
1
        ptr1[10] = 0x40445500;
483
1
        ptr1[11] = 0xb0c0d0e0;
484
1
        ptr1[12] = 0xc0d0e0f0;
485
1
        ptr1[13] = 0xd0e0f000;
486
1
        ptr1[14] = 0xe0f00010;
487
1
        ptr1[15] = 0xf0001020;
488
489
1
        SDL_Surface *surface2 = createSoftware32BitSurface(4, 4);
490
1
        uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
491
492
1
        ptr2[0] = 0x50003344;
493
1
        ptr2[1] = 0x60330055;
494
1
        ptr2[2] = 0x70445500;
495
1
        ptr2[3] = 0x80112233;
496
1
        ptr2[4] = 0x90111111;
497
1
        ptr2[5] = 0x90111111;
498
1
        ptr2[6] = 0xff000000;
499
1
        ptr2[7] = 0xff000000;
500
1
        ptr2[8] = 0xff000000;
501
1
        ptr2[9] = 0xff000000;
502
1
        ptr2[10] = 0xff000000;
503
1
        ptr2[11] = 0xff000000;
504
1
        ptr2[12] = 0xff000000;
505
1
        ptr2[13] = 0xff000000;
506
1
        ptr2[14] = 0xff000000;
507
1
        ptr2[15] = 0xff000000;
508
509
        SDL_Rect rect1;
510
        SDL_Rect rect2;
511
1
        rect1.x = 1;
512
1
        rect1.y = 1;
513
1
        rect1.w = 2;
514
1
        rect1.h = 2;
515
1
        rect2.x = 0;
516
1
        rect2.y = 0;
517
1
        rect2.w = 2;
518
1
        rect2.h = 2;
519
        SDLImageHelper::combineSurface(surface2,
520
            &rect2,
521
            surface1,
522
✓✗
1
            &rect1);
523
524
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[0] == 0x10203040);
525
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[1] == 0x20304050);
526
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[2] == 0x30405060);
527
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[3] == 0x708090a0);
528
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[4] == 0x8090a0b0);
529
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[5] == 0x9f082b3c);
530
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[6] == 0xbd1f144e);
531
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[7] == 0x90a0b0c0);
532
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[8] == 0xa0b0c0d0);
533
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[9] == 0xbf1b0d23);
534
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[10] == 0xff1f230c);
535
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[11] == 0xb0c0d0e0);
536
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[12] == 0xc0d0e0f0);
537
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[13] == 0xd0e0f000);
538
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[14] == 0xe0f00010);
539
✓✗✓✗
✓✗✓✗
✓✗✗✗
✗✗
4
        REQUIRE(ptr1[15] == 0xf0001020);
540
541
✓✗
1
        MSDL_FreeSurface(surface1);
542
✓✗
1
        MSDL_FreeSurface(surface2);
543
    }
544
545
✓✗
11
    delete2(userPalette)
546
✓✗
11
    delete2(theme)
547
✓✗
11
    delete2(client)
548
✓✗
33
    VirtFs::unmountDirSilent("data");
549
✓✗
33
    VirtFs::unmountDirSilent("../data");
550
✓✗✓✗
14
}
551
552
#endif  // SDL_BYTEORDER == SDL_LIL_ENDIAN
553
#endif  // USE_SDL2