summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-07 22:02:59 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-07 22:02:59 +0300
commitbbd71d4a8c95092deb9cbf4aef86722a1e9628db (patch)
tree59566c4baa2e32287fe5867e5616ca560d3f3bf5
parent6f7f469430ea05946a11dd41f62010961be6285e (diff)
downloadmv-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.gz
mv-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.bz2
mv-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.xz
mv-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.zip
Fix unit tests on windows.
-rw-r--r--src/configmanager.cpp2
-rw-r--r--src/fs/files.cpp16
-rw-r--r--src/fs/files_unittest.cc12
-rw-r--r--src/fs/virtfs/virtfs_unittest.cc202
-rw-r--r--src/fs/virtfs/virtfszip.cpp2
-rw-r--r--src/fs/virtfs/zip.cpp6
-rw-r--r--src/fs/virtfs/zip_unittest.cc29
-rw-r--r--src/fs/virtfs_unittest.cc39
-rw-r--r--src/gui/widgets/browserbox_unittest.cc1
-rw-r--r--src/gui/windowmanager_unittest.cc1
-rw-r--r--src/integrity_unittest.cc1
-rw-r--r--src/resources/dye/dye_unittest.cc1
-rw-r--r--src/resources/dye/dyepalette_unittest.cc1
-rw-r--r--src/resources/resourcemanager/resourcemanager_unittest.cc1
-rw-r--r--src/resources/sprite/animatedsprite_unittest.cc1
-rw-r--r--src/utils/chatutils_unittest.cc1
-rw-r--r--src/utils/stringutils_unittest.cc53
-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
20 files changed, 205 insertions, 169 deletions
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 953a7c2e7..f95d98f4e 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -67,7 +67,7 @@ void ConfigManager::initServerConfig(const std::string &serverName)
FILE *configFile = fopen(configPath.c_str(), "r");
if (!configFile)
{
- configFile = fopen(configPath.c_str(), "wt");
+ configFile = fopen(configPath.c_str(), "wb");
logger->log("Creating new server config: " + configPath);
if (configFile)
{
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
index d8a6e76ec..f6a138475 100644
--- a/src/fs/files.cpp
+++ b/src/fs/files.cpp
@@ -38,6 +38,8 @@
#include "debug.h"
+extern const char *dirSeparator;
+
#ifdef ANDROID
void Files::extractLocale()
{
@@ -211,7 +213,21 @@ int Files::copyFile(const std::string &restrict srcName,
bool Files::existsLocal(const std::string &path)
{
struct stat statbuf;
+#ifdef WIN32
+ // in windows path\file.ext\ by default detected as exists
+ // if file.ext is not directory, need return false
+ const bool res = (stat(path.c_str(), &statbuf) == 0);
+ if (res == false)
+ return false;
+ if ((findLast(path, "/") == true || findLast(path, "\\") == true) &&
+ S_ISDIR(statbuf.st_mode) == 0)
+ {
+ return false;
+ }
+ return true;
+#else // WIN32
return stat(path.c_str(), &statbuf) == 0;
+#endif // WIN32
}
bool Files::loadTextFileLocal(const std::string &fileName,
diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc
index 19fd40ec1..d2bac3256 100644
--- a/src/fs/files_unittest.cc
+++ b/src/fs/files_unittest.cc
@@ -34,7 +34,6 @@
TEST_CASE("Files renameFile")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -74,7 +73,6 @@ TEST_CASE("Files renameFile")
TEST_CASE("Files existsLocal")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -91,7 +89,6 @@ TEST_CASE("Files existsLocal")
TEST_CASE("Files loadTextFileString")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -107,7 +104,6 @@ TEST_CASE("Files loadTextFileString")
TEST_CASE("Files loadTextFile")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -127,7 +123,6 @@ TEST_CASE("Files loadTextFile")
TEST_CASE("Files saveTextFile")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -138,7 +133,13 @@ TEST_CASE("Files saveTextFile")
Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2");
std::string data = VirtFs::loadTextFileString("test/tempfile.txt");
::remove((dir + "/tempfile.txt").c_str());
+#ifdef WIN32
+ REQUIRE(data == "test line\r\ntext line2\r\n");
+#else // WIN32
+
REQUIRE(data == "test line\ntext line2\n");
+#endif // WIN32
+
ResourceManager::deleteInstance();
VirtFs::removeDirFromSearchPathSilent("data");
VirtFs::removeDirFromSearchPathSilent("../data");
@@ -148,7 +149,6 @@ TEST_CASE("Files saveTextFile")
TEST_CASE("Files getFilesInDir")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc
index cece63a04..8047c879c 100644
--- a/src/fs/virtfs/virtfs_unittest.cc
+++ b/src/fs/virtfs/virtfs_unittest.cc
@@ -55,14 +55,15 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
{
VirtFs::init(".");
logger = new Logger();
+ const std::string sep = dirSeparator;
SECTION("simple 1")
{
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1",
Append_false));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -72,13 +73,13 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
{
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1/",
Append_true));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1/");
+ VirtFs::getEntries()[0])->userDir == "dir1" + sep);
}
SECTION("simple 3")
@@ -87,12 +88,12 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
Append_false));
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2",
Append_false));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir2/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir2/");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir2" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
@@ -107,16 +108,16 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
Append_true));
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2",
Append_true));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir2/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1/");
+ VirtFs::getEntries()[0])->userDir == "dir1" + sep);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2");
}
@@ -129,14 +130,15 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
Append_true));
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3/test",
Append_true));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir2/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir3/test/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal(
+ "dir3" + sep + "test" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2/");
- REQUIRE(VirtFs::getEntries()[2]->root == "dir3/test/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
+ REQUIRE(VirtFs::getEntries()[2]->root == "dir3" + sep + "test" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
@@ -145,7 +147,7 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2");
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[2])->userDir == "dir3/test");
+ VirtFs::getEntries()[2])->userDir == "dir3" + sep + "test");
}
SECTION("simple 6")
@@ -154,21 +156,25 @@ TEST_CASE("VirtFs1 addDirToSearchPath")
Append_true));
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2",
Append_true));
- REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3/test",
+ REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3\\test",
Append_false));
- REQUIRE(VirtFs::searchEntryByRootInternal("dir1/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir2/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("dir3/test/") != nullptr);
- REQUIRE(VirtFs::searchEntryByRootInternal("test/") == nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal(
+ "dir1" + sep + "") != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal(
+ "dir2" + sep + "") != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal(
+ "dir3" + sep + "test" + sep) != nullptr);
+ REQUIRE(VirtFs::searchEntryByRootInternal(
+ "test" + sep + "") == nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3/test/");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1/");
- REQUIRE(VirtFs::getEntries()[2]->root == "dir2/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep + "test" + sep);
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[2]->root == "dir2" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3/test");
+ VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test");
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir1");
REQUIRE(static_cast<VirtDirEntry*>(
@@ -185,6 +191,7 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
logger = new Logger();
std::string name("data/test/test.zip");
std::string prefix;
+ const std::string sep = dirSeparator;
std::vector<ZipLocalHeader*> headers;
if (Files::existsLocal(name) == false)
prefix = "../";
@@ -194,12 +201,12 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip",
Append_false));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") == nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") == nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
}
@@ -210,15 +217,15 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip",
Append_false));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
}
@@ -229,15 +236,15 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip",
Append_true));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
}
@@ -250,20 +257,20 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip",
Append_false));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/") != nullptr);
+ prefix + "data" + sep + "test" + sep + "") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/");
+ prefix + "data" + sep + "test" + sep + "");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
}
@@ -276,20 +283,20 @@ TEST_CASE("VirtFs1 addZipToSearchPath")
REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip",
Append_true));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/") != nullptr);
+ prefix + "data" + sep + "test" + sep + "") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/");
+ prefix + "data" + sep + "test" + sep + "");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
}
@@ -303,6 +310,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
logger = new Logger();
std::string name("data/test/test.zip");
std::string prefix;
+ const std::string sep = dirSeparator;
std::vector<ZipLocalHeader*> headers;
if (Files::existsLocal(name) == false)
prefix = "../";
@@ -333,28 +341,28 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2"));
REQUIRE(VirtFs::removeDirFromSearchPath("dir1"));
REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2/dir3/");
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2/dir3");
+ VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir1"));
REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2/dir3/");
+ REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2/dir3");
+ VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
REQUIRE(VirtFs::removeDirFromSearchPath("dir2/dir3"));
- REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2/dir3/"));
+ REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2/dir3" + sep));
REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
@@ -365,7 +373,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1",
Append_true));
REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -375,7 +383,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1",
Append_true));
REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1/");
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtDirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -389,25 +397,25 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
Append_true));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip");
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") == nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") == nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
}
@@ -417,39 +425,39 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
Append_false));
REQUIRE(VirtFs::addDirToSearchPath(prefix + "data/test",
Append_false));
- REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip",
+ REQUIRE(VirtFs::addZipToSearchPath(prefix + "data\\test/test2.zip",
Append_false));
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/") != nullptr);
+ prefix + "data" + sep + "test" + sep + "") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/");
+ prefix + "data" + sep + "test" + sep);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data/test/test.zip");
+ prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip");
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test.zip") == nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip") == nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/test2.zip") != nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip") != nullptr);
REQUIRE(VirtFs::searchEntryByRootInternal(
- prefix + "data/test/") != nullptr);
+ prefix + "data" + sep + "test" + sep + "") != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data/test/");
+ prefix + "data" + sep + "test" + sep);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
}
@@ -547,6 +555,7 @@ TEST_CASE("VirtFs1 getRealDir1")
{
VirtFs::init(".");
logger = new Logger();
+ const std::string sep = dirSeparator;
REQUIRE(VirtFs::getRealDir(".") == "");
REQUIRE(VirtFs::getRealDir("..") == "");
const bool dir1 = VirtFs::addDirToSearchPathSilent("data",
@@ -587,17 +596,17 @@ TEST_CASE("VirtFs1 getRealDir1")
REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
"data");
REQUIRE(VirtFs::getRealDir("test.txt") ==
- "data/test");
+ "data" + sep + "test");
}
else
{
- REQUIRE(VirtFs::getRealDir("test") == "../data");
+ REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
+ ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
- "../data");
+ ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test.txt") ==
- "../data/test");
+ ".." + sep + "data" + sep + "test");
}
REQUIRE(VirtFs::getRealDir("zzz") == "");
@@ -612,9 +621,9 @@ TEST_CASE("VirtFs1 getRealDir1")
}
else
{
- REQUIRE(VirtFs::getRealDir("test") == "../data");
+ REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
+ ".." + sep + "data");
}
REQUIRE(VirtFs::getRealDir("zzz") == "");
@@ -628,10 +637,11 @@ TEST_CASE("VirtFs1 getRealDir2")
{
VirtFs::init(".");
logger = new Logger();
+ const std::string sep = dirSeparator;
std::string name("data/test/test.zip");
- std::string prefix("data/test/");
+ std::string prefix("data" + sep + "test" + sep);
if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
+ prefix = ".." + sep + prefix;
VirtFs::addZipToSearchPath(prefix + "test2.zip",
Append_false);
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index eac4a2535..0f1021793 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -136,7 +136,7 @@ namespace VirtFsZip
StringVect &names)
{
VirtZipEntry *const zipEntry = static_cast<VirtZipEntry*>(entry);
- if (dirName == "/")
+ if (dirName == dirSeparator)
{
FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
it2,
diff --git a/src/fs/virtfs/zip.cpp b/src/fs/virtfs/zip.cpp
index 8dd7d8080..0556af1f8 100644
--- a/src/fs/virtfs/zip.cpp
+++ b/src/fs/virtfs/zip.cpp
@@ -36,6 +36,8 @@
#include "debug.h"
+extern const char *dirSeparator;
+
#define readVal(val, sz, msg) \
cnt = fread(static_cast<void*>(val), 1, sz, arcFile); \
if (cnt != sz) \
@@ -131,7 +133,7 @@ namespace Zip
header->dataOffset = ftell(arcFile) + extraFieldLen;
fseek(arcFile, extraFieldLen + header->compressSize, SEEK_CUR);
// pointer on 30 + fileNameLen + extraFieldLen + compressSize
- if (findLast(header->fileName, "/") == false)
+ if (findLast(header->fileName, dirSeparator) == false)
{
headers.push_back(header);
logger->log(" file name: %s",
@@ -145,6 +147,8 @@ namespace Zip
}
else
{
+ logger->log(" dir name: %s",
+ header->fileName.c_str());
dirs.push_back(header->fileName);
delete header;
}
diff --git a/src/fs/virtfs/zip_unittest.cc b/src/fs/virtfs/zip_unittest.cc
index 4b9258ec5..27d4bc1f9 100644
--- a/src/fs/virtfs/zip_unittest.cc
+++ b/src/fs/virtfs/zip_unittest.cc
@@ -35,11 +35,14 @@
#include "debug.h"
+extern const char *dirSeparator;
+
TEST_CASE("Zip readArchiveInfo")
{
logger = new Logger();
std::string name("data/test/test.zip");
std::string prefix;
+ const std::string sep = dirSeparator;
if (Files::existsLocal(name) == false)
prefix = "../";
@@ -54,10 +57,10 @@ TEST_CASE("Zip readArchiveInfo")
REQUIRE(Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 2);
REQUIRE(entry->root == name);
- REQUIRE(headers[0]->fileName == "dir/hide.png");
+ REQUIRE(headers[0]->fileName == "dir" + sep + "hide.png");
REQUIRE(headers[0]->compressSize == 365);
REQUIRE(headers[0]->uncompressSize == 368);
- REQUIRE(headers[1]->fileName == "dir/brimmedhat.png");
+ REQUIRE(headers[1]->fileName == "dir" + sep + "brimmedhat.png");
REQUIRE(headers[1]->compressSize == 1959);
REQUIRE(headers[1]->uncompressSize == 1959);
@@ -79,39 +82,43 @@ TEST_CASE("Zip readArchiveInfo")
REQUIRE(headers[0]->compressSize == 17);
REQUIRE(headers[0]->uncompressSize == 23);
- REQUIRE(headers[1]->fileName == "dir2/hide.png");
+ REQUIRE(headers[1]->fileName == "dir2" + sep + "hide.png");
REQUIRE(headers[1]->compressSize == 365);
REQUIRE(headers[1]->uncompressSize == 368);
- REQUIRE(headers[2]->fileName == "dir2/test.txt");
+ REQUIRE(headers[2]->fileName == "dir2" + sep + "test.txt");
REQUIRE(headers[2]->compressSize == 17);
REQUIRE(headers[2]->uncompressSize == 23);
- REQUIRE(headers[3]->fileName == "dir2/paths.xml");
+ REQUIRE(headers[3]->fileName == "dir2" + sep + "paths.xml");
REQUIRE(headers[3]->compressSize == 154);
REQUIRE(headers[3]->uncompressSize == 185);
- REQUIRE(headers[4]->fileName == "dir2/units.xml");
+ REQUIRE(headers[4]->fileName == "dir2" + sep + "units.xml");
REQUIRE(headers[4]->compressSize == 202);
REQUIRE(headers[4]->uncompressSize == 306);
- REQUIRE(headers[5]->fileName == "dir/hide.png");
+ REQUIRE(headers[5]->fileName == "dir" + sep + "hide.png");
REQUIRE(headers[5]->compressSize == 365);
REQUIRE(headers[5]->uncompressSize == 368);
- REQUIRE(headers[6]->fileName == "dir/1/test.txt");
+ REQUIRE(headers[6]->fileName ==
+ "dir" + sep + "1" + sep + "test.txt");
REQUIRE(headers[6]->compressSize == 17);
REQUIRE(headers[6]->uncompressSize == 23);
- REQUIRE(headers[7]->fileName == "dir/1/file1.txt");
+ REQUIRE(headers[7]->fileName ==
+ "dir" + sep + "1" + sep + "file1.txt");
REQUIRE(headers[7]->compressSize == 17);
REQUIRE(headers[7]->uncompressSize == 23);
- REQUIRE(headers[8]->fileName == "dir/gpl/palette.gpl");
+ REQUIRE(headers[8]->fileName ==
+ "dir" + sep + "gpl" + sep + "palette.gpl");
REQUIRE(headers[8]->compressSize == 128);
REQUIRE(headers[8]->uncompressSize == 213);
- REQUIRE(headers[9]->fileName == "dir/dye.png");
+ REQUIRE(headers[9]->fileName ==
+ "dir" + sep + "dye.png");
REQUIRE(headers[9]->compressSize == 794);
REQUIRE(headers[9]->uncompressSize == 794);
diff --git a/src/fs/virtfs_unittest.cc b/src/fs/virtfs_unittest.cc
index c1dcc4fd0..b3f07daa1 100644
--- a/src/fs/virtfs_unittest.cc
+++ b/src/fs/virtfs_unittest.cc
@@ -599,6 +599,7 @@ TEST_CASE("VirtFs openRead3")
TEST_CASE("VirtFs getRealDir1")
{
logger = new Logger();
+ const std::string sep = dirSeparator;
REQUIRE(VirtFs::getRealDir(".") == "");
REQUIRE(VirtFs::getRealDir("..") == "");
const bool dir1 = VirtFs::addDirToSearchPathSilent("data", Append_false);
@@ -626,15 +627,15 @@ TEST_CASE("VirtFs getRealDir1")
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
"data");
REQUIRE(VirtFs::getRealDir("test.txt") ==
- "data/test");
+ "data" + sep + "test");
}
else
{
- REQUIRE(VirtFs::getRealDir("test") == "../data");
+ REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
+ ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test.txt") ==
- "../data/test");
+ ".." + sep + "data" + sep + "test");
}
REQUIRE(VirtFs::getRealDir("zzz") == "");
@@ -642,15 +643,17 @@ TEST_CASE("VirtFs getRealDir1")
{
VirtFs::addZipToSearchPath("data/test/test.zip", Append_false);
REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") ==
- "data/test/test.zip");
- REQUIRE(VirtFs::getRealDir("hide.png") == "data/test");
+ "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getRealDir("hide.png") ==
+ "data" + sep + "test");
}
else
{
VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false);
REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") ==
- "../data/test/test.zip");
- REQUIRE(VirtFs::getRealDir("hide.png") == "../data/test");
+ ".." + sep + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getRealDir("hide.png") ==
+ ".." + sep + "data" + sep + "test");
}
VirtFs::removeDirFromSearchPathSilent("data/test");
@@ -661,14 +664,16 @@ TEST_CASE("VirtFs getRealDir1")
REQUIRE(VirtFs::getRealDir("test") == "data");
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
"data");
- REQUIRE(VirtFs::getRealDir("dir/hide.png") == "data/test/test.zip");
+ REQUIRE(VirtFs::getRealDir("dir/hide.png") ==
+ "data" + sep + "test" + sep + "test.zip");
}
else
{
- REQUIRE(VirtFs::getRealDir("test") == "../data");
+ REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
- REQUIRE(VirtFs::getRealDir("dir/hide.png") == "../data/test/test.zip");
+ ".." + sep + "data");
+ REQUIRE(VirtFs::getRealDir("dir/hide.png") ==
+ ".." + sep + "data" + sep + "test" + sep + "test.zip");
}
REQUIRE(VirtFs::exists("dir/hide.png"));
REQUIRE(VirtFs::getRealDir("zzz") == "");
@@ -685,6 +690,7 @@ TEST_CASE("VirtFs getRealDir1")
TEST_CASE("VirtFs getrealDir2")
{
logger = new Logger();
+ const std::string sep = dirSeparator;
std::string name("data/test/test.zip");
std::string prefix;
if (Files::existsLocal(name) == false)
@@ -697,12 +703,13 @@ TEST_CASE("VirtFs getrealDir2")
REQUIRE(VirtFs::getRealDir("zzz") == "");
REQUIRE(VirtFs::getRealDir("dir1/file1.txt") ==
- prefix + "data/test");
- REQUIRE(VirtFs::getRealDir("hide.png") == prefix + "data/test");
+ prefix + "data" + sep + "test");
+ REQUIRE(VirtFs::getRealDir("hide.png") ==
+ prefix + "data" + sep + "test");
REQUIRE(VirtFs::getRealDir("dir//hide.png") ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getRealDir("dir/1//test.txt") ==
- prefix + "data/test/test2.zip");
+ prefix + "data" + sep + "test" + sep + "test2.zip");
VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip");
VirtFs::removeDirFromSearchPath(prefix + "data/test");
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index 485c67ca4..8f4c04aa7 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -46,7 +46,6 @@ extern const char *dirSeparator;
TEST_CASE("BrowserBox tests", "browserbox")
{
- dirSeparator = "/";
client = new Client;
logger = new Logger();
ResourceManager::init();
diff --git a/src/gui/windowmanager_unittest.cc b/src/gui/windowmanager_unittest.cc
index 78bd85ab8..871b23c84 100644
--- a/src/gui/windowmanager_unittest.cc
+++ b/src/gui/windowmanager_unittest.cc
@@ -135,7 +135,6 @@ TEST_CASE("Windows tests", "windowmanager")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc
index a0789d09c..98138a3a9 100644
--- a/src/integrity_unittest.cc
+++ b/src/integrity_unittest.cc
@@ -112,7 +112,6 @@ TEST_CASE("integrity tests", "integrity")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index ff1aa8995..a092357f5 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -2355,7 +2355,6 @@ TEST_CASE("Dye real dye")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
ResourceManager::init();
diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc
index 4f9d26bb6..ba25ea4ab 100644
--- a/src/resources/dye/dyepalette_unittest.cc
+++ b/src/resources/dye/dyepalette_unittest.cc
@@ -55,7 +55,6 @@ TEST_CASE("DyePalette tests")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc
index 52da99571..ccb2a792a 100644
--- a/src/resources/resourcemanager/resourcemanager_unittest.cc
+++ b/src/resources/resourcemanager/resourcemanager_unittest.cc
@@ -90,7 +90,6 @@ TEST_CASE("resourcemanager", "resourcemanager")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc
index b0e1fe78a..0264fdbf6 100644
--- a/src/resources/sprite/animatedsprite_unittest.cc
+++ b/src/resources/sprite/animatedsprite_unittest.cc
@@ -57,7 +57,6 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite")
initRand();
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/utils/chatutils_unittest.cc b/src/utils/chatutils_unittest.cc
index 8c237b70a..a62cd57a4 100644
--- a/src/utils/chatutils_unittest.cc
+++ b/src/utils/chatutils_unittest.cc
@@ -50,7 +50,6 @@
TEST_CASE("chatutils replaceVars")
{
client = new Client;
- dirSeparator = "/";
XML::initXML();
SDL_Init(SDL_INIT_VIDEO);
logger = new Logger();
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index 31e09e4ae..cf0e880aa 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -1256,84 +1256,87 @@ TEST_CASE("stringuntils escapeString")
TEST_CASE("stringuntils sanitizePath")
{
std::string path;
+ const std::string sep = dirSeparator;
path = "";
sanitizePath(path);
REQUIRE(path == "");
path = "/";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "/\\";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "\\/";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "//";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "///";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "//\\/";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "///\\";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "\\";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "\\\\";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "\\/\\";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "\\\\/";
sanitizePath(path);
- REQUIRE(path == "/");
+ REQUIRE(path == dirSeparator);
path = "test";
sanitizePath(path);
REQUIRE(path == "test");
path = "./test";
sanitizePath(path);
- REQUIRE(path == "./test");
+ REQUIRE(path == "." + sep + "test");
path = "test line";
sanitizePath(path);
REQUIRE(path == "test line");
path = "dir/test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "/dir/test";
sanitizePath(path);
- REQUIRE(path == "/dir/test");
+ REQUIRE(path == sep + "dir" + sep + "test");
path = "dir//test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "dir///test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "dir///\\test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "dir/\\//test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "dir\\test";
sanitizePath(path);
- REQUIRE(path == "dir/test");
+ REQUIRE(path == "dir" + sep + "test");
path = "dir/test/";
sanitizePath(path);
- REQUIRE(path == "dir/test/");
+ REQUIRE(path == "dir" + sep + "test" + sep);
path = "dir/test\\";
sanitizePath(path);
- REQUIRE(path == "dir/test/");
+ REQUIRE(path == "dir" + sep + "test" + sep);
path = "/very\\long/dir\\with\\sepa/ra/tors";
sanitizePath(path);
- REQUIRE(path == "/very/long/dir/with/sepa/ra/tors");
+ REQUIRE(path == sep + "very" + sep + "long" + sep + \
+ "dir" + sep + "with" + sep + "sepa" + sep + "ra" + sep + "tors");
path = "/very\\long/dir\\\\with\\sepa//ra/tors";
sanitizePath(path);
- REQUIRE(path == "/very/long/dir/with/sepa/ra/tors");
+ REQUIRE(path == sep + "very" + sep + "long" + sep + \
+ "dir" + sep + "with" + sep + "sepa" + sep + "ra" + sep + "tors");
}
TEST_CASE("stringuntils secureChatCommand")
@@ -1358,6 +1361,8 @@ TEST_CASE("stringuntils secureChatCommand")
REQUIRE(str == "_#test");
}
+#ifndef WIN32
+// disabled on windows for now, because no gettext
TEST_CASE("stringuntils timeDiffToString")
{
REQUIRE(timeDiffToString(60 * 60 * 24 * 7) == "1 week");
@@ -1388,10 +1393,10 @@ TEST_CASE("stringuntils timeDiffToString")
REQUIRE(timeDiffToString(60 * 7
) == "7 minutes");
}
+#endif // WIN32
TEST_CASE("stringuntils replaceItemLinks")
{
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
diff --git a/src/utils/translation/poparser_unittest.cc b/src/utils/translation/poparser_unittest.cc
index c7fc2e560..510be11bb 100644
--- a/src/utils/translation/poparser_unittest.cc
+++ b/src/utils/translation/poparser_unittest.cc
@@ -48,7 +48,6 @@ TEST_CASE("PoParser tests", "PoParser")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
logger = new Logger();
ResourceManager::init();
VirtFs::addDirToSearchPathSilent("data", Append_false);
diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc
index ee5451fc6..64ee293b7 100644
--- a/src/utils/xml_unittest.cc
+++ b/src/utils/xml_unittest.cc
@@ -48,7 +48,6 @@ TEST_CASE("xml doc")
setEnv("SDL_VIDEODRIVER", "dummy");
client = new Client;
- dirSeparator = "/";
XML::initXML();
logger = new Logger();
ResourceManager::init();
diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc
index 6653952cc..b28d3ec9d 100644
--- a/src/utils/xmlutils_unittest.cc
+++ b/src/utils/xmlutils_unittest.cc
@@ -41,7 +41,6 @@
TEST_CASE("xmlutils readXmlIntVector 1")
{
client = new Client;
- dirSeparator = "/";
XML::initXML();
logger = new Logger();
ResourceManager::init();
@@ -88,7 +87,6 @@ TEST_CASE("xmlutils readXmlIntVector 1")
TEST_CASE("xmlutils readXmlStringMap 1")
{
client = new Client;
- dirSeparator = "/";
XML::initXML();
logger = new Logger();
ResourceManager::init();
@@ -134,7 +132,6 @@ TEST_CASE("xmlutils readXmlStringMap 1")
TEST_CASE("xmlutils readXmlIntMap 1")
{
client = new Client;
- dirSeparator = "/";
XML::initXML();
logger = new Logger();
ResourceManager::init();