summaryrefslogblamecommitdiff
path: root/src/resources/dye/dye_unittest.cc
blob: 5f38aa77ab28f2f7669b0c3781c7688847119d79 (plain) (tree)
1
2
3
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713

                       
                                                    
















                                                                         

                    



                            

                              




                                         

                                     
 





                                                      
                          
                      
                         




                   

                  

                 
                                     

                                            



                                                         

 
                                     
 
                                            



                                                         

 
                                     

                                                          



                                                         

 
                                     









                                                         
                                     













                                                         
                                     





















                                                          


































































































                                                          













































                                                          
 
                                     

                                                



                                                         

 
                                     
 
                                                



                                                         

 
                                     

                                                                  



                                                         

 
                                     









                                                                  
                                     













                                                                  
                                     





















                                                                  

































































































                                                                  













































                                                                  

                     
 
                                  

                                            



                                                         

 
                                  

                                            



                                                         

 
                                  

                                                          



                                                         

 
                                  









                                                          













                                                          













                                                          






































                                                          





















                                                          



















































                                                          
                                          
 
                                            

                                               
                                              
                                                         

 
                                          
 
                                            
                     


                                                         

 
                                          
 
                                                          
                     


                                                         
 
 
                                          
 
                                                          
                     




                                                         

 
                                          
 
                                                          
                     






                                                         

 
                                          
 
                                                          
                     








                                                         

 
                                          
 
                                                          
                     































































































































































































































































































                                                          
                                       
 
                                            

                                               
                                           


                                                         
                                       
 
                                            
                     


                                                         

 
                                       
 
                                                          
                     


                                                         

 
                                       
 
                                                          
                     




                                                         

 
                                       
 
                                                          
                     






                                                         

 
                                       
 
                                                          
                     








                                                         

 
                                       
 
                                                          
                     










                                                         

 
                                       
 
                                                          
                     














                                                         

 
                                       
 
                                                          
                     
















                                                         

 
                                       
 
                                                          
                     

































































































































































































































































































































































































































































































































































                                                                  
                                               
                                              










                                                         
                                           












                                                                  
                                               











                                                         
                                       



                                                
                                           


                                                         
                                       



                                                
                                           


                                                         
                                       



                                                                  
                                           


                                                         
                                       




                                                                  
                                           



                                                         
                                       





                                                                  
                                           




                                                         
                                       






                                                                  
                                           





                                                         
                                       







                                                                  
                                           






                                                         
                                       









                                                                  
                                           








                                                         
                                       










                                                                  
                                           









                                                         
                                       











                                                                  
                                           










                                                         
                                        












                                                                  
                                            











                                                         
                                       



                                                
                                           


                                                         
                                       



                                                
                                           


                                                         
                                       



                                                                  
                                           


                                                         
                                       




                                                                  
                                           



                                                         
                                       





                                                                  
                                           




                                                         
                                       






                                                                  
                                           





                                                         
                                       







                                                                  
                                           






                                                         
                                       









                                                                  
                                           








                                                         
                                       










                                                                  
                                           









                                                         
                                       











                                                                  
                                           










                                                         
                                        












                                                                  



















































































































































































                                                                  











                                                         
 
                            

                                



                                                         

 
                            

                                



                                                         

 
 
                 
                               

                                



                                                         
 
                     


























                                                                

                     






                                       



                             

                                                             


                                         
 


                                                                   



                                     
                                                                             
                   
 

                        













                                                            
                    
                    
                       
 
/*
 *  The ManaPlus Client
 *  Copyright (C) 2013-2017  The ManaPlus Developers
 *
 *  This file is part of The ManaPlus Client.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "catch.hpp"

#include "client.h"
#include "graphicsmanager.h"
#include "logger.h"

#include "being/actorsprite.h"

#include "resources/sdlimagehelper.h"
#ifdef USE_SDL2
#include "resources/surfaceimagehelper.h"
#endif  // USE_SDL2

#include "resources/dye/dye.h"
#include "resources/dye/dyepalette.h"

#include "resources/image/image.h"

#include "resources/loaders/imageloader.h"

#include "resources/resourcemanager/resourcemanager.h"

#include "utils/delete2.h"
#include "utils/env.h"
#include "utils/virtfs.h"

#ifndef USE_SDL2
#include <SDL.h>
#endif  // USE_SDL2

#include "debug.h"

#ifdef USE_OPENGL

TEST_CASE("Dye replaceSOGLColor 1 1")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
    palette.replaceSOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
}

TEST_CASE("Dye replaceSOGLColor 1 2")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[1];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    palette.replaceSOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
}

TEST_CASE("Dye replaceSOGLColor 1 3")
{
    DyePalette palette("#404040,200000,0100ee,102030", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceSOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceSOGLColor 2 1")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[2];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    palette.replaceSOGLColor(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
}

TEST_CASE("Dye replaceSOGLColor 4 1")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[4];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    palette.replaceSOGLColor(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 8 1")
{
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
    uint32_t data[8];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
    palette.replaceSOGLColor(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 1 1 default")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
    palette.replaceSOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
}

TEST_CASE("Dye replaceSOGLColor 1 2 default")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[1];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    palette.replaceSOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
}

TEST_CASE("Dye replaceSOGLColor 1 3 default")
{
    DyePalette palette("#404040,200000,0100ee,102030", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceSOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceSOGLColor 2 1 default")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[2];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    palette.replaceSOGLColorDefault(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
}

TEST_CASE("Dye replaceSOGLColor 4 1 default")
{
    DyePalette palette("#01ff02,030411", 6);
    uint32_t data[4];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    palette.replaceSOGLColorDefault(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 8 1 default")
{
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
    uint32_t data[8];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
    palette.replaceSOGLColorDefault(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 8 1 simd")
{
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
    uint32_t data[8];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
    palette.replaceSOGLColorSimd(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 8 1 sse2")
{
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
    uint32_t data[8];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
    palette.replaceSOGLColorSse2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
}

TEST_CASE("Dye replaceSOGLColor 8 1 avx2")
{
    DyePalette palette("#01ff02,030411,01ee02,010203", 6);
    uint32_t data[8];
    data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
    data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
    data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
    data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
    data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
    palette.replaceSOGLColorAvx2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
    REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
    REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
    REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
    REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
}


TEST_CASE("Dye replaceAOGLColor 1 1")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAOGLColor 1 2")
{
    DyePalette palette("#00ff0120,020311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
    palette.replaceAOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
}

TEST_CASE("Dye replaceAOGLColor 1 3")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 2 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColor(&data[0], 2);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 4 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColor(&data[0], 4);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 8 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColor(&data[0], 8);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 1 1 default")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAOGLColor 1 2 default")
{
    DyePalette palette("#00ff0120,020311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
    palette.replaceAOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
}

TEST_CASE("Dye replaceAOGLColor 1 3 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 2 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorDefault(&data[0], 2);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 4 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorDefault(&data[0], 4);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 8 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorDefault(&data[0], 8);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 8 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorSimd(&data[0], 8);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 8 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorSse2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
}

TEST_CASE("Dye replaceAOGLColor 8 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
    data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
    data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
    data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
    palette.replaceAOGLColorAvx2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
    REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
    REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
    REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
    REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
}
#endif  // USE_OPENGL


TEST_CASE("Dye replaceSColor 1 1")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceSColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceSColor 1 2")
{
    DyePalette palette("#403020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
    palette.replaceSColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 1 3")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    palette.replaceSColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 2 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[2];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColor(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 3 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[3];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
    palette.replaceSColor(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
}

TEST_CASE("Dye replaceSColor 4 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[4];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColor(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 5 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[5];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColor(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 7 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[7];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    palette.replaceSColor(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
}

TEST_CASE("Dye replaceSColor 8 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[8];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    palette.replaceSColor(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
}

TEST_CASE("Dye replaceSColor 9 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[9];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
    palette.replaceSColor(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
}

TEST_CASE("Dye replaceSColor 10 1")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[10];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
    palette.replaceSColor(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
}

TEST_CASE("Dye replaceSColor 1 1 default")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceSColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceSColor 1 2 default")
{
    DyePalette palette("#403020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
    palette.replaceSColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 1 3 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    palette.replaceSColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 2 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[2];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorDefault(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 3 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[3];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
    palette.replaceSColorDefault(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
}

TEST_CASE("Dye replaceSColor 4 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[4];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorDefault(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 5 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[5];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorDefault(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 7 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[7];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    palette.replaceSColorDefault(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
}

TEST_CASE("Dye replaceSColor 8 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[8];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    palette.replaceSColorDefault(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
}

TEST_CASE("Dye replaceSColor 9 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[9];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
    palette.replaceSColorDefault(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
}

TEST_CASE("Dye replaceSColor 10 1 default")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[10];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
    palette.replaceSColorDefault(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
}

TEST_CASE("Dye replaceSColor 1 1 simd")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceSColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceSColor 1 2 simd")
{
    DyePalette palette("#403020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
    palette.replaceSColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 1 3 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    palette.replaceSColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 2 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[2];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSimd(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 3 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[3];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
    palette.replaceSColorSimd(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
}

TEST_CASE("Dye replaceSColor 4 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[4];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSimd(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 5 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[5];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSimd(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 7 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[7];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    palette.replaceSColorSimd(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
}

TEST_CASE("Dye replaceSColor 8 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[8];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    palette.replaceSColorSimd(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
}

TEST_CASE("Dye replaceSColor 9 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[9];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
    palette.replaceSColorSimd(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
}

TEST_CASE("Dye replaceSColor 10 1 simd")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[10];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
    palette.replaceSColorSimd(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
}

TEST_CASE("Dye replaceSColor 1 1 sse2")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceSColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceSColor 1 2 sse2")
{
    DyePalette palette("#403020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
    palette.replaceSColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 1 3 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    palette.replaceSColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 2 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[2];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSse2(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 3 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[3];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
    palette.replaceSColorSse2(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
}

TEST_CASE("Dye replaceSColor 4 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[4];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSse2(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 5 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[5];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorSse2(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 7 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[7];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    palette.replaceSColorSse2(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
}

TEST_CASE("Dye replaceSColor 8 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[8];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    palette.replaceSColorSse2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
}

TEST_CASE("Dye replaceSColor 9 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[9];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
    palette.replaceSColorSse2(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
}

TEST_CASE("Dye replaceSColor 10 1 sse2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[10];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
    palette.replaceSColorSse2(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
}

TEST_CASE("Dye replaceSColor 1 1 avx2")
{
    DyePalette palette("#00ff00,000011", 6);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceSColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceSColor 1 2 avx2")
{
    DyePalette palette("#403020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
    palette.replaceSColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 1 3 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[1];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    palette.replaceSColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
}

TEST_CASE("Dye replaceSColor 2 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[2];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorAvx2(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 3 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[3];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
    palette.replaceSColorAvx2(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
}

TEST_CASE("Dye replaceSColor 4 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[4];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorAvx2(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 5 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[5];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
    palette.replaceSColorAvx2(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
}

TEST_CASE("Dye replaceSColor 7 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[7];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    palette.replaceSColorAvx2(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
}

TEST_CASE("Dye replaceSColor 8 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[8];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    palette.replaceSColorAvx2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
}

TEST_CASE("Dye replaceSColor 9 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[9];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
    palette.replaceSColorAvx2(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
}

TEST_CASE("Dye replaceSColor 10 1 avx2")
{
    DyePalette palette("#123456,000000,ff3020,706050", 6);
    uint32_t data[10];
    data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
    data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
    data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
    data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
    data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
    data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
    data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
    data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
    palette.replaceSColorAvx2(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
    REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
    REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
    REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
    REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
    REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
    REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
    REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
}


TEST_CASE("Dye replaceAColor 1 1")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAColor 1 2")
{
    DyePalette palette("#02ff0120,040311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
    palette.replaceAColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}

TEST_CASE("Dye replaceAColor 1 3")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColor(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 2 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 3 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[3];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 4 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 5 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[5];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 7 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[7];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    palette.replaceAColor(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
}

TEST_CASE("Dye replaceAColor 8 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 9 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[9];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColor(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 10 1")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[10];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColor(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 1 1 default")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAColor 1 2 default")
{
    DyePalette palette("#02ff0120,040311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
    palette.replaceAColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}

TEST_CASE("Dye replaceAColor 1 3 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorDefault(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 2 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 3 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[3];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 4 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 5 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[5];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 7 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[7];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    palette.replaceAColorDefault(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
}

TEST_CASE("Dye replaceAColor 8 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 9 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[9];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorDefault(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 10 1 default")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[10];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorDefault(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 1 1 simd")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAColor 1 2 simd")
{
    DyePalette palette("#02ff0120,040311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
    palette.replaceAColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}

TEST_CASE("Dye replaceAColor 1 3 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorSimd(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 2 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 3 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[3];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 4 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 5 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[5];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 7 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[7];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    palette.replaceAColorSimd(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
}

TEST_CASE("Dye replaceAColor 8 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 9 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[9];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSimd(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 10 1 simd")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[10];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorSimd(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 1 1 sse2")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAColor 1 2 sse2")
{
    DyePalette palette("#02ff0120,040311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
    palette.replaceAColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}

TEST_CASE("Dye replaceAColor 1 3 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorSse2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 2 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 3 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[3];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 4 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 5 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[5];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 7 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[7];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    palette.replaceAColorSse2(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
}

TEST_CASE("Dye replaceAColor 8 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 9 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[9];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorSse2(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 10 1 sse2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[10];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorSse2(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 1 1 avx2")
{
    DyePalette palette("#00ff0010,00001120", 8);
    uint32_t data[1];
    data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
    palette.replaceAColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}

TEST_CASE("Dye replaceAColor 1 2 avx2")
{
    DyePalette palette("#02ff0120,040311ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
    palette.replaceAColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}

TEST_CASE("Dye replaceAColor 1 3 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[1];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorAvx2(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}

TEST_CASE("Dye replaceAColor 2 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[2];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 2);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 3 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[3];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
    data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 3);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
    REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 4 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[4];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 4);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 5 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[5];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
    data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 5);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
    REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 7 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[7];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    palette.replaceAColorAvx2(&data[0], 7);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
}

TEST_CASE("Dye replaceAColor 8 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[8];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 8);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 9 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[9];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    palette.replaceAColorAvx2(&data[0], 9);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
}

TEST_CASE("Dye replaceAColor 10 1 avx2")
{
    DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
    uint32_t data[10];
    data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
    data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
    data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
    data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
    data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
    data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
    palette.replaceAColorAvx2(&data[0], 10);
    REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
    REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
    REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
    REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
    REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
    REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}


TEST_CASE("Dye normalDye 1")
{
    Dye dye("R:#203040,506070");
    uint32_t data[1];
    data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
    dye.normalDye(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x55));
}

TEST_CASE("Dye normalDye 2")
{
    Dye dye("G:#203040,506070");
    uint32_t data[1];
    data[0] = buildHex(0x00, 0x50, 0x00, 0x60);
    dye.normalDye(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x60));
}


#ifdef USE_OPENGL
TEST_CASE("Dye normalOGLDye 1")
{
    Dye dye("R:#203040,506070");
    uint32_t data[1];
    data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
    dye.normalOGLDye(&data[0], 1);
    REQUIRE(data[0] == buildHex(0x50, 0x2a, 0x20, 0x15));
}
#endif  // USE_OPENGL

static void dyeCheck(const std::string &dyeString,
                     const std::string &dstName)
{
    const std::string srcName = "arrow_up.png";

    Image *const image1 = Loader::getImage(srcName + dyeString);
    Image *const image2 = Loader::getImage(dstName);
    REQUIRE(image1 != nullptr);
    REQUIRE(image2 != nullptr);
    SDL_Surface *const surface1 = image1->getSDLSurface();
    SDL_Surface *const surface2 = image2->getSDLSurface();
    REQUIRE(surface1 != nullptr);
    REQUIRE(surface2 != nullptr);
    REQUIRE(surface1->w == surface2->w);
    REQUIRE(surface1->h == surface2->h);
    REQUIRE(surface1->pixels != nullptr);
    REQUIRE(surface2->pixels != nullptr);
    const uint32_t *const ptr1 = static_cast<const uint32_t *>(
        surface1->pixels);
    const uint32_t *const ptr2 = static_cast<const uint32_t *>(
        surface2->pixels);
    const size_t sz = surface1->w * surface1->h;
    for (size_t idx = 0; idx < sz; idx ++)
    {
        REQUIRE(ptr1[idx] == ptr2[idx]);
    }
    image2->decRef();
    image1->decRef();
}

TEST_CASE("Dye real dye")
{
    setEnv("SDL_VIDEODRIVER", "dummy");

    client = new Client;
    dirSeparator = "/";
    SDL_Init(SDL_INIT_VIDEO);
    logger = new Logger();
    ResourceManager::init();
    VirtFs::addDirToSearchPath("data/test", Append_false);
    VirtFs::addDirToSearchPath("../data/test", Append_false);

#ifdef USE_SDL2
    imageHelper = new SurfaceImageHelper;

    SDLImageHelper::setRenderer(graphicsManager.createRenderer(
        graphicsManager.createWindow(640, 480, 0,
        SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
#else  // USE_SDL2

    imageHelper = new SDLImageHelper;

    graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
#endif  // USE_SDL2

    ActorSprite::load();

    SECTION("B dye")
    {
        dyeCheck("|B:#FFC88A", "arrow_up_B.png");
    }

    SECTION("S dye")
    {
        dyeCheck("|S:#0000FF,FF0000", "arrow_up_S.png");
    }

    SECTION("A dye")
    {
        dyeCheck("|A:#0000FFFF,FF000050", "arrow_up_A.png");
    }
    delete2(client);
    delete2(logger);
//    VirtFs::deinit();
}