summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-07 17:05:13 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-07 17:53:24 +0300
commit130f07fd84bfdf781eb42903b3fcbabc26199a3a (patch)
treee4e560c32177e0a64867c5d1584d9bf64b57bbce /src/resources
parent9bbd191307c97c7589f93a64a4eb9abf3f11c46b (diff)
downloadplus-130f07fd84bfdf781eb42903b3fcbabc26199a3a.tar.gz
plus-130f07fd84bfdf781eb42903b3fcbabc26199a3a.tar.bz2
plus-130f07fd84bfdf781eb42903b3fcbabc26199a3a.tar.xz
plus-130f07fd84bfdf781eb42903b3fcbabc26199a3a.zip
Move unit tests into unittests directory.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/dye/dye_unittest.cc2020
-rw-r--r--src/resources/dye/dyepalette_unittest.cc422
-rw-r--r--src/resources/map/maplayer_unittest.cc3213
-rw-r--r--src/resources/map/speciallayer_unittest.cc291
-rw-r--r--src/resources/mstack_unittest.cc165
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc701
-rw-r--r--src/resources/sdlimagehelper_unittest.cc541
-rw-r--r--src/resources/sprite/animatedsprite_unittest.cc220
8 files changed, 0 insertions, 7573 deletions
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
deleted file mode 100644
index 87ac73fbf..000000000
--- a/src/resources/dye/dye_unittest.cc
+++ /dev/null
@@ -1,2020 +0,0 @@
-/*
- * 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 "test/unittests.h"
-
-#include "client.h"
-#include "graphicsmanager.h"
-#include "logger.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.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"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifdef USE_OPENGL
-
-TEST_CASE("Dye leak test1", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 1", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
- DYEPALETTE(palette, SOGLColor)(&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);
- DYEPALETTE(palette, SOGLColor)(&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);
- DYEPALETTE(palette, SOGLColor)(&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);
- DYEPALETTE(palette, SOGLColor)(&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);
- DYEPALETTE(palette, SOGLColor)(&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);
- DYEPALETTE(palette, SOGLColor)(&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 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);
- DYEPALETTE(palette, SOGLColorSse2)(&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);
- DYEPALETTE(palette, SOGLColorAvx2)(&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);
- DYEPALETTE(palette, AOGLColor)(&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);
- DYEPALETTE(palette, AOGLColor)(&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);
- DYEPALETTE(palette, AOGLColor)(&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);
- DYEPALETTE(palette, AOGLColor)(&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);
- DYEPALETTE(palette, AOGLColor)(&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);
- DYEPALETTE(palette, AOGLColor)(&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 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);
- DYEPALETTE(palette, AOGLColorSse2)(&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);
- DYEPALETTE(palette, AOGLColorAvx2)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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);
- DYEPALETTE(palette, SColor)(&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 sse2", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorSse2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, SColorAvx2)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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);
- DYEPALETTE(palette, AColor)(&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 sse2", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorSse2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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);
- DYEPALETTE(palette, AColorAvx2)(&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;
- SDL_Init(SDL_INIT_VIDEO);
- logger = new Logger();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../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);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
- delete2(logger);
-// VirtFs::deinit();
-}
-
-TEST_CASE("Dye leak test2", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc
deleted file mode 100644
index c7d64d918..000000000
--- a/src/resources/dye/dyepalette_unittest.cc
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * 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 "test/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/db/palettedb.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-TEST_CASE("DyePalette leak test1", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
-
-TEST_CASE("DyePalette tests", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- logger = new Logger();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- getConfigDefaults2(config.getDefaultValues());
- branding.setDefaultValues(getBrandingDefaults());
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
- paths.setDefaultValues(getPathsDefaults());
- PaletteDB::load();
-
- SECTION("simple test 1")
- {
- DyePalette palette("#12ff34", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("simple test 2")
- {
- DyePalette palette("#12ff3456", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("simple test 3")
- {
- DyePalette palette("#12ff34,002211", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("simple test 4")
- {
- DyePalette palette("#12ff3412,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("simple test 5")
- {
- DyePalette palette("#12ff34,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("simple test 6")
- {
- DyePalette palette("#12ff3456,", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("simple test 7")
- {
- DyePalette palette("#,,,12ff3412,,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 1")
- {
- DyePalette palette("@Untitled1", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
- }
-
- SECTION("palette test 2")
- {
- DyePalette palette("@Untitled1,Untitled8", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 255);
- }
-
- SECTION("palette test 3")
- {
- DyePalette palette("@Untitled1,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
- }
-
- SECTION("palette test 4")
- {
- DyePalette palette("@,,,Untitled1,,Untitled8", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 255);
- }
-
- SECTION("palette test 5")
- {
- DyePalette palette("@12ff34", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("palette test 6")
- {
- DyePalette palette("@12ff3456", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("palette test 7")
- {
- DyePalette palette("@12ff34,002211", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("palette test 8")
- {
- DyePalette palette("@12ff3412,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 9")
- {
- DyePalette palette("@12ff34,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("palette test 10")
- {
- DyePalette palette("@12ff3456,", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("palette test 11")
- {
- DyePalette palette("@,,,12ff3412,,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 12")
- {
- DyePalette palette("@Untitled1,334455", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0x33);
- REQUIRE(palette.mColors[1].value[1] == 0x44);
- REQUIRE(palette.mColors[1].value[2] == 0x55);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("palette test 13")
- {
- DyePalette palette("@Untitled1,33445566", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0x33);
- REQUIRE(palette.mColors[1].value[1] == 0x44);
- REQUIRE(palette.mColors[1].value[2] == 0x55);
- REQUIRE(palette.mColors[1].value[3] == 0x66);
- }
-
- SECTION("palette test 14")
- {
- DyePalette palette("@+77,Untitled1", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x77);
- }
-
- SECTION("palette test 15")
- {
- DyePalette palette("@+87,Untitled1,Untitled8", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x87);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 0x87);
- }
-
- SECTION("palette test 16")
- {
- DyePalette palette("@+87,Untitled1,+34,Untitled8", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x87);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 0x34);
- }
-
- SECTION("palette test 17")
- {
- DyePalette palette("@+12,+23,+77,Untitled1", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x77);
- }
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
- delete2(logger);
-// VirtFs::deinit();
-}
-
-TEST_CASE("DyePalette leak test2", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
diff --git a/src/resources/map/maplayer_unittest.cc b/src/resources/map/maplayer_unittest.cc
deleted file mode 100644
index 194128815..000000000
--- a/src/resources/map/maplayer_unittest.cc
+++ /dev/null
@@ -1,3213 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 "test/unittests.h"
-
-#include "graphicsmanager.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/map/blockmask.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/theme.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "render/mockgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer getTileDrawWidth", "")
-{
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
- int width;
- int nextTile;
-
- SECTION("simple 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
- }
-
- SECTION("simple 3")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 2,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4.2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
- }
-
- SECTION("simple 6")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 7")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[1].isEnabled = false;
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
-// REQUIRE(layer->getTileDrawWidth(tiles + 1,
-// 2,
-// width,
-// nextTile) == 0);
-// REQUIRE(width == 32);
-// REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 8")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
-// REQUIRE(layer->getTileDrawWidth(tiles,
-// 3,
-// width,
-// nextTile) == 1);
-// REQUIRE(width == 0);
-// REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 1,
- 100 - 1,
- width,
- nextTile) == 2);
- REQUIRE(width == 96);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 2,
- 100 - 2,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 3,
- 100 - 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 4,
- 100 - 4,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 6,
- 100 - 6,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 9,
- 100 - 9,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 10,
- 100 - 10,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 11,
- 100 - 11,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 3);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 15,
- 100 - 15,
- width,
- nextTile) == 2);
- REQUIRE(width == 96);
- REQUIRE(nextTile == 84);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 16,
- 100 - 16,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 83);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 17,
- 100 - 17,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 82);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
-
-
-TEST_CASE("MapLayer getEmptyTileDrawWidth", "")
-{
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
- int nextTile;
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1,
- 1,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1,
- 2,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 2,
- 1,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 0,
- 100 - 0,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 5,
- 100 - 5,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 7,
- 100 - 7,
- nextTile) == 1);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 8,
- 100 - 8,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 12,
- 100 - 12,
- nextTile) == 2);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 13,
- 100 - 13,
- nextTile) == 1);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 14,
- 100 - 14,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
-
-
-TEST_CASE("MapLayer updateCache", "")
-{
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(1, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- }
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == false);
- REQUIRE(tiles[1].width == 0);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 3")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 4.2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == false);
- REQUIRE(tiles[1].width == 0);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 2);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 1);
- REQUIRE(tiles[2].isEnabled == false);
- REQUIRE(tiles[2].width == 0);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 6")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 7")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == false);
- REQUIRE(tiles[0].width == 0);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(100, 100);
-
- REQUIRE(tiles[0 * 100 + 0].isEnabled == false);
- REQUIRE(tiles[0 * 100 + 0].width == 0);
- REQUIRE(tiles[0 * 100 + 0].count == 99);
- REQUIRE(tiles[0 * 100 + 0].nextTile == 99);
-
- REQUIRE(tiles[0 * 100 + 1].isEnabled == false);
- REQUIRE(tiles[0 * 100 + 1].width == 0);
- REQUIRE(tiles[0 * 100 + 1].count == 98);
- REQUIRE(tiles[0 * 100 + 1].nextTile == 98);
-
- REQUIRE(tiles[10 * 100 + 0].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 0].width == 0);
- REQUIRE(tiles[10 * 100 + 0].count == 0);
- REQUIRE(tiles[10 * 100 + 0].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 1].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 1].width == 96);
- REQUIRE(tiles[10 * 100 + 1].count == 2);
- REQUIRE(tiles[10 * 100 + 1].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 2].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 2].width == 64);
- REQUIRE(tiles[10 * 100 + 2].count == 1);
- REQUIRE(tiles[10 * 100 + 2].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 3].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 3].width == 32);
- REQUIRE(tiles[10 * 100 + 3].count == 0);
- REQUIRE(tiles[10 * 100 + 3].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 4].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 4].width == 32);
- REQUIRE(tiles[10 * 100 + 4].count == 0);
- REQUIRE(tiles[10 * 100 + 4].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 5].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 5].width == 0);
- REQUIRE(tiles[10 * 100 + 5].count == 0);
- REQUIRE(tiles[10 * 100 + 5].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 6].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 6].width == 32);
- REQUIRE(tiles[10 * 100 + 6].count == 0);
- REQUIRE(tiles[10 * 100 + 6].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 7].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 7].width == 0);
- REQUIRE(tiles[10 * 100 + 7].count == 1);
- REQUIRE(tiles[10 * 100 + 7].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 8].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 8].width == 0);
- REQUIRE(tiles[10 * 100 + 8].count == 0);
- REQUIRE(tiles[10 * 100 + 8].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 9].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 9].width == 64);
- REQUIRE(tiles[10 * 100 + 9].count == 1);
- REQUIRE(tiles[10 * 100 + 9].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 10].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 10].width == 32);
- REQUIRE(tiles[10 * 100 + 10].count == 0);
- REQUIRE(tiles[10 * 100 + 10].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 11].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 11].width == 32);
- REQUIRE(tiles[10 * 100 + 11].count == 0);
- REQUIRE(tiles[10 * 100 + 11].nextTile == 3);
-
- REQUIRE(tiles[10 * 100 + 12].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 12].width == 0);
- REQUIRE(tiles[10 * 100 + 12].count == 2);
- REQUIRE(tiles[10 * 100 + 12].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 13].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 13].width == 0);
- REQUIRE(tiles[10 * 100 + 13].count == 1);
- REQUIRE(tiles[10 * 100 + 13].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 14].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 14].width == 0);
- REQUIRE(tiles[10 * 100 + 14].count == 0);
- REQUIRE(tiles[10 * 100 + 14].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 15].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 15].width == 96);
- REQUIRE(tiles[10 * 100 + 15].count == 2);
- REQUIRE(tiles[10 * 100 + 15].nextTile == 84);
-
- REQUIRE(tiles[10 * 100 + 16].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 16].width == 64);
- REQUIRE(tiles[10 * 100 + 16].count == 1);
- REQUIRE(tiles[10 * 100 + 16].nextTile == 83);
-
- REQUIRE(tiles[10 * 100 + 17].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 17].width == 32);
- REQUIRE(tiles[10 * 100 + 17].count == 0);
- REQUIRE(tiles[10 * 100 + 17].nextTile == 82);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- REQUIRE(tiles[10 * maxX + 0].isEnabled == false);
- REQUIRE(tiles[10 * maxX + 0].width == 0);
- REQUIRE(tiles[10 * maxX + 0].count == 40);
- REQUIRE(tiles[10 * maxX + 0].nextTile == 40);
-
- REQUIRE(tiles[10 * maxX + 1].isEnabled == false);
- REQUIRE(tiles[10 * maxX + 1].width == 0);
- REQUIRE(tiles[10 * maxX + 1].count == 39);
- REQUIRE(tiles[10 * maxX + 1].nextTile == 39);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
-
-TEST_CASE("MapLayer updateConditionTiles", "")
-{
- Image *const img1 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(0, 0, BlockType::NONE);
- layer->updateConditionTiles(map->getMetaTiles(),
- 1, 1);
- REQUIRE(tiles[0].isEnabled == false);
-
- map->addBlockMask(0, 0, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 1, 1);
- REQUIRE(tiles[0].isEnabled == true);
- }
-
- SECTION("normal 1")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- layer->setTile(10, 30, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::NONE);
- map->addBlockMask(10, 20, BlockType::NONE);
- map->addBlockMask(20, 20, BlockType::NONE);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
-
- SECTION("normal 2")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- layer->setTile(10, 30, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::WATER);
- map->addBlockMask(10, 20, BlockType::WATER);
- map->addBlockMask(20, 20, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- SECTION("normal 3")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- layer->setTile(x, y, img1);
- }
- }
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::WATER);
- map->addBlockMask(10, 20, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- SECTION("normal 4")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- map->addBlockMask(x, y, BlockType::WATER);
- }
- }
-
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- delete map;
- delete img1;
-}
-
-TEST_CASE("MapLayer draw", "")
-{
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- MockGraphics *const mock = new MockGraphics;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->updateCache(1, 1);
-
- layer->draw(mock,
- 0, 0,
- 1, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 1, 1,
- 10, 5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 1, 1,
- -10, -5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
-
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 10, 5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, -5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, -20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 42);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 4.2")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 10, -20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 54);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img1);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 42);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- layer->updateCache(maxX, maxY);
-
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- map->addLayer(layer);
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- }
-
- delete map;
- delete img1;
- delete img2;
- delete img3;
- delete mock;
-}
-
-TEST_CASE("MapLayer drawSpecialLayer (specialLayer)", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- logger = new Logger;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- SpecialLayer *specialLayer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
-// REQUIRE(mock->mDraws.size() == 1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 8")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 3);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 64);
- REQUIRE(mock->mDraws[2].y == 0);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 50;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 5, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(3, 5, MapItemType::EMPTY);
- specialLayer->setTile(4, 5, MapItemType::EMPTY);
- specialLayer->setTile(6, 5, MapItemType::ARROW_LEFT);
- specialLayer->setTile(10, 20, MapItemType::ARROW_LEFT);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 5,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 4);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0 * 32);
- REQUIRE(mock->mDraws[0].y == 5 * 32);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 1 * 32);
- REQUIRE(mock->mDraws[1].y == 5 * 32);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 2 * 32);
- REQUIRE(mock->mDraws[2].y == 5 * 32);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 6 * 32);
- REQUIRE(mock->mDraws[3].y == 5 * 32);
-
- mock->mDraws.clear();
- layer->drawSpecialLayer(mock,
- 4,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 6,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 20,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10 * 32);
- REQUIRE(mock->mDraws[0].y == 20 * 32);
- }
-
- delete map;
- delete mock;
- GraphicsManager::deleteRenderers();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-}
-
-TEST_CASE("MapLayer drawSpecialLayer (tempLayer)", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- logger = new Logger;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- SpecialLayer *specialLayer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
-// REQUIRE(mock->mDraws.size() == 1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- const int *const cache = specialLayer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
-
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 8")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 3);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 64);
- REQUIRE(mock->mDraws[2].y == 0);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 50;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 5, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(3, 5, MapItemType::EMPTY);
- specialLayer->setTile(4, 5, MapItemType::EMPTY);
- specialLayer->setTile(6, 5, MapItemType::ARROW_LEFT);
- specialLayer->setTile(10, 20, MapItemType::ARROW_LEFT);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 5,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 4);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0 * 32);
- REQUIRE(mock->mDraws[0].y == 5 * 32);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 1 * 32);
- REQUIRE(mock->mDraws[1].y == 5 * 32);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 2 * 32);
- REQUIRE(mock->mDraws[2].y == 5 * 32);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 6 * 32);
- REQUIRE(mock->mDraws[3].y == 5 * 32);
-
- mock->mDraws.clear();
- layer->drawSpecialLayer(mock,
- 4,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 6,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 20,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10 * 32);
- REQUIRE(mock->mDraws[0].y == 20 * 32);
- }
-
- delete map;
- delete mock;
- GraphicsManager::deleteRenderers();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-}
-
-TEST_CASE("MapLayer drawFringe", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- logger = new Logger;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(1, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- 10, 5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- -10, -5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
-
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 10, 5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, -5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, -20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 42);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 4.2")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 10, -20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 54);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img1);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 42);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- }
-
- SECTION("normal 3")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- SpecialLayer *const specialLayer = map->getSpecialLayer();
- SpecialLayer *const tempLayer = map->getTempLayer();
- layer->setSpecialLayer(specialLayer);
- layer->setTempLayer(tempLayer);
- specialLayer->setTile(1, 10, MapItemType::ARROW_UP);
- specialLayer->setTile(10, 10, MapItemType::ARROW_DOWN);
- specialLayer->updateCache();
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 1);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
-// REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11);
- REQUIRE(mock->mDraws[6].y == 32 * 10);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15);
- REQUIRE(mock->mDraws[7].y == 32 * 10);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[6].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[7].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
- }
-
- SECTION("normal 4")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- SpecialLayer *const specialLayer = map->getSpecialLayer();
- SpecialLayer *const tempLayer = map->getTempLayer();
- layer->setSpecialLayer(specialLayer);
- layer->setTempLayer(tempLayer);
- specialLayer->setTile(0, 10, MapItemType::ARROW_UP);
- specialLayer->setTile(10, 10, MapItemType::ARROW_DOWN);
- specialLayer->setTile(90, 10, MapItemType::ARROW_DOWN);
- specialLayer->updateCache();
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX - 20, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 0);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-// REQUIRE(mock->mDraws[0].image == img2);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[1].x == 32 * 1);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].width == 96);
- REQUIRE(mock->mDraws[1].height == 32);
- REQUIRE(mock->mDraws[1].image == img1);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11);
- REQUIRE(mock->mDraws[6].y == 32 * 10);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15);
- REQUIRE(mock->mDraws[7].y == 32 * 10);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX - 20, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 0 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[0].image == img2);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[1].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].width == 96);
- REQUIRE(mock->mDraws[1].height == 32);
- REQUIRE(mock->mDraws[1].image == img1);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[6].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[7].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
- }
-
- delete2(localPlayer);
- delete map;
- delete img1;
- delete img2;
- delete img3;
- delete mock;
- delete2(theme);
- GraphicsManager::deleteRenderers();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-}
diff --git a/src/resources/map/speciallayer_unittest.cc b/src/resources/map/speciallayer_unittest.cc
deleted file mode 100644
index af84d6a77..000000000
--- a/src/resources/map/speciallayer_unittest.cc
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 "test/unittests.h"
-
-#include "client.h"
-#include "logger.h"
-
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/map/speciallayer.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-TEST_CASE("SpecialLayer leak test1", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
-
-TEST_CASE("SpecialLayer updateCache", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- logger = new Logger;
- client = new Client;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- ActorSprite::load();
-
- SpecialLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- layer = new SpecialLayer("test",
- 1, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- }
-
- SECTION("simple 2")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 3")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_DOWN);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 4")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 4.2")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(2, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 1);
- REQUIRE(cache[1] == 0);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 5")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 6")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- layer->setTile(2, 0, MapItemType::ARROW_DOWN);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 0);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 7")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 8")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::EMPTY);
- layer->setTile(1, 0, MapItemType::EMPTY);
- layer->setTile(2, 0, MapItemType::EMPTY);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 9")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("normal 1")
- {
- layer = new SpecialLayer("test",
- 100, 100);
- layer->setTile(1, 10, MapItemType::ARROW_UP);
- layer->setTile(2, 10, MapItemType::ARROW_UP);
- layer->setTile(3, 10, MapItemType::ARROW_UP);
- layer->setTile(4, 10, MapItemType::ARROW_DOWN);
- layer->setTile(5, 10, MapItemType::EMPTY);
- layer->setTile(6, 10, MapItemType::ARROW_DOWN);
- layer->setTile(7, 10, MapItemType::EMPTY);
- layer->setTile(8, 10, MapItemType::EMPTY);
- layer->setTile(9, 10, MapItemType::ARROW_DOWN);
- layer->setTile(10, 10, MapItemType::ARROW_DOWN);
- layer->setTile(11, 10, MapItemType::ARROW_LEFT);
- layer->setTile(12, 10, MapItemType::EMPTY);
- layer->setTile(13, 10, MapItemType::EMPTY);
- layer->setTile(14, 10, MapItemType::EMPTY);
- layer->setTile(15, 10, MapItemType::ARROW_UP);
- layer->setTile(16, 10, MapItemType::ARROW_UP);
- layer->setTile(17, 10, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
-
- REQUIRE(cache[10 * 100 + 0] == 0);
- REQUIRE(cache[10 * 100 + 1] == 0);
- REQUIRE(cache[10 * 100 + 2] == 0);
- REQUIRE(cache[10 * 100 + 3] == 0);
- REQUIRE(cache[10 * 100 + 4] == 1);
- REQUIRE(cache[10 * 100 + 5] == 0);
- REQUIRE(cache[10 * 100 + 6] == 2);
- REQUIRE(cache[10 * 100 + 7] == 1);
- REQUIRE(cache[10 * 100 + 8] == 0);
- REQUIRE(cache[10 * 100 + 9] == 0);
- REQUIRE(cache[10 * 100 + 10] == 0);
- REQUIRE(cache[10 * 100 + 11] == 3);
- REQUIRE(cache[10 * 100 + 12] == 2);
- REQUIRE(cache[10 * 100 + 13] == 1);
- REQUIRE(cache[10 * 100 + 14] == 0);
- REQUIRE(cache[10 * 100 + 15] == 0);
- REQUIRE(cache[10 * 100 + 16] == 0);
- REQUIRE(cache[10 * 100 + 17] == 10000);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- layer = new SpecialLayer("test",
- maxX, maxY);
- const int *const cache = layer->getCache();
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, MapItemType::ARROW_UP);
- REQUIRE(layer->getTiles()[x + y * maxX] != nullptr);
- }
- }
- layer->updateCache();
-
- for (int y = 0; y < maxY; y ++)
- {
- for (int x = 0; x < maxX - 1; x ++)
- {
- REQUIRE(cache[y * maxX + x] == 0);
- }
- REQUIRE(cache[y * maxX + maxX - 1] == 10000);
- }
- }
-
- delete layer;
- ResourceManager::cleanOrphans();
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-}
-
-TEST_CASE("SpecialLayer leak test2", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
diff --git a/src/resources/mstack_unittest.cc b/src/resources/mstack_unittest.cc
deleted file mode 100644
index c45015680..000000000
--- a/src/resources/mstack_unittest.cc
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2015-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 "test/unittests.h"
-
-#include "gui/cliprect.h"
-
-#include "resources/mstack.h"
-
-#include "debug.h"
-
-TEST_CASE("mstack push 1", "")
-{
- MStack<ClipRect> stack(10);
- REQUIRE(-1 == (stack.mPointer - stack.mStack));
- REQUIRE(0 == stack.mStack[0].xOffset);
-
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- ClipRect &val2 = stack.top();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
-
- val2.yOffset = 2;
- REQUIRE(2 == val1.yOffset);
-}
-
-TEST_CASE("mstack push 2", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- const ClipRect &val2 = stack.top();
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- val1.yOffset = 2;
- REQUIRE(2 == val2.yOffset);
- REQUIRE(2 == stack.mStack[0].yOffset);
-}
-
-TEST_CASE("mstack push 3", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- ClipRect &val2 = stack.top();
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
-}
-
-TEST_CASE("mstack push 4", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == val1.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-
- ClipRect &val2 = stack.push();
- val2.xOffset = 20;
- REQUIRE(20 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-
- ClipRect &val3 = stack.push();
- val3.xOffset = 30;
- REQUIRE(30 == val3.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(30 == stack.mStack[2].xOffset);
-}
-
-TEST_CASE("mstack pop 1", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- stack.pop();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
-}
-
-TEST_CASE("mstack pop 2", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- REQUIRE(0 == stack.mPointer - stack.mStack);
-
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- ClipRect &val2 = stack.push();
- REQUIRE(1 == stack.mPointer - stack.mStack);
-
- val2.xOffset = 20;
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
-
- stack.pop();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
-
- ClipRect &val3 = stack.top();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == val1.xOffset);
- REQUIRE(20 == val2.xOffset);
- REQUIRE(10 == val3.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-}
-
-TEST_CASE("mstack clear 1", "")
-{
- MStack<ClipRect> stack(10);
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(0 == stack.mStack[0].xOffset);
-
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
-
- stack.clear();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
-}
-
-TEST_CASE("mstack getpop 1", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(10 == val1.xOffset);
-
- ClipRect &val2 = stack.getPop();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(10 == val2.xOffset);
-}
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
deleted file mode 100644
index 2efbc2ab1..000000000
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * 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 "test/unittests.h"
-
-#include "client.h"
-#include "dirs.h"
-#include "logger.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-
-#include <unistd.h>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace
-{
- int testResouceCounter = 0;
-
- class TestResource : public Resource
- {
- public:
- TestResource() :
- Resource()
- {
- testResouceCounter ++;
- }
-
- ~TestResource()
- {
- testResouceCounter --;
- }
- };
-
- struct TestLoader final
- {
- std::string path;
- static Resource *load(const void *const v)
- {
- BLOCK_START("TestLoader::load")
- if (v == nullptr)
- {
- BLOCK_END("TestLoader::load")
- return nullptr;
- }
-
- Resource *const res = new TestResource();
- BLOCK_END("TestLoader::load")
- return res;
- }
- };
-
-} // namespace
-
-TEST_CASE("resourcemanager leak test1", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
-
-TEST_CASE("resourcemanager", "resourcemanager")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- logger = new Logger();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper();
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- ActorSprite::load();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
-// ConfigManager::initConfiguration();
-// getConfigDefaults2(config.getDefaultValues());
-
- while (ResourceManager::cleanOrphans(true))
- continue;
-
- testResouceCounter = 0;
- const size_t resSize = ResourceManager::getResources().size();
-
- SECTION("resourcemanager get 0")
- {
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager get 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 2")
- {
- TestLoader rl = { "test1" };
- Resource *const res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(res->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(res2->mRefCount == 2);
- REQUIRE(res->mIdPath == res2->mIdPath);
- REQUIRE(res2->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 3")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 4")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res->mIdPath == res2->mIdPath);
- REQUIRE(res2->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 5")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- sleep(33);
- ResourceManager::cleanOrphans();
- REQUIRE(ResourceManager::isInCache("test1") == false);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res2->decRef();
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 6")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test2",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getResources()["test2"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 1")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::getFromCache("test1");
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 2);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 2")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- Resource *const res2 = ResourceManager::getFromCache("test1");
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 3")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test2",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getResources()["test2"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const resC = ResourceManager::getFromCache("test1");
- Resource *const res2C = ResourceManager::getFromCache("test2");
- REQUIRE(resC != nullptr);
- REQUIRE(res2C != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res == resC);
- REQUIRE(res2 == res2C);
- REQUIRE(resC->mRefCount == 2);
- REQUIRE(res2C->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == resC);
- REQUIRE(ResourceManager::getResources()["test2"] == res2C);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- res->decRef();
- res->decRef();
- res2->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager addResource 1")
- {
- REQUIRE(testResouceCounter == 0);
- Resource *res = new TestResource();
- REQUIRE(testResouceCounter == 1);
- ResourceManager::addResource("test1", res);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager isInCache 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- REQUIRE(ResourceManager::isInCache("test1") == false);
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(ResourceManager::isInCache("test2") == false);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getTempResource 1")
- {
- TestLoader rl = { "test1" };
- REQUIRE(ResourceManager::getTempResource("test1") == nullptr);
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::getTempResource("test1");
- REQUIRE(ResourceManager::getTempResource("test2") == nullptr);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager moveToDeleted 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager moveToDeleted 2")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
- res->decRef();
- }
-
- SECTION("resourcemanager moveToDeleted 3")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- res->decRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager decRefDelete 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- ResourceManager::decRefDelete(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager cleanUp 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
-
- ResourceManager::cleanUp(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::getOrphanedResources().clear();
- }
-
- SECTION("resourcemanager cleanProtected 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mProtected = true;
- ResourceManager::cleanProtected();
-
- REQUIRE(testResouceCounter == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- }
-
- SECTION("resourcemanager clearDeleted 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
-
- ResourceManager::clearDeleted();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
- res->decRef();
- }
-
- SECTION("resourcemanager clearDeleted 2")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
-
- res->decRef();
- ResourceManager::clearDeleted();
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-// VirtFs::deinit();
-}
-
-TEST_CASE("resourcemanager leak test2", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
diff --git a/src/resources/sdlimagehelper_unittest.cc b/src/resources/sdlimagehelper_unittest.cc
deleted file mode 100644
index 517054b1b..000000000
--- a/src/resources/sdlimagehelper_unittest.cc
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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/>.
- */
-
-#ifndef USE_SDL2
-#include "localconsts.h"
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_endian.h>
-PRAGMA48(GCC diagnostic pop)
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#include "test/unittests.h"
-
-#include "client.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "debug.h"
-
-static SDL_Surface *createSoftware32BitSurface(int width,
- int height)
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- return MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height, 32, rmask, gmask, bmask, amask);
-}
-
-TEST_CASE("sdlimagehelper combineSurface", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- logger = new Logger();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper;
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- ActorSprite::load();
-
- SECTION("empty copy1")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff000000;
- ptr2[1] = 0x00ff0000;
- ptr2[2] = 0x0000ff00;
- ptr2[3] = 0x000000ff;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- // src image test
- REQUIRE(ptr2[0] == 0xff000000);
- REQUIRE(ptr2[1] == 0x00ff0000);
- REQUIRE(ptr2[2] == 0x0000ff00);
- REQUIRE(ptr2[3] == 0x000000ff);
-
- REQUIRE(ptr1[0] == 0xff000000);
- REQUIRE(ptr1[1] == 0xff000000);
- REQUIRE(ptr1[2] == 0xff000000);
- REQUIRE(ptr1[3] == 0xff000000);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy2")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff112233;
- ptr2[1] = 0xff003344;
- ptr2[2] = 0xff330055;
- ptr2[3] = 0xff445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff112233);
- REQUIRE(ptr1[1] == 0xff003344);
- REQUIRE(ptr1[2] == 0xff330055);
- REQUIRE(ptr1[3] == 0xff445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy3")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0x00000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff112233;
- ptr2[1] = 0xff003344;
- ptr2[2] = 0xff330055;
- ptr2[3] = 0xff445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff112233);
- REQUIRE(ptr1[1] == 0xff003344);
- REQUIRE(ptr1[2] == 0xff330055);
- REQUIRE(ptr1[3] == 0xff445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy4")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50112233;
- ptr2[1] = 0x50003344;
- ptr2[2] = 0x50330055;
- ptr2[3] = 0x50445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff09121c);
- REQUIRE(ptr1[1] == 0xff001c25);
- REQUIRE(ptr1[2] == 0xff1c002f);
- REQUIRE(ptr1[3] == 0xff252f00);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy5")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0x00000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50112233;
- ptr2[1] = 0x50003344;
- ptr2[2] = 0x50330055;
- ptr2[3] = 0x50445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x8e09121c);
- REQUIRE(ptr1[1] == 0x8e001c25);
- REQUIRE(ptr1[2] == 0x8e1c002f);
- REQUIRE(ptr1[3] == 0x8e252f00);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy6")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x50112233;
- ptr1[1] = 0x50003344;
- ptr1[2] = 0x50330055;
- ptr1[3] = 0x50445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- for (int f = 0; f < 2 * 2; f ++)
- ptr2[f] = 0x00000000;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x50112233);
- REQUIRE(ptr1[1] == 0x50003344);
- REQUIRE(ptr1[2] == 0x50330055);
- REQUIRE(ptr1[3] == 0x50445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("mix 1")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x50112233;
- ptr1[1] = 0x50003344;
- ptr1[2] = 0x50330055;
- ptr1[3] = 0x50445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x50330055;
- ptr2[2] = 0x50445500;
- ptr2[3] = 0x50112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xdf082b3c);
- REQUIRE(ptr1[1] == 0xdf1d174d);
- REQUIRE(ptr1[2] == 0xdf3d2f26);
- REQUIRE(ptr1[3] == 0xdf29391c);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("mix 2")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x10112233;
- ptr1[1] = 0x20003344;
- ptr1[2] = 0x30330055;
- ptr1[3] = 0x40445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x9f082b3c);
- REQUIRE(ptr1[1] == 0xbd1f144e);
- REQUIRE(ptr1[2] == 0xb93f391e);
- REQUIRE(ptr1[3] == 0xf5213224);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 1")
- {
-// 11 11 00 00
-// 11 11 00 00
-// 00 00 00 00
-// 00 00 00 00
-
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x10112233;
- ptr1[1] = 0x20003344;
- ptr1[2] = 0x10203040;
- ptr1[3] = 0x20304050;
- ptr1[4] = 0x30330055;
- ptr1[5] = 0x40445500;
- ptr1[6] = 0x30405060;
- ptr1[7] = 0x708090a0;
-
- ptr1[8] = 0x8090a0b0;
- ptr1[9] = 0x90a0b0c0;
- ptr1[10] = 0xa0b0c0d0;
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x9f082b3c);
- REQUIRE(ptr1[1] == 0xbd1f144e);
- REQUIRE(ptr1[2] == 0x10203040);
- REQUIRE(ptr1[3] == 0x20304050);
- REQUIRE(ptr1[4] == 0xb93f391e);
- REQUIRE(ptr1[5] == 0xf5213224);
- REQUIRE(ptr1[6] == 0x30405060);
- REQUIRE(ptr1[7] == 0x708090a0);
-
- REQUIRE(ptr1[8] == 0x8090a0b0);
- REQUIRE(ptr1[9] == 0x90a0b0c0);
- REQUIRE(ptr1[10] == 0xa0b0c0d0);
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 2")
- {
-// 00 00 00 00
-// 00 11 11 00
-// 00 11 11 00
-// 00 00 00 00
-
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
-
- ptr1[0] = 0x10203040;
- ptr1[1] = 0x20304050;
- ptr1[2] = 0x30405060;
- ptr1[3] = 0x708090a0;
- ptr1[4] = 0x8090a0b0;
-
- ptr1[5] = 0x10112233; // +
- ptr1[6] = 0x20003344; // +
-
- ptr1[7] = 0x90a0b0c0;
- ptr1[8] = 0xa0b0c0d0;
-
- ptr1[9] = 0x30330055; // +
- ptr1[10] = 0x40445500; // +
-
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDL_Rect rect1;
- SDL_Rect rect2;
- rect1.x = 1;
- rect1.y = 1;
- rect1.w = 2;
- rect1.h = 2;
- rect2.x = 0;
- rect2.y = 0;
- rect2.w = 2;
- rect2.h = 2;
- SDLImageHelper::combineSurface(surface2,
- &rect2,
- surface1,
- &rect1);
-
- REQUIRE(ptr1[0] == 0x10203040);
- REQUIRE(ptr1[1] == 0x20304050);
- REQUIRE(ptr1[2] == 0x30405060);
- REQUIRE(ptr1[3] == 0x708090a0);
- REQUIRE(ptr1[4] == 0x8090a0b0);
-
- REQUIRE(ptr1[5] == 0x9f082b3c); // +
- REQUIRE(ptr1[6] == 0xbd1f144e); // +
-
- REQUIRE(ptr1[7] == 0x90a0b0c0);
- REQUIRE(ptr1[8] == 0xa0b0c0d0);
-
- REQUIRE(ptr1[9] == 0xb93f391e); // +
- REQUIRE(ptr1[10] == 0xf5213224); // +
-
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 3")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
-
- ptr1[0] = 0x10203040;
- ptr1[1] = 0x20304050;
- ptr1[2] = 0x30405060;
- ptr1[3] = 0x708090a0;
- ptr1[4] = 0x8090a0b0;
- ptr1[5] = 0x10112233;
- ptr1[6] = 0x20003344;
- ptr1[7] = 0x90a0b0c0;
- ptr1[8] = 0xa0b0c0d0;
- ptr1[9] = 0x30330055;
- ptr1[10] = 0x40445500;
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
- ptr2[4] = 0x90111111;
- ptr2[5] = 0x90111111;
- ptr2[6] = 0xff000000;
- ptr2[7] = 0xff000000;
- ptr2[8] = 0xff000000;
- ptr2[9] = 0xff000000;
- ptr2[10] = 0xff000000;
- ptr2[11] = 0xff000000;
- ptr2[12] = 0xff000000;
- ptr2[13] = 0xff000000;
- ptr2[14] = 0xff000000;
- ptr2[15] = 0xff000000;
-
- SDL_Rect rect1;
- SDL_Rect rect2;
- rect1.x = 1;
- rect1.y = 1;
- rect1.w = 2;
- rect1.h = 2;
- rect2.x = 0;
- rect2.y = 0;
- rect2.w = 2;
- rect2.h = 2;
- SDLImageHelper::combineSurface(surface2,
- &rect2,
- surface1,
- &rect1);
-
- REQUIRE(ptr1[0] == 0x10203040);
- REQUIRE(ptr1[1] == 0x20304050);
- REQUIRE(ptr1[2] == 0x30405060);
- REQUIRE(ptr1[3] == 0x708090a0);
- REQUIRE(ptr1[4] == 0x8090a0b0);
- REQUIRE(ptr1[5] == 0x9f082b3c);
- REQUIRE(ptr1[6] == 0xbd1f144e);
- REQUIRE(ptr1[7] == 0x90a0b0c0);
- REQUIRE(ptr1[8] == 0xa0b0c0d0);
- REQUIRE(ptr1[9] == 0xbf1b0d23);
- REQUIRE(ptr1[10] == 0xff1f230c);
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-}
-
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-#endif // USE_SDL2
diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc
deleted file mode 100644
index b04d585fd..000000000
--- a/src/resources/sprite/animatedsprite_unittest.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * 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 "test/unittests.h"
-
-#include "configuration.h"
-#include "configmanager.h"
-#include "client.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/animation/animation.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-#include "utils/mrand.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-TEST_CASE("AnimatedSprite leak test1", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}
-
-TEST_CASE("AnimatedSprite tests", "animatedsprite")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- initRand();
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- logger = new Logger();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- getConfigDefaults2(config.getDefaultValues());
- branding.setDefaultValues(getBrandingDefaults());
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- SECTION("basic test 1")
- {
- AnimatedSprite *sprite = AnimatedSprite::load(
- "graphics/sprites/error.xml", 0);
- sprite->play(SpriteAction::DEFAULT);
-
- REQUIRE_FALSE(sprite == nullptr);
- REQUIRE_FALSE(sprite->getSprite() == nullptr);
- REQUIRE_FALSE(sprite->getAnimation() == nullptr);
- REQUIRE_FALSE(sprite->getFrame() == nullptr);
- REQUIRE(0 == sprite->getFrameIndex());
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(false == sprite->update(1));
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(false == sprite->update(11));
- REQUIRE(10 == sprite->getFrameTime());
- REQUIRE(0 == sprite->getFrameIndex());
- delete sprite;
- logger->log("test4");
- }
-
- SECTION("basic test 2")
- {
- AnimatedSprite *sprite = AnimatedSprite::load(
- "graphics/sprites/test.xml", 0);
- sprite->play(SpriteAction::STAND);
-
- REQUIRE(10 == const_cast<Animation*>(sprite->getAnimation())
- ->getFrames().size());
-
- REQUIRE_FALSE(nullptr == sprite);
-
- REQUIRE(false == sprite->update(1));
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(10 == sprite->getFrame()->delay);
-
- REQUIRE(false == sprite->update(1 + 10));
- REQUIRE(0 == sprite->getFrameIndex());
- REQUIRE(10 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 5));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(5 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 5));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(5 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(20 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 1));
- REQUIRE(2 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20 + 10));
- REQUIRE(2 == sprite->getFrameIndex());
- REQUIRE(10 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 1));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20 + 10 + 25));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(25 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 1));
- REQUIRE(6 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 10 + 1));
- REQUIRE(8 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 10 + 10 + 1));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
- delete sprite;
- }
-
- SECTION("basic test 3")
- {
- AnimatedSprite *sprite2 = AnimatedSprite::load(
- "graphics/sprites/test.xml", 0);
- sprite2->play(SpriteAction::SIT);
-
- REQUIRE(false == sprite2->update(1));
- REQUIRE(2 == const_cast<Animation*>(sprite2->getAnimation())
- ->getFrames().size());
- REQUIRE(0 == sprite2->getFrameTime());
- REQUIRE(85 == sprite2->getFrame()->delay);
-
- REQUIRE(true == sprite2->update(1 + 10 + 20 + 10 + 25 + 10 + 10 + 1));
- REQUIRE(1 == sprite2->getFrameIndex());
- REQUIRE(1 == sprite2->getFrameTime());
- delete sprite2;
- }
-
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- delete2(logger);
-// VirtFs::deinit();
-}
-
-TEST_CASE("AnimatedSprite leak test2", "")
-{
- logger = new Logger();
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- delete2(logger);
-}