summaryrefslogtreecommitdiff
path: root/src/utils/stringutils_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-10 18:35:16 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-10 18:35:16 +0300
commit9c53b966c34d505e27681f2ed51998d3a737a663 (patch)
tree689af8fb285a3192e20c6906e4b84f54b0db0c32 /src/utils/stringutils_unittest.cc
parent4df1e68047488ec00a264c076bb3222715f42295 (diff)
downloadmv-9c53b966c34d505e27681f2ed51998d3a737a663.tar.gz
mv-9c53b966c34d505e27681f2ed51998d3a737a663.tar.bz2
mv-9c53b966c34d505e27681f2ed51998d3a737a663.tar.xz
mv-9c53b966c34d505e27681f2ed51998d3a737a663.zip
Add pathJoin functions for join parts of path.
Diffstat (limited to 'src/utils/stringutils_unittest.cc')
-rw-r--r--src/utils/stringutils_unittest.cc77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index dd60af3cd..712935820 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -1339,6 +1339,83 @@ TEST_CASE("stringuntils sanitizePath")
"dir" + sep + "with" + sep + "sepa" + sep + "ra" + sep + "tors");
}
+TEST_CASE("stringuntils pathJoin1")
+{
+ const std::string sep = dirSeparator;
+
+ REQUIRE(pathJoin("", "") == sep);
+ REQUIRE(pathJoin(sep, "") == sep);
+ REQUIRE(pathJoin("", sep) == sep);
+ REQUIRE(pathJoin(sep, sep) == sep);
+ REQUIRE(pathJoin("dir1", "dir2") == "dir1" + sep + "dir2");
+ REQUIRE(pathJoin("dir1" + sep, "dir2") == "dir1" + sep + "dir2");
+ REQUIRE(pathJoin("dir1", sep + "dir2") == "dir1" + sep + "dir2");
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2") == "dir1" + sep + "dir2");
+ REQUIRE(pathJoin("dir1" + sep + "dir2" + sep + "dir3", "dir4") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
+ REQUIRE(pathJoin("dir1" + sep + "dir2" + sep, "dir3" + sep + "dir4") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
+ REQUIRE(pathJoin("dir1" + sep + "dir2", "dir3" + sep + "dir4") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
+ REQUIRE(pathJoin("dir1" + sep + "dir2", sep + "dir3" + sep + "dir4") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
+}
+
+TEST_CASE("stringuntils pathJoin2")
+{
+ const std::string sep = dirSeparator;
+
+ REQUIRE(pathJoin("", "", "") == sep);
+ REQUIRE(pathJoin(sep, "", "") == sep);
+ REQUIRE(pathJoin("", sep, "") == sep);
+ REQUIRE(pathJoin("", "", sep) == sep);
+ REQUIRE(pathJoin(sep, sep, "") == sep);
+ REQUIRE(pathJoin(sep, "", sep) == sep);
+ REQUIRE(pathJoin("", sep, sep) == sep);
+ REQUIRE(pathJoin(sep, sep, sep) == sep);
+
+ REQUIRE(pathJoin("dir1", "dir2", "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, "dir2", "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1", sep + "dir2", "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1", "dir2" + sep, "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1", "dir2", sep + "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1", "dir2", "dir3" + sep) ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep);
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2", "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, "dir2" + sep, "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, "dir2", sep + "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2", sep + "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, sep + "dir3") ==
+ "dir1" + sep + "dir2" + sep + "dir3");
+ REQUIRE(pathJoin("dir1" + sep + "dir2" + sep + "dir3", "dir4", "dir5") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
+ REQUIRE(pathJoin("dir1" + sep + "dir2" + sep,
+ "dir3" + sep + "dir4",
+ "dir5") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
+ REQUIRE(pathJoin("dir1" + sep + "dir2",
+ "dir3",
+ sep + "dir4" + sep + "dir5") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
+ REQUIRE(pathJoin("dir1" + sep + "dir2",
+ sep + "dir3" + sep + "dir4",
+ sep + "dir5") ==
+ "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
+}
+
TEST_CASE("stringuntils secureChatCommand")
{
std::string str;