GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/unittests/resources/dye/dye.cc Lines: 1553 1553 100.0 %
Date: 2021-03-17 Branches: 3094 8260 37.5 %

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 "client.h"
25
#include "configmanager.h"
26
#include "configuration.h"
27
#include "dirs.h"
28
#include "graphicsmanager.h"
29
30
#include "being/actorsprite.h"
31
32
#include "fs/virtfs/fs.h"
33
34
#include "gui/userpalette.h"
35
#include "gui/theme.h"
36
37
#include "resources/sdlimagehelper.h"
38
#ifdef USE_SDL2
39
#include "resources/surfaceimagehelper.h"
40
#endif  // USE_SDL2
41
42
#include "resources/dye/dye.h"
43
#include "resources/dye/dyepalette.h"
44
45
#include "resources/image/image.h"
46
47
#include "resources/loaders/imageloader.h"
48
49
#include "utils/delete2.h"
50
#include "utils/env.h"
51
52
PRAGMA48(GCC diagnostic push)
53
PRAGMA48(GCC diagnostic ignored "-Wshadow")
54
#ifndef USE_SDL2
55
#include <SDL.h>
56
#endif  // USE_SDL2
57
PRAGMA48(GCC diagnostic pop)
58
59
#include "debug.h"
60
61
#ifdef USE_OPENGL
62
63
3
TEST_CASE("Dye replaceSOGLColor 1 1", "")
64
{
65
5
    DyePalette palette("#00ff00,000011", 6);
66
    uint32_t data[1];
67
1
    data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
68

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 1);
69



4
    REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
70
1
}
71
72
3
TEST_CASE("Dye replaceSOGLColor 1 2", "")
73
{
74
5
    DyePalette palette("#01ff02,030411", 6);
75
    uint32_t data[1];
76
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
77

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 1);
78



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
79
1
}
80
81
3
TEST_CASE("Dye replaceSOGLColor 1 3", "")
82
{
83
5
    DyePalette palette("#404040,200000,0100ee,102030", 6);
84
    uint32_t data[1];
85
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
86

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 1);
87



4
    REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
88
1
}
89
90
3
TEST_CASE("Dye replaceSOGLColor 2 1", "")
91
{
92
5
    DyePalette palette("#01ff02,030411", 6);
93
    uint32_t data[2];
94
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
95
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
96

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 2);
97



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
98



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
99
1
}
100
101
3
TEST_CASE("Dye replaceSOGLColor 4 1", "")
102
{
103
5
    DyePalette palette("#01ff02,030411", 6);
104
    uint32_t data[4];
105
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
106
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
107
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
108
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
109

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 4);
110



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
111



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
112



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
113



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
114
1
}
115
116
3
TEST_CASE("Dye replaceSOGLColor 8 1", "")
117
{
118
5
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
119
    uint32_t data[8];
120
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
121
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
122
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
123
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
124
1
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
125
1
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
126
1
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
127
1
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
128

1
    DYEPALETTE(palette, SOGLColor)(&data[0], 8);
129



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
130



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
131



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
132



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
133



4
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
134



4
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
135



4
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
136



4
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
137
1
}
138
139
3
TEST_CASE("Dye replaceSOGLColor 1 1 default", "")
140
{
141
5
    DyePalette palette("#00ff00,000011", 6);
142
    uint32_t data[1];
143
1
    data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
144
1
    palette.replaceSOGLColorDefault(&data[0], 1);
145



4
    REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
146
1
}
147
148
3
TEST_CASE("Dye replaceSOGLColor 1 2 default", "")
149
{
150
5
    DyePalette palette("#01ff02,030411", 6);
151
    uint32_t data[1];
152
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
153
1
    palette.replaceSOGLColorDefault(&data[0], 1);
154



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
155
1
}
156
157
3
TEST_CASE("Dye replaceSOGLColor 1 3 default", "")
158
{
159
5
    DyePalette palette("#404040,200000,0100ee,102030", 6);
160
    uint32_t data[1];
161
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
162
1
    palette.replaceSOGLColorDefault(&data[0], 1);
163



4
    REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
164
1
}
165
166
3
TEST_CASE("Dye replaceSOGLColor 2 1 default", "")
167
{
168
5
    DyePalette palette("#01ff02,030411", 6);
169
    uint32_t data[2];
170
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
171
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
172
1
    palette.replaceSOGLColorDefault(&data[0], 2);
173



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
174



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
175
1
}
176
177
3
TEST_CASE("Dye replaceSOGLColor 4 1 default", "")
178
{
179
5
    DyePalette palette("#01ff02,030411", 6);
180
    uint32_t data[4];
181
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
182
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
183
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
184
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
185
1
    palette.replaceSOGLColorDefault(&data[0], 4);
186



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
187



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
188



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
189



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
190
1
}
191
192
3
TEST_CASE("Dye replaceSOGLColor 8 1 default", "")
193
{
194
5
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
195
    uint32_t data[8];
196
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
197
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
198
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
199
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
200
1
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
201
1
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
202
1
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
203
1
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
204
1
    palette.replaceSOGLColorDefault(&data[0], 8);
205



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
206



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
207



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
208



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
209



4
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
210



4
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
211



4
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
212



4
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
213
1
}
214
215
3
TEST_CASE("Dye replaceSOGLColor 8 1 sse2", "")
216
{
217
5
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
218
    uint32_t data[8];
219
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
220
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
221
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
222
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
223
1
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
224
1
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
225
1
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
226
1
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
227

1
    DYEPALETTE(palette, SOGLColorSse2)(&data[0], 8);
228



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
229



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
230



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
231



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
232



4
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
233



4
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
234



4
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
235



4
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
236
1
}
237
238
3
TEST_CASE("Dye replaceSOGLColor 8 1 avx2", "")
239
{
240
5
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
241
    uint32_t data[8];
242
1
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
243
1
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
244
1
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
245
1
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
246
1
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
247
1
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
248
1
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
249
1
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
250

1
    DYEPALETTE(palette, SOGLColorAvx2)(&data[0], 8);
251



4
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
252



4
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
253



4
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
254



4
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
255



4
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
256



4
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
257



4
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
258



4
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
259
1
}
260
261
262
3
TEST_CASE("Dye replaceAOGLColor 1 1", "")
263
{
264
5
    DyePalette palette("#00ff0010,00001120", 8);
265
    uint32_t data[1];
266
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
267

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 1);
268



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
269
1
}
270
271
3
TEST_CASE("Dye replaceAOGLColor 1 2", "")
272
{
273
5
    DyePalette palette("#00ff0120,020311ff", 8);
274
    uint32_t data[1];
275
1
    data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
276

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 1);
277



4
    REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
278
1
}
279
280
3
TEST_CASE("Dye replaceAOGLColor 1 3", "")
281
{
282
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
283
    uint32_t data[1];
284
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
285

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 1);
286



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
287
1
}
288
289
3
TEST_CASE("Dye replaceAOGLColor 2 1", "")
290
{
291
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
292
    uint32_t data[2];
293
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
294
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
295

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 2);
296



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
297



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
298
1
}
299
300
3
TEST_CASE("Dye replaceAOGLColor 4 1", "")
301
{
302
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
303
    uint32_t data[4];
304
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
305
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
306
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
307
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
308

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 4);
309



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
310



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
311



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
312



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
313
1
}
314
315
3
TEST_CASE("Dye replaceAOGLColor 8 1", "")
316
{
317
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
318
    uint32_t data[8];
319
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
320
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
321
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
322
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
323
1
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
324
1
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
325
1
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
326
1
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
327

1
    DYEPALETTE(palette, AOGLColor)(&data[0], 8);
328



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
329



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
330



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
331



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
332



4
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
333



4
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
334



4
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
335



4
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
336
1
}
337
338
3
TEST_CASE("Dye replaceAOGLColor 1 1 default", "")
339
{
340
5
    DyePalette palette("#00ff0010,00001120", 8);
341
    uint32_t data[1];
342
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
343
1
    palette.replaceAOGLColorDefault(&data[0], 1);
344



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
345
1
}
346
347
3
TEST_CASE("Dye replaceAOGLColor 1 2 default", "")
348
{
349
5
    DyePalette palette("#00ff0120,020311ff", 8);
350
    uint32_t data[1];
351
1
    data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
352
1
    palette.replaceAOGLColorDefault(&data[0], 1);
353



4
    REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
354
1
}
355
356
3
TEST_CASE("Dye replaceAOGLColor 1 3 default", "")
357
{
358
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
359
    uint32_t data[1];
360
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
361
1
    palette.replaceAOGLColorDefault(&data[0], 1);
362



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
363
1
}
364
365
3
TEST_CASE("Dye replaceAOGLColor 2 1 default", "")
366
{
367
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
368
    uint32_t data[2];
369
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
370
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
371
1
    palette.replaceAOGLColorDefault(&data[0], 2);
372



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
373



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
374
1
}
375
376
3
TEST_CASE("Dye replaceAOGLColor 4 1 default", "")
377
{
378
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
379
    uint32_t data[4];
380
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
381
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
382
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
383
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
384
1
    palette.replaceAOGLColorDefault(&data[0], 4);
385



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
386



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
387



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
388



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
389
1
}
390
391
3
TEST_CASE("Dye replaceAOGLColor 8 1 default", "")
392
{
393
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
394
    uint32_t data[8];
395
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
396
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
397
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
398
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
399
1
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
400
1
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
401
1
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
402
1
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
403
1
    palette.replaceAOGLColorDefault(&data[0], 8);
404



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
405



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
406



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
407



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
408



4
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
409



4
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
410



4
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
411



4
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
412
1
}
413
414
3
TEST_CASE("Dye replaceAOGLColor 8 1 sse2", "")
415
{
416
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
417
    uint32_t data[8];
418
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
419
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
420
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
421
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
422
1
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
423
1
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
424
1
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
425
1
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
426

1
    DYEPALETTE(palette, AOGLColorSse2)(&data[0], 8);
427



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
428



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
429



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
430



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
431



4
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
432



4
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
433



4
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
434



4
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
435
1
}
436
437
3
TEST_CASE("Dye replaceAOGLColor 8 1 avx2", "")
438
{
439
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
440
    uint32_t data[8];
441
1
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
442
1
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
443
1
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
444
1
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
445
1
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
446
1
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
447
1
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
448
1
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
449

1
    DYEPALETTE(palette, AOGLColorAvx2)(&data[0], 8);
450



4
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
451



4
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
452



4
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
453



4
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
454



4
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
455



4
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
456



4
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
457



4
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
458
1
}
459
#endif  // USE_OPENGL
460
461
462
3
TEST_CASE("Dye replaceSColor 1 1", "")
463
{
464
5
    DyePalette palette("#00ff00,000011", 6);
465
    uint32_t data[1];
466
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
467

1
    DYEPALETTE(palette, SColor)(&data[0], 1);
468



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
469
1
}
470
471
3
TEST_CASE("Dye replaceSColor 1 2", "")
472
{
473
5
    DyePalette palette("#403020,706050", 6);
474
    uint32_t data[1];
475
1
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
476

1
    DYEPALETTE(palette, SColor)(&data[0], 1);
477



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
478
1
}
479
480
3
TEST_CASE("Dye replaceSColor 1 3", "")
481
{
482
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
483
    uint32_t data[1];
484
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
485

1
    DYEPALETTE(palette, SColor)(&data[0], 1);
486



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
487
1
}
488
489
3
TEST_CASE("Dye replaceSColor 2 1", "")
490
{
491
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
492
    uint32_t data[2];
493
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
494
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
495

1
    DYEPALETTE(palette, SColor)(&data[0], 2);
496



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
497



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
498
1
}
499
500
3
TEST_CASE("Dye replaceSColor 3 1", "")
501
{
502
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
503
    uint32_t data[3];
504
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
505
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
506
1
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
507

1
    DYEPALETTE(palette, SColor)(&data[0], 3);
508



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
509



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
510



4
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
511
1
}
512
513
3
TEST_CASE("Dye replaceSColor 4 1", "")
514
{
515
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
516
    uint32_t data[4];
517
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
518
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
519
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
520
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
521

1
    DYEPALETTE(palette, SColor)(&data[0], 4);
522



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
523



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
524



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
525



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
526
1
}
527
528
3
TEST_CASE("Dye replaceSColor 5 1", "")
529
{
530
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
531
    uint32_t data[5];
532
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
533
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
534
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
535
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
536
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
537

1
    DYEPALETTE(palette, SColor)(&data[0], 5);
538



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
539



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
540



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
541



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
542



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
543
1
}
544
545
3
TEST_CASE("Dye replaceSColor 7 1", "")
546
{
547
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
548
    uint32_t data[7];
549
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
550
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
551
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
552
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
553
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
554
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
555
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
556

1
    DYEPALETTE(palette, SColor)(&data[0], 7);
557



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
558



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
559



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
560



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
561



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
562



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
563



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
564
1
}
565
566
3
TEST_CASE("Dye replaceSColor 8 1", "")
567
{
568
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
569
    uint32_t data[8];
570
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
571
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
572
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
573
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
574
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
575
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
576
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
577
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
578

1
    DYEPALETTE(palette, SColor)(&data[0], 8);
579



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
580



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
581



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
582



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
583



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
584



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
585



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
586



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
587
1
}
588
589
3
TEST_CASE("Dye replaceSColor 9 1", "")
590
{
591
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
592
    uint32_t data[9];
593
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
594
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
595
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
596
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
597
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
598
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
599
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
600
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
601
1
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
602

1
    DYEPALETTE(palette, SColor)(&data[0], 9);
603



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
604



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
605



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
606



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
607



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
608



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
609



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
610



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
611



4
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
612
1
}
613
614
3
TEST_CASE("Dye replaceSColor 10 1", "")
615
{
616
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
617
    uint32_t data[10];
618
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
619
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
620
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
621
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
622
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
623
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
624
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
625
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
626
1
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
627
1
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
628

1
    DYEPALETTE(palette, SColor)(&data[0], 10);
629



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
630



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
631



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
632



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
633



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
634



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
635



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
636



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
637



4
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
638



4
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
639
1
}
640
641
3
TEST_CASE("Dye replaceSColor 1 1 default", "")
642
{
643
5
    DyePalette palette("#00ff00,000011", 6);
644
    uint32_t data[1];
645
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
646
1
    palette.replaceSColorDefault(&data[0], 1);
647



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
648
1
}
649
650
3
TEST_CASE("Dye replaceSColor 1 2 default", "")
651
{
652
5
    DyePalette palette("#403020,706050", 6);
653
    uint32_t data[1];
654
1
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
655
1
    palette.replaceSColorDefault(&data[0], 1);
656



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
657
1
}
658
659
3
TEST_CASE("Dye replaceSColor 1 3 default", "")
660
{
661
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
662
    uint32_t data[1];
663
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
664
1
    palette.replaceSColorDefault(&data[0], 1);
665



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
666
1
}
667
668
3
TEST_CASE("Dye replaceSColor 2 1 default", "")
669
{
670
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
671
    uint32_t data[2];
672
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
673
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
674
1
    palette.replaceSColorDefault(&data[0], 2);
675



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
676



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
677
1
}
678
679
3
TEST_CASE("Dye replaceSColor 3 1 default", "")
680
{
681
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
682
    uint32_t data[3];
683
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
684
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
685
1
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
686
1
    palette.replaceSColorDefault(&data[0], 3);
687



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
688



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
689



4
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
690
1
}
691
692
3
TEST_CASE("Dye replaceSColor 4 1 default", "")
693
{
694
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
695
    uint32_t data[4];
696
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
697
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
698
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
699
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
700
1
    palette.replaceSColorDefault(&data[0], 4);
701



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
702



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
703



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
704



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
705
1
}
706
707
3
TEST_CASE("Dye replaceSColor 5 1 default", "")
708
{
709
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
710
    uint32_t data[5];
711
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
712
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
713
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
714
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
715
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
716
1
    palette.replaceSColorDefault(&data[0], 5);
717



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
718



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
719



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
720



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
721



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
722
1
}
723
724
3
TEST_CASE("Dye replaceSColor 7 1 default", "")
725
{
726
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
727
    uint32_t data[7];
728
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
729
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
730
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
731
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
732
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
733
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
734
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
735
1
    palette.replaceSColorDefault(&data[0], 7);
736



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
737



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
738



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
739



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
740



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
741



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
742



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
743
1
}
744
745
3
TEST_CASE("Dye replaceSColor 8 1 default", "")
746
{
747
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
748
    uint32_t data[8];
749
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
750
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
751
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
752
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
753
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
754
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
755
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
756
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
757
1
    palette.replaceSColorDefault(&data[0], 8);
758



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
759



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
760



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
761



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
762



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
763



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
764



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
765



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
766
1
}
767
768
3
TEST_CASE("Dye replaceSColor 9 1 default", "")
769
{
770
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
771
    uint32_t data[9];
772
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
773
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
774
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
775
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
776
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
777
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
778
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
779
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
780
1
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
781
1
    palette.replaceSColorDefault(&data[0], 9);
782



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
783



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
784



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
785



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
786



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
787



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
788



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
789



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
790



4
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
791
1
}
792
793
3
TEST_CASE("Dye replaceSColor 10 1 default", "")
794
{
795
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
796
    uint32_t data[10];
797
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
798
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
799
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
800
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
801
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
802
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
803
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
804
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
805
1
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
806
1
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
807
1
    palette.replaceSColorDefault(&data[0], 10);
808



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
809



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
810



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
811



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
812



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
813



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
814



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
815



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
816



4
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
817



4
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
818
1
}
819
820
3
TEST_CASE("Dye replaceSColor 1 1 sse2", "")
821
{
822
5
    DyePalette palette("#00ff00,000011", 6);
823
    uint32_t data[1];
824
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
825

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 1);
826



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
827
1
}
828
829
3
TEST_CASE("Dye replaceSColor 1 2 sse2", "")
830
{
831
5
    DyePalette palette("#403020,706050", 6);
832
    uint32_t data[1];
833
1
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
834

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 1);
835



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
836
1
}
837
838
3
TEST_CASE("Dye replaceSColor 1 3 sse2", "")
839
{
840
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
841
    uint32_t data[1];
842
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
843

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 1);
844



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
845
1
}
846
847
3
TEST_CASE("Dye replaceSColor 2 1 sse2", "")
848
{
849
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
850
    uint32_t data[2];
851
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
852
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
853

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 2);
854



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
855



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
856
1
}
857
858
3
TEST_CASE("Dye replaceSColor 3 1 sse2", "")
859
{
860
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
861
    uint32_t data[3];
862
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
863
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
864
1
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
865

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 3);
866



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
867



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
868



4
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
869
1
}
870
871
3
TEST_CASE("Dye replaceSColor 4 1 sse2", "")
872
{
873
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
874
    uint32_t data[4];
875
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
876
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
877
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
878
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
879

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 4);
880



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
881



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
882



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
883



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
884
1
}
885
886
3
TEST_CASE("Dye replaceSColor 5 1 sse2", "")
887
{
888
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
889
    uint32_t data[5];
890
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
891
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
892
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
893
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
894
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
895

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 5);
896



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
897



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
898



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
899



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
900



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
901
1
}
902
903
3
TEST_CASE("Dye replaceSColor 7 1 sse2", "")
904
{
905
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
906
    uint32_t data[7];
907
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
908
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
909
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
910
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
911
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
912
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
913
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
914

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 7);
915



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
916



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
917



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
918



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
919



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
920



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
921



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
922
1
}
923
924
3
TEST_CASE("Dye replaceSColor 8 1 sse2", "")
925
{
926
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
927
    uint32_t data[8];
928
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
929
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
930
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
931
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
932
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
933
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
934
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
935
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
936

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 8);
937



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
938



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
939



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
940



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
941



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
942



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
943



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
944



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
945
1
}
946
947
3
TEST_CASE("Dye replaceSColor 9 1 sse2", "")
948
{
949
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
950
    uint32_t data[9];
951
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
952
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
953
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
954
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
955
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
956
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
957
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
958
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
959
1
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
960

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 9);
961



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
962



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
963



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
964



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
965



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
966



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
967



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
968



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
969



4
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
970
1
}
971
972
3
TEST_CASE("Dye replaceSColor 10 1 sse2", "")
973
{
974
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
975
    uint32_t data[10];
976
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
977
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
978
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
979
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
980
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
981
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
982
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
983
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
984
1
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
985
1
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
986

1
    DYEPALETTE(palette, SColorSse2)(&data[0], 10);
987



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
988



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
989



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
990



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
991



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
992



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
993



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
994



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
995



4
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
996



4
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
997
1
}
998
999
3
TEST_CASE("Dye replaceSColor 1 1 avx2", "")
1000
{
1001
5
    DyePalette palette("#00ff00,000011", 6);
1002
    uint32_t data[1];
1003
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
1004

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
1005



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
1006
1
}
1007
1008
3
TEST_CASE("Dye replaceSColor 1 2 avx2", "")
1009
{
1010
5
    DyePalette palette("#403020,706050", 6);
1011
    uint32_t data[1];
1012
1
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
1013

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
1014



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1015
1
}
1016
1017
3
TEST_CASE("Dye replaceSColor 1 3 avx2", "")
1018
{
1019
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1020
    uint32_t data[1];
1021
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1022

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
1023



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1024
1
}
1025
1026
3
TEST_CASE("Dye replaceSColor 2 1 avx2", "")
1027
{
1028
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1029
    uint32_t data[2];
1030
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1031
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1032

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 2);
1033



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1034



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1035
1
}
1036
1037
3
TEST_CASE("Dye replaceSColor 3 1 avx2", "")
1038
{
1039
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1040
    uint32_t data[3];
1041
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1042
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1043
1
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
1044

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 3);
1045



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1046



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1047



4
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
1048
1
}
1049
1050
3
TEST_CASE("Dye replaceSColor 4 1 avx2", "")
1051
{
1052
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1053
    uint32_t data[4];
1054
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1055
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1056
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1057
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
1058

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 4);
1059



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1060



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1061



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1062



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
1063
1
}
1064
1065
3
TEST_CASE("Dye replaceSColor 5 1 avx2", "")
1066
{
1067
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1068
    uint32_t data[5];
1069
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1070
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1071
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1072
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
1073
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
1074

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 5);
1075



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1076



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1077



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1078



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
1079



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
1080
1
}
1081
1082
3
TEST_CASE("Dye replaceSColor 7 1 avx2", "")
1083
{
1084
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1085
    uint32_t data[7];
1086
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1087
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1088
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1089
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
1090
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
1091
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
1092
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
1093

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 7);
1094



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1095



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1096



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1097



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
1098



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
1099



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
1100



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
1101
1
}
1102
1103
3
TEST_CASE("Dye replaceSColor 8 1 avx2", "")
1104
{
1105
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1106
    uint32_t data[8];
1107
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1108
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1109
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1110
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
1111
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
1112
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
1113
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
1114
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
1115

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 8);
1116



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1117



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1118



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1119



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
1120



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
1121



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
1122



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
1123



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
1124
1
}
1125
1126
3
TEST_CASE("Dye replaceSColor 9 1 avx2", "")
1127
{
1128
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1129
    uint32_t data[9];
1130
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1131
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1132
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1133
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
1134
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
1135
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
1136
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
1137
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
1138
1
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
1139

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 9);
1140



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1141



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1142



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1143



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
1144



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
1145



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
1146



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
1147



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
1148



4
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
1149
1
}
1150
1151
3
TEST_CASE("Dye replaceSColor 10 1 avx2", "")
1152
{
1153
5
    DyePalette palette("#123456,000000,ff3020,706050", 6);
1154
    uint32_t data[10];
1155
1
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
1156
1
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
1157
1
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
1158
1
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
1159
1
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
1160
1
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
1161
1
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
1162
1
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
1163
1
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
1164
1
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
1165

1
    DYEPALETTE(palette, SColorAvx2)(&data[0], 10);
1166



4
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
1167



4
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
1168



4
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
1169



4
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
1170



4
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
1171



4
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
1172



4
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
1173



4
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
1174



4
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
1175



4
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
1176
1
}
1177
1178
1179
3
TEST_CASE("Dye replaceAColor 1 1", "")
1180
{
1181
5
    DyePalette palette("#00ff0010,00001120", 8);
1182
    uint32_t data[1];
1183
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
1184

1
    DYEPALETTE(palette, AColor)(&data[0], 1);
1185



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
1186
1
}
1187
1188
3
TEST_CASE("Dye replaceAColor 1 2", "")
1189
{
1190
5
    DyePalette palette("#02ff0120,040311ff", 8);
1191
    uint32_t data[1];
1192
1
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
1193

1
    DYEPALETTE(palette, AColor)(&data[0], 1);
1194



4
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
1195
1
}
1196
1197
3
TEST_CASE("Dye replaceAColor 1 3", "")
1198
{
1199
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1200
    uint32_t data[1];
1201
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1202

1
    DYEPALETTE(palette, AColor)(&data[0], 1);
1203



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1204
1
}
1205
1206
3
TEST_CASE("Dye replaceAColor 2 1", "")
1207
{
1208
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1209
    uint32_t data[2];
1210
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1211
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1212

1
    DYEPALETTE(palette, AColor)(&data[0], 2);
1213



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1214



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1215
1
}
1216
1217
3
TEST_CASE("Dye replaceAColor 3 1", "")
1218
{
1219
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1220
    uint32_t data[3];
1221
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1222
1
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
1223
1
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
1224

1
    DYEPALETTE(palette, AColor)(&data[0], 3);
1225



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1226



4
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
1227



4
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
1228
1
}
1229
1230
3
TEST_CASE("Dye replaceAColor 4 1", "")
1231
{
1232
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1233
    uint32_t data[4];
1234
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1235
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1236
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1237
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1238

1
    DYEPALETTE(palette, AColor)(&data[0], 4);
1239



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1240



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1241



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1242



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1243
1
}
1244
1245
3
TEST_CASE("Dye replaceAColor 5 1", "")
1246
{
1247
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1248
    uint32_t data[5];
1249
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1250
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1251
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1252
1
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
1253
1
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
1254

1
    DYEPALETTE(palette, AColor)(&data[0], 5);
1255



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1256



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1257



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1258



4
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
1259



4
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
1260
1
}
1261
1262
3
TEST_CASE("Dye replaceAColor 7 1", "")
1263
{
1264
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1265
    uint32_t data[7];
1266
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1267
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1268
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1269
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1270
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1271
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1272
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1273

1
    DYEPALETTE(palette, AColor)(&data[0], 7);
1274



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1275



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1276



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1277



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1278



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1279



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1280



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1281
1
}
1282
1283
3
TEST_CASE("Dye replaceAColor 8 1", "")
1284
{
1285
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1286
    uint32_t data[8];
1287
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1288
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1289
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1290
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1291
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1292
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1293
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1294
1
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
1295

1
    DYEPALETTE(palette, AColor)(&data[0], 8);
1296



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1297



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1298



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1299



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1300



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1301



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1302



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1303



4
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
1304
1
}
1305
1306
3
TEST_CASE("Dye replaceAColor 9 1", "")
1307
{
1308
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1309
    uint32_t data[9];
1310
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1311
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1312
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1313
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1314
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1315
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1316
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1317
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1318
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1319

1
    DYEPALETTE(palette, AColor)(&data[0], 9);
1320



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1321



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1322



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1323



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1324



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1325



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1326



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1327



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1328



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1329
1
}
1330
1331
3
TEST_CASE("Dye replaceAColor 10 1", "")
1332
{
1333
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1334
    uint32_t data[10];
1335
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1336
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1337
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1338
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1339
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1340
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1341
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1342
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1343
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1344
1
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
1345

1
    DYEPALETTE(palette, AColor)(&data[0], 10);
1346



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1347



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1348



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1349



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1350



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1351



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1352



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1353



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1354



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1355



4
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
1356
1
}
1357
1358
3
TEST_CASE("Dye replaceAColor 1 1 default", "")
1359
{
1360
5
    DyePalette palette("#00ff0010,00001120", 8);
1361
    uint32_t data[1];
1362
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
1363
1
    palette.replaceAColorDefault(&data[0], 1);
1364



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
1365
1
}
1366
1367
3
TEST_CASE("Dye replaceAColor 1 2 default", "")
1368
{
1369
5
    DyePalette palette("#02ff0120,040311ff", 8);
1370
    uint32_t data[1];
1371
1
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
1372
1
    palette.replaceAColorDefault(&data[0], 1);
1373



4
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
1374
1
}
1375
1376
3
TEST_CASE("Dye replaceAColor 1 3 default", "")
1377
{
1378
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1379
    uint32_t data[1];
1380
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1381
1
    palette.replaceAColorDefault(&data[0], 1);
1382



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1383
1
}
1384
1385
3
TEST_CASE("Dye replaceAColor 2 1 default", "")
1386
{
1387
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1388
    uint32_t data[2];
1389
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1390
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1391
1
    palette.replaceAColorDefault(&data[0], 2);
1392



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1393



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1394
1
}
1395
1396
3
TEST_CASE("Dye replaceAColor 3 1 default", "")
1397
{
1398
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1399
    uint32_t data[3];
1400
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1401
1
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
1402
1
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
1403
1
    palette.replaceAColorDefault(&data[0], 3);
1404



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1405



4
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
1406



4
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
1407
1
}
1408
1409
3
TEST_CASE("Dye replaceAColor 4 1 default", "")
1410
{
1411
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1412
    uint32_t data[4];
1413
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1414
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1415
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1416
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1417
1
    palette.replaceAColorDefault(&data[0], 4);
1418



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1419



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1420



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1421



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1422
1
}
1423
1424
3
TEST_CASE("Dye replaceAColor 5 1 default", "")
1425
{
1426
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1427
    uint32_t data[5];
1428
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1429
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1430
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1431
1
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
1432
1
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
1433
1
    palette.replaceAColorDefault(&data[0], 5);
1434



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1435



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1436



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1437



4
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
1438



4
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
1439
1
}
1440
1441
3
TEST_CASE("Dye replaceAColor 7 1 default", "")
1442
{
1443
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1444
    uint32_t data[7];
1445
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1446
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1447
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1448
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1449
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1450
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1451
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1452
1
    palette.replaceAColorDefault(&data[0], 7);
1453



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1454



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1455



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1456



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1457



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1458



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1459



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1460
1
}
1461
1462
3
TEST_CASE("Dye replaceAColor 8 1 default", "")
1463
{
1464
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1465
    uint32_t data[8];
1466
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1467
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1468
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1469
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1470
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1471
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1472
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1473
1
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
1474
1
    palette.replaceAColorDefault(&data[0], 8);
1475



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1476



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1477



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1478



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1479



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1480



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1481



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1482



4
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
1483
1
}
1484
1485
3
TEST_CASE("Dye replaceAColor 9 1 default", "")
1486
{
1487
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1488
    uint32_t data[9];
1489
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1490
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1491
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1492
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1493
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1494
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1495
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1496
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1497
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1498
1
    palette.replaceAColorDefault(&data[0], 9);
1499



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1500



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1501



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1502



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1503



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1504



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1505



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1506



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1507



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1508
1
}
1509
1510
3
TEST_CASE("Dye replaceAColor 10 1 default", "")
1511
{
1512
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1513
    uint32_t data[10];
1514
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1515
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1516
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1517
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1518
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1519
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1520
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1521
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1522
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1523
1
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
1524
1
    palette.replaceAColorDefault(&data[0], 10);
1525



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1526



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1527



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1528



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1529



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1530



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1531



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1532



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1533



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1534



4
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
1535
1
}
1536
1537
3
TEST_CASE("Dye replaceAColor 1 1 sse2", "")
1538
{
1539
5
    DyePalette palette("#00ff0010,00001120", 8);
1540
    uint32_t data[1];
1541
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
1542

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 1);
1543



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
1544
1
}
1545
1546
3
TEST_CASE("Dye replaceAColor 1 2 sse2", "")
1547
{
1548
5
    DyePalette palette("#02ff0120,040311ff", 8);
1549
    uint32_t data[1];
1550
1
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
1551

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 1);
1552



4
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
1553
1
}
1554
1555
3
TEST_CASE("Dye replaceAColor 1 3 sse2", "")
1556
{
1557
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1558
    uint32_t data[1];
1559
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1560

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 1);
1561



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1562
1
}
1563
1564
3
TEST_CASE("Dye replaceAColor 2 1 sse2", "")
1565
{
1566
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1567
    uint32_t data[2];
1568
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1569
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1570

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 2);
1571



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1572



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1573
1
}
1574
1575
3
TEST_CASE("Dye replaceAColor 3 1 sse2", "")
1576
{
1577
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1578
    uint32_t data[3];
1579
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1580
1
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
1581
1
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
1582

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 3);
1583



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1584



4
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
1585



4
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
1586
1
}
1587
1588
3
TEST_CASE("Dye replaceAColor 4 1 sse2", "")
1589
{
1590
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1591
    uint32_t data[4];
1592
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1593
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1594
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1595
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1596

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 4);
1597



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1598



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1599



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1600



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1601
1
}
1602
1603
3
TEST_CASE("Dye replaceAColor 5 1 sse2", "")
1604
{
1605
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1606
    uint32_t data[5];
1607
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1608
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1609
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1610
1
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
1611
1
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
1612

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 5);
1613



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1614



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1615



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1616



4
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
1617



4
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
1618
1
}
1619
1620
3
TEST_CASE("Dye replaceAColor 7 1 sse2", "")
1621
{
1622
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1623
    uint32_t data[7];
1624
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1625
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1626
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1627
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1628
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1629
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1630
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1631

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 7);
1632



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1633



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1634



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1635



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1636



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1637



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1638



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1639
1
}
1640
1641
3
TEST_CASE("Dye replaceAColor 8 1 sse2", "")
1642
{
1643
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1644
    uint32_t data[8];
1645
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1646
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1647
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1648
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1649
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1650
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1651
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1652
1
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
1653

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 8);
1654



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1655



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1656



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1657



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1658



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1659



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1660



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1661



4
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
1662
1
}
1663
1664
3
TEST_CASE("Dye replaceAColor 9 1 sse2", "")
1665
{
1666
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1667
    uint32_t data[9];
1668
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1669
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1670
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1671
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1672
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1673
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1674
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1675
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1676
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1677

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 9);
1678



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1679



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1680



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1681



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1682



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1683



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1684



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1685



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1686



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1687
1
}
1688
1689
3
TEST_CASE("Dye replaceAColor 10 1 sse2", "")
1690
{
1691
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1692
    uint32_t data[10];
1693
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1694
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1695
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1696
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1697
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1698
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1699
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1700
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1701
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1702
1
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
1703

1
    DYEPALETTE(palette, AColorSse2)(&data[0], 10);
1704



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1705



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1706



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1707



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1708



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1709



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1710



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1711



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1712



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1713



4
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
1714
1
}
1715
1716
3
TEST_CASE("Dye replaceAColor 1 1 avx2", "")
1717
{
1718
5
    DyePalette palette("#00ff0010,00001120", 8);
1719
    uint32_t data[1];
1720
1
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
1721

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
1722



4
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
1723
1
}
1724
1725
3
TEST_CASE("Dye replaceAColor 1 2 avx2", "")
1726
{
1727
5
    DyePalette palette("#02ff0120,040311ff", 8);
1728
    uint32_t data[1];
1729
1
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
1730

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
1731



4
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
1732
1
}
1733
1734
3
TEST_CASE("Dye replaceAColor 1 3 avx2", "")
1735
{
1736
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1737
    uint32_t data[1];
1738
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1739

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
1740



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1741
1
}
1742
1743
3
TEST_CASE("Dye replaceAColor 2 1 avx2", "")
1744
{
1745
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1746
    uint32_t data[2];
1747
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1748
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1749

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 2);
1750



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1751



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1752
1
}
1753
1754
3
TEST_CASE("Dye replaceAColor 3 1 avx2", "")
1755
{
1756
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1757
    uint32_t data[3];
1758
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1759
1
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
1760
1
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
1761

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 3);
1762



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1763



4
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
1764



4
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
1765
1
}
1766
1767
3
TEST_CASE("Dye replaceAColor 4 1 avx2", "")
1768
{
1769
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1770
    uint32_t data[4];
1771
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1772
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1773
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1774
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1775

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 4);
1776



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1777



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1778



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1779



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1780
1
}
1781
1782
3
TEST_CASE("Dye replaceAColor 5 1 avx2", "")
1783
{
1784
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1785
    uint32_t data[5];
1786
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1787
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1788
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1789
1
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
1790
1
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
1791

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 5);
1792



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1793



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1794



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1795



4
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
1796



4
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
1797
1
}
1798
1799
3
TEST_CASE("Dye replaceAColor 7 1 avx2", "")
1800
{
1801
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1802
    uint32_t data[7];
1803
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1804
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1805
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1806
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1807
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1808
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1809
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1810

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 7);
1811



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1812



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1813



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1814



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1815




4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1816



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1817



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1818
1
}
1819
1820
3
TEST_CASE("Dye replaceAColor 8 1 avx2", "")
1821
{
1822
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1823
    uint32_t data[8];
1824
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1825
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1826
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1827
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1828
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1829
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1830
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1831
1
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
1832

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 8);
1833



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1834



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1835



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1836



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1837



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1838



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1839



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1840



4
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
1841
1
}
1842
1843
3
TEST_CASE("Dye replaceAColor 9 1 avx2", "")
1844
{
1845
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1846
    uint32_t data[9];
1847
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1848
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1849
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1850
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1851
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1852
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1853
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1854
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1855
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1856

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 9);
1857



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1858



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1859



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1860



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1861



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1862



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1863



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1864



4
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1865



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1866
1
}
1867
1868
3
TEST_CASE("Dye replaceAColor 10 1 avx2", "")
1869
{
1870
5
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
1871
    uint32_t data[10];
1872
1
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
1873
1
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
1874
1
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
1875
1
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
1876
1
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
1877
1
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
1878
1
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
1879
1
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
1880
1
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
1881
1
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
1882

1
    DYEPALETTE(palette, AColorAvx2)(&data[0], 10);
1883



4
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
1884



4
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
1885



4
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
1886



4
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
1887



4
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
1888



4
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
1889



4
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
1890



3
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
1891



4
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
1892



4
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
1893
1
}
1894
1895
1896
3
TEST_CASE("Dye normalDye 1", "")
1897
{
1898
5
    Dye dye("R:#203040,506070");
1899
    uint32_t data[1];
1900
1
    data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
1901
1
    dye.normalDye(&data[0], 1);
1902



4
    REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x55));
1903
1
}
1904
1905
3
TEST_CASE("Dye normalDye 2", "")
1906
{
1907
5
    Dye dye("G:#203040,506070");
1908
    uint32_t data[1];
1909
1
    data[0] = buildHex(0x00, 0x50, 0x00, 0x60);
1910
1
    dye.normalDye(&data[0], 1);
1911



4
    REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x60));
1912
1
}
1913
1914
1915
#ifdef USE_OPENGL
1916
3
TEST_CASE("Dye normalOGLDye 1", "")
1917
{
1918
5
    Dye dye("R:#203040,506070");
1919
    uint32_t data[1];
1920
1
    data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
1921
1
    dye.normalOGLDye(&data[0], 1);
1922



4
    REQUIRE(data[0] == buildHex(0x50, 0x2a, 0x20, 0x15));
1923
1
}
1924
#endif  // USE_OPENGL
1925
1926
3
static void dyeCheck(const std::string &dyeString,
1927
                     const std::string &dstName)
1928
{
1929
12
    const std::string srcName = "arrow_up.png";
1930
1931

6
    Image *const image1 = Loader::getImage(srcName + dyeString);
1932
3
    Image *const image2 = Loader::getImage(dstName);
1933



12
    REQUIRE(image1 != nullptr);
1934



12
    REQUIRE(image2 != nullptr);
1935
6
    SDL_Surface *const surface1 = image1->getSDLSurface();
1936
6
    SDL_Surface *const surface2 = image2->getSDLSurface();
1937



12
    REQUIRE(surface1 != nullptr);
1938



12
    REQUIRE(surface2 != nullptr);
1939



12
    REQUIRE(surface1->w == surface2->w);
1940



12
    REQUIRE(surface1->h == surface2->h);
1941



12
    REQUIRE(surface1->pixels != nullptr);
1942



12
    REQUIRE(surface2->pixels != nullptr);
1943
    const uint32_t *const ptr1 = static_cast<const uint32_t *>(
1944
3
        surface1->pixels);
1945
    const uint32_t *const ptr2 = static_cast<const uint32_t *>(
1946
3
        surface2->pixels);
1947
3
    const size_t sz = surface1->w * surface1->h;
1948
3075
    for (size_t idx = 0; idx < sz; idx ++)
1949
    {
1950



12288
        REQUIRE(ptr1[idx] == ptr2[idx]);
1951
    }
1952
3
    image2->decRef();
1953
3
    image1->decRef();
1954
3
}
1955
1956
5
TEST_CASE("Dye real dye", "")
1957
{
1958
3
    setEnv("SDL_VIDEODRIVER", "dummy");
1959
1960
3
    client = new Client;
1961
3
    SDL_Init(SDL_INIT_VIDEO);
1962
12
    VirtFs::mountDirSilent("data", Append_false);
1963
12
    VirtFs::mountDirSilent("../data", Append_false);
1964
12
    VirtFs::mountDirSilent("data/test", Append_false);
1965
12
    VirtFs::mountDirSilent("../data/test", Append_false);
1966
1967
3
    Dirs::initRootDir();
1968
3
    Dirs::initHomeDir();
1969
1970
3
    setBrandingDefaults(branding);
1971
3
    ConfigManager::initConfiguration();
1972
1973
#ifdef USE_SDL2
1974
6
    imageHelper = new SurfaceImageHelper;
1975
1976
3
    SDLImageHelper::setRenderer(graphicsManager.createRenderer(
1977
        GraphicsManager::createWindow(640, 480, 0,
1978
3
        SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
1979
#else  // USE_SDL2
1980
1981
    imageHelper = new SDLImageHelper;
1982
1983
    GraphicsManager::createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
1984
#endif  // USE_SDL2
1985
1986
3
    userPalette = new UserPalette;
1987
1988
3
    theme = new Theme;
1989
3
    Theme::selectSkin();
1990
1991
3
    ActorSprite::load();
1992
1993



21
    SECTION("B dye")
1994
    {
1995

7
        dyeCheck("|B:#FFC88A", "arrow_up_B.png");
1996
    }
1997
1998



21
    SECTION("S dye")
1999
    {
2000

7
        dyeCheck("|S:#0000FF,FF0000", "arrow_up_S.png");
2001
    }
2002
2003



21
    SECTION("A dye")
2004
    {
2005

7
        dyeCheck("|A:#0000FFFF,FF000050", "arrow_up_A.png");
2006
    }
2007
2008
3
    delete2(userPalette)
2009
3
    delete2(theme)
2010
3
    delete2(client)
2011
12
    VirtFs::unmountDirSilent("data");
2012
12
    VirtFs::unmountDirSilent("../data");
2013
12
    VirtFs::unmountDirSilent("data/test");
2014
12
    VirtFs::unmountDirSilent("../data/test");
2015

6
}