diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-20 15:51:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-20 15:51:27 +0300 |
commit | cf772ab6f9fdfe1647b9b7b79aab685ebc831f31 (patch) | |
tree | 25cdb35a8733efe3a4cb90e36cbb89e8e0c24c10 /src/utils/xmlutils_unittest.cc | |
parent | 80ba4766d8ce9861f6d026e791abc741e3fed0f4 (diff) | |
download | plus-cf772ab6f9fdfe1647b9b7b79aab685ebc831f31.tar.gz plus-cf772ab6f9fdfe1647b9b7b79aab685ebc831f31.tar.bz2 plus-cf772ab6f9fdfe1647b9b7b79aab685ebc831f31.tar.xz plus-cf772ab6f9fdfe1647b9b7b79aab685ebc831f31.zip |
Fix some leaks in unit tests.
Add support for suppression some leaks in asan.
Diffstat (limited to 'src/utils/xmlutils_unittest.cc')
-rw-r--r-- | src/utils/xmlutils_unittest.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc index dbb571429..00c850bcc 100644 --- a/src/utils/xmlutils_unittest.cc +++ b/src/utils/xmlutils_unittest.cc @@ -22,13 +22,21 @@ #include "catch.hpp" #include "client.h" +#include "graphicsmanager.h" #include "logger.h" +#include "being/actorsprite.h" + +#include "utils/delete2.h" #include "utils/virtfs.h" #include "utils/xml.h" +#include "render/sdlgraphics.h" + #include "resources/resourcemanager/resourcemanager.h" +#include "resources/sdlimagehelper.h" + #include "debug.h" TEST_CASE("xmlutils readXmlIntVector 1") @@ -38,6 +46,20 @@ TEST_CASE("xmlutils readXmlIntVector 1") XML::initXML(); logger = new Logger(); ResourceManager::init(); + + 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(); + VirtFs::addDirToSearchPath("data", Append_false); VirtFs::addDirToSearchPath("../data", Append_false); @@ -57,7 +79,9 @@ TEST_CASE("xmlutils readXmlIntVector 1") REQUIRE(0 == arr[2]); REQUIRE(1 == arr[3]); REQUIRE(1 == arr[4]); + delete2(client); ResourceManager::deleteInstance(); + delete2(logger); // VirtFs::deinit(); } @@ -68,6 +92,20 @@ TEST_CASE("xmlutils readXmlStringMap 1") XML::initXML(); logger = new Logger(); ResourceManager::init(); + + 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(); + VirtFs::addDirToSearchPath("data", Append_false); VirtFs::addDirToSearchPath("../data", Append_false); @@ -86,7 +124,9 @@ TEST_CASE("xmlutils readXmlStringMap 1") REQUIRE(arr["Kitty"] == "0"); REQUIRE(arr["xD"] == "1"); REQUIRE(arr["Metal"] == "26"); + delete2(client); ResourceManager::deleteInstance(); + delete2(logger); // VirtFs::deinit(); } @@ -97,6 +137,20 @@ TEST_CASE("xmlutils readXmlIntMap 1") XML::initXML(); logger = new Logger(); ResourceManager::init(); + + 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(); + VirtFs::addDirToSearchPath("data/test", Append_false); VirtFs::addDirToSearchPath("../data/test", Append_false); @@ -115,6 +169,8 @@ TEST_CASE("xmlutils readXmlIntMap 1") REQUIRE(arr[1] == 2); REQUIRE(arr[10] == 20); REQUIRE(arr[3] == 0); + delete2(client); ResourceManager::deleteInstance(); + delete2(logger); // VirtFs::deinit(); } |