summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/chatutils_unittest.cc1
-rw-r--r--src/utils/files_unittest.cc6
-rw-r--r--src/utils/physfstools.cpp10
-rw-r--r--src/utils/physfstools.h1
-rw-r--r--src/utils/stringutils_unittest.cc13
-rw-r--r--src/utils/translation/poparser_unittest.cc1
-rw-r--r--src/utils/xml_unittest.cc1
-rw-r--r--src/utils/xmlutils_unittest.cc3
8 files changed, 36 insertions, 0 deletions
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();
}