summaryrefslogtreecommitdiff
path: root/src/utils
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
parent6f7f469430ea05946a11dd41f62010961be6285e (diff)
downloadplus-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.gz
plus-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.bz2
plus-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.tar.xz
plus-bbd71d4a8c95092deb9cbf4aef86722a1e9628db.zip
Fix unit tests on windows.
Diffstat (limited to 'src/utils')
-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
5 files changed, 29 insertions, 30 deletions
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();