summaryrefslogtreecommitdiff
path: root/src/utils/stringutils_unittest.cc
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 /src/utils/stringutils_unittest.cc
parent6f7f469430ea05946a11dd41f62010961be6285e (diff)
downloadmanaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.gz
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.bz2
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.xz
manaverse-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.zip
Fix unit tests on windows.
Diffstat (limited to 'src/utils/stringutils_unittest.cc')
-rw-r--r--src/utils/stringutils_unittest.cc53
1 files changed, 29 insertions, 24 deletions
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);