diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-10 18:35:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-10 18:35:16 +0300 |
commit | 9c53b966c34d505e27681f2ed51998d3a737a663 (patch) | |
tree | 689af8fb285a3192e20c6906e4b84f54b0db0c32 /src/utils/stringutils_unittest.cc | |
parent | 4df1e68047488ec00a264c076bb3222715f42295 (diff) | |
download | mv-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.cc | 77 |
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; |