diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-01-04 18:25:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-01-04 18:25:48 +0300 |
commit | 9fefb2942865846ccb7dbdac4ebd4515b8c851a2 (patch) | |
tree | c3e805eb002d03c286de2a3fe37f450f6279f82c /src | |
parent | 76ad2d74012c408788473c3b495076c96666b27c (diff) | |
download | manaverse-9fefb2942865846ccb7dbdac4ebd4515b8c851a2.tar.gz manaverse-9fefb2942865846ccb7dbdac4ebd4515b8c851a2.tar.bz2 manaverse-9fefb2942865846ccb7dbdac4ebd4515b8c851a2.tar.xz manaverse-9fefb2942865846ccb7dbdac4ebd4515b8c851a2.zip |
Add physfs deinit function for unit tests. But not using it for now.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/browserbox_unittest.cc | 5 | ||||
-rw-r--r-- | src/gui/windowmanager_unittest.cc | 1 | ||||
-rw-r--r-- | src/integrity_unittest.cc | 2 | ||||
-rw-r--r-- | src/resources/dye/dye_unittest.cc | 1 | ||||
-rw-r--r-- | src/resources/dye/dyepalette_unittest.cc | 1 | ||||
-rw-r--r-- | src/resources/resourcemanager/resourcemanager_unittest.cc | 1 | ||||
-rw-r--r-- | src/resources/sprite/animatedsprite_unittest.cc | 1 | ||||
-rw-r--r-- | src/utils/chatutils_unittest.cc | 1 | ||||
-rw-r--r-- | src/utils/files_unittest.cc | 6 | ||||
-rw-r--r-- | src/utils/physfstools.cpp | 10 | ||||
-rw-r--r-- | src/utils/physfstools.h | 1 | ||||
-rw-r--r-- | src/utils/stringutils_unittest.cc | 13 | ||||
-rw-r--r-- | src/utils/translation/poparser_unittest.cc | 1 | ||||
-rw-r--r-- | src/utils/xml_unittest.cc | 1 | ||||
-rw-r--r-- | src/utils/xmlutils_unittest.cc | 3 |
15 files changed, 48 insertions, 0 deletions
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index a4438eb64..665d6de3f 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -31,6 +31,8 @@ #include "resources/sdlimagehelper.h" +#include "utils/physfstools.h" + #include <physfs.h> #include "debug.h" @@ -46,6 +48,8 @@ TEST_CASE("BrowserBox tests", "browserbox") imageHelper = new SDLImageHelper(); theme = new Theme; ResourceManager::init(); + resourceManager->addToSearchPath("data", Append_false); + resourceManager->addToSearchPath("../data", Append_false); ActorSprite::load(); Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/" "ttf-dejavu/DejaVuSans-Oblique.ttf", 18)); @@ -151,4 +155,5 @@ TEST_CASE("BrowserBox tests", "browserbox") delete box; delete client; client = nullptr; +// PhysFs::deinit(); } diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc index 2230385f2..0f8c5bc15 100644 --- a/src/gui/windowmanager_unittest.cc +++ b/src/gui/windowmanager_unittest.cc @@ -673,4 +673,5 @@ TEST_CASE("Windows tests", "windowmanager") delete2(client); delete2(serverFeatures); delete2(inventoryHandler); +// PhysFs::deinit(); } diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc index d1b332387..39fa054f1 100644 --- a/src/integrity_unittest.cc +++ b/src/integrity_unittest.cc @@ -163,4 +163,6 @@ TEST_CASE("integrity tests", "integrity") delete client; client = nullptr; + +// PhysFs::deinit(); } diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc index 29d39ff3e..ff79fea52 100644 --- a/src/resources/dye/dye_unittest.cc +++ b/src/resources/dye/dye_unittest.cc @@ -2392,4 +2392,5 @@ TEST_CASE("Dye real dye") dyeCheck("|A:#0000FFFF,FF000050", "arrow_up_A.png"); } delete2(client); +// PhysFs::deinit(); } diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc index a7af3c6a6..7e652e43f 100644 --- a/src/resources/dye/dyepalette_unittest.cc +++ b/src/resources/dye/dyepalette_unittest.cc @@ -373,4 +373,5 @@ TEST_CASE("DyePalette tests") REQUIRE(palette.mColors[0].value[3] == 0x77); } delete2(client); +// PhysFs::deinit(); } diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc index da7d87cbf..a8b1becc1 100644 --- a/src/resources/resourcemanager/resourcemanager_unittest.cc +++ b/src/resources/resourcemanager/resourcemanager_unittest.cc @@ -660,4 +660,5 @@ TEST_CASE("resourcemanager", "resourcemanager") resourceManager = safeResman; delete client; client = nullptr; +// PhysFs::deinit(); } diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc index 950a12079..bf151308c 100644 --- a/src/resources/sprite/animatedsprite_unittest.cc +++ b/src/resources/sprite/animatedsprite_unittest.cc @@ -175,4 +175,5 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite") delete client; client = nullptr; +// PhysFs::deinit(); } diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc index 8a1d5b047..2077bfe5e 100644 --- a/src/utils/chatutils_unittest.cc +++ b/src/utils/chatutils_unittest.cc @@ -234,6 +234,7 @@ TEST_CASE("chatutils replaceVars") delete2(actorManager); delete2(client); +// PhysFs::deinit(); } TEST_CASE("chatutils textToMe") diff --git a/src/utils/files_unittest.cc b/src/utils/files_unittest.cc index 84ddb0df1..77a7017f6 100644 --- a/src/utils/files_unittest.cc +++ b/src/utils/files_unittest.cc @@ -64,6 +64,7 @@ TEST_CASE("Files renameFile") delete [] buf; delete [] buf2; ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("Files existsLocal") @@ -78,6 +79,7 @@ TEST_CASE("Files existsLocal") REQUIRE_FALSE(Files::existsLocal(Files::getPath("help/about1.txt"))); REQUIRE_FALSE(Files::existsLocal(Files::getPath("help1/about.txt"))); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("Files loadTextFileString") @@ -91,6 +93,7 @@ TEST_CASE("Files loadTextFileString") REQUIRE(Files::loadTextFileString("test/simplefile.txt") == "this is test \nfile."); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("Files loadTextFile") @@ -108,6 +111,7 @@ TEST_CASE("Files loadTextFile") REQUIRE(lines[0] == "this is test "); REQUIRE(lines[1] == "file."); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("Files saveTextFile") @@ -126,6 +130,7 @@ TEST_CASE("Files saveTextFile") ::remove((dir + "/tempfile.txt").c_str()); REQUIRE(data == "test line\ntext line2\n"); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("Files getFilesInDir") @@ -155,4 +160,5 @@ TEST_CASE("Files getFilesInDir") REQUIRE(list[3] == "perserver/default/features.xml"); REQUIRE(list[4] == "perserver/default/weapons.xml"); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp index 6cc809656..1424bb2a2 100644 --- a/src/utils/physfstools.cpp +++ b/src/utils/physfstools.cpp @@ -161,4 +161,14 @@ namespace PhysFs return buffer; } + + bool deinit() + { + if (PHYSFS_deinit() != 0) + { + logger->log("Physfs deinit error: %s", PHYSFS_getLastError()); + return false; + } + return true; + } } // namespace PhysFs diff --git a/src/utils/physfstools.h b/src/utils/physfstools.h index 9caed5b55..e524dad64 100644 --- a/src/utils/physfstools.h +++ b/src/utils/physfstools.h @@ -44,6 +44,7 @@ namespace PhysFs const char *getRealDir(const char *const filename); bool mkdir(const char *const dirName); void *loadFile(const std::string &fileName, int &fileSize); + bool deinit(); } // namespace PhysFs extern const char *dirSeparator; diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc index a8347cdd5..481289087 100644 --- a/src/utils/stringutils_unittest.cc +++ b/src/utils/stringutils_unittest.cc @@ -19,13 +19,17 @@ */ #include "catch.hpp" +#include "logger.h" +#include "utils/physfstools.h" #include "utils/stringutils.h" #include "resources/iteminfo.h" #include "resources/db/itemdb.h" +#include "resources/resourcemanager/resourcemanager.h" + #include "debug.h" TEST_CASE("stringuntils trim 1") @@ -619,6 +623,13 @@ TEST_CASE("stringuntils escapeString") TEST_CASE("stringuntils replaceItemLinks") { + PHYSFS_init("manaplus"); + dirSeparator = "/"; + logger = new Logger(); + ResourceManager::init(); + resourceManager->addToSearchPath("data", Append_false); + resourceManager->addToSearchPath("../data", Append_false); + ItemDB::NamedItemInfos &namedInfos = ItemDB::getNamedItemInfosTest(); ItemDB::ItemInfos &infos = ItemDB::getItemInfosTest(); ItemInfo *info = new ItemInfo; @@ -833,4 +844,6 @@ TEST_CASE("stringuntils replaceItemLinks") replaceItemLinks(str); REQUIRE(str == "[[test name 1 ,test name2[] test name 1]"); } + ResourceManager::deleteInstance(); +// PhysFs::deinit(); } diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc index c1191ed54..9a138c67c 100644 --- a/src/utils/translation/poparser_unittest.cc +++ b/src/utils/translation/poparser_unittest.cc @@ -114,4 +114,5 @@ TEST_CASE("PoParser tests", "PoParser") delete dict; } delete2(client); +// PhysFs::deinit(); } diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc index 5c395535a..52f234d12 100644 --- a/src/utils/xml_unittest.cc +++ b/src/utils/xml_unittest.cc @@ -350,4 +350,5 @@ TEST_CASE("xml doc") } delete2(theme); delete2(client); +// PhysFs::deinit(); } diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc index 6d413d484..5603bf5a8 100644 --- a/src/utils/xmlutils_unittest.cc +++ b/src/utils/xmlutils_unittest.cc @@ -59,6 +59,7 @@ TEST_CASE("xmlutils readXmlIntVector 1") REQUIRE(1 == arr[3]); REQUIRE(1 == arr[4]); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("xmlutils readXmlStringMap 1") @@ -88,6 +89,7 @@ TEST_CASE("xmlutils readXmlStringMap 1") REQUIRE(arr["xD"] == "1"); REQUIRE(arr["Metal"] == "26"); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } TEST_CASE("xmlutils readXmlIntMap 1") @@ -117,4 +119,5 @@ TEST_CASE("xmlutils readXmlIntMap 1") REQUIRE(arr[10] == 20); REQUIRE(arr[3] == 0); ResourceManager::deleteInstance(); +// PhysFs::deinit(); } |