summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-01-23 16:31:25 +0300
committerAndrei Karas <akaras@inbox.ru>2017-01-23 22:24:54 +0300
commitbb738bb468b1aafb9c6291b9d9e87e3711fa2ef7 (patch)
tree7c25e6541dd52b38ff08e86ac524f86d2956e655 /src
parent03b3dd1a41fa3984ce794b1811ba929c975cfff0 (diff)
downloadplus-bb738bb468b1aafb9c6291b9d9e87e3711fa2ef7.tar.gz
plus-bb738bb468b1aafb9c6291b9d9e87e3711fa2ef7.tar.bz2
plus-bb738bb468b1aafb9c6291b9d9e87e3711fa2ef7.tar.xz
plus-bb738bb468b1aafb9c6291b9d9e87e3711fa2ef7.zip
Fix unit tests issues.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/integrity_unittest.cc16
-rw-r--r--src/utils/stringutils_unittest.cc2
3 files changed, 15 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 76db75c8e..614bb3169 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1874,6 +1874,8 @@ manaplustests_CXXFLAGS += -DUSE_X11
endif
manaplustests_SOURCES = ${manaplus_SOURCES} \
+ enums/render/mockdrawtype.h \
+ render/mockdrawitem.h \
render/mockgraphics.cc \
render/mockgraphics.h \
enums/enums_unittest.cc \
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index 572cc29e6..e3e2a29cb 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -32,14 +32,15 @@
#include "resources/loaders/imageloader.h"
#include "resources/sdlimagehelper.h"
+#ifdef USE_SDL2
+#include "resources/surfaceimagehelper.h"
+#endif // USE_SDL2
#include "resources/resourcemanager/resourcemanager.h"
#include "utils/env.h"
#include "utils/physfsrwops.h"
-#include "utils/physfstools.h"
-#include <physfs.h>
#include <SDL_image.h>
#include "debug.h"
@@ -108,13 +109,16 @@ TEST_CASE("integrity tests", "integrity")
resourceManager->addToSearchPath("data", Append_false);
resourceManager->addToSearchPath("../data", Append_false);
- imageHelper = new SDLImageHelper();
#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
@@ -207,8 +211,12 @@ TEST_CASE("integrity tests", "integrity")
SECTION("integrity Loader::getImage test 2")
{
+ resourceManager->addToSearchPath("data/test/test.zip", Append_false);
+ resourceManager->addToSearchPath("../data/test/test.zip", Append_false);
Image *const image = Loader::getImage(
"hide.png");
+ resourceManager->removeFromSearchPath("data/test/test.zip");
+ resourceManager->removeFromSearchPath("../data/test/test.zip");
REQUIRE(image != nullptr);
REQUIRE(image->getSDLSurface() != nullptr);
image->decRef();
@@ -290,7 +298,7 @@ TEST_CASE("integrity tests", "integrity")
CAST_U32(size1));
if (rc != static_cast<PHYSFS_sint64>(size1))
{
- logger->log("PHYSFS_read %d bytes", rc);
+ logger->log("PHYSFS_read %d bytes", static_cast<int>(rc));
if (!PHYSFS_eof(handle))
{
logger->log("PhysicsFS read error: %s",
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index 998c5831b..309bf1ee9 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -821,7 +821,7 @@ TEST_CASE("stringuntils splitToStringVector 1")
splitToStringVector(tokens, "t,,zz", ',');
REQUIRE(tokens.size() == 2);
REQUIRE(tokens[0] == "t");
- REQUIRE(tokens[2] == "zz");
+ REQUIRE(tokens[1] == "zz");
tokens.clear();
splitToStringVector(tokens, "10,a2;30", ',');