mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for absolutePath() and sanitizePath()
This commit is contained in:
parent
9bce5f91dc
commit
1718fad088
@ -25,12 +25,16 @@
|
||||
#include <test/FilesystemUtils.h>
|
||||
#include <test/libsolidity/util/SoltestErrors.h>
|
||||
|
||||
#include <boost/test/data/test_case.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
using namespace std::string_literals;
|
||||
using namespace solidity::test;
|
||||
|
||||
#define TEST_CASE_NAME (boost::unit_test::framework::current_test_case().p_name)
|
||||
@ -38,6 +42,22 @@ using namespace solidity::test;
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
/// Joins two paths in a way that matches the way used by util::absolutePath() to
|
||||
/// combine the import with the reference. Not generic - only does enough to handle example
|
||||
/// paths used in this test suite.
|
||||
std::string absolutePathJoin(std::string const& _parent, std::string const& _suffix)
|
||||
{
|
||||
if (!_parent.empty() && _parent != "/" && !_suffix.empty())
|
||||
return _parent + "/" + _suffix;
|
||||
|
||||
return _parent + _suffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(CommonIOTest)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readFileAsString_regular_file)
|
||||
@ -98,6 +118,426 @@ BOOST_AUTO_TEST_CASE(readBytes_past_end)
|
||||
BOOST_CHECK_EQUAL(readBytes(inputStream, 20), "");
|
||||
}
|
||||
|
||||
BOOST_DATA_TEST_CASE(
|
||||
absolutePath_direct_import,
|
||||
boost::unit_test::data::make(std::vector<char const*>{
|
||||
"",
|
||||
"/",
|
||||
"x",
|
||||
"/x",
|
||||
"x/",
|
||||
"/x/",
|
||||
"x/y",
|
||||
"/x/y",
|
||||
"x/y/",
|
||||
"/x/y/",
|
||||
".",
|
||||
"..",
|
||||
"./../.../../."
|
||||
}),
|
||||
reference
|
||||
)
|
||||
{
|
||||
// absolutePath() should have no effect on a direct import, regardless of what the source
|
||||
// unit name of the importing module is.
|
||||
|
||||
BOOST_TEST(absolutePath("", reference) == "");
|
||||
BOOST_TEST(absolutePath("/", reference) == "/");
|
||||
BOOST_TEST(absolutePath("//", reference) == "//");
|
||||
BOOST_TEST(absolutePath("///", reference) == "///");
|
||||
|
||||
BOOST_TEST(absolutePath("\\", reference) == "\\");
|
||||
BOOST_TEST(absolutePath("\\\\", reference) == "\\\\");
|
||||
BOOST_TEST(absolutePath("\\\\\\", reference) == "\\\\\\");
|
||||
|
||||
BOOST_TEST(absolutePath(".\\", reference) == ".\\");
|
||||
BOOST_TEST(absolutePath(".\\\\", reference) == ".\\\\");
|
||||
BOOST_TEST(absolutePath(".\\\\\\", reference) == ".\\\\\\");
|
||||
|
||||
BOOST_TEST(absolutePath("..\\", reference) == "..\\");
|
||||
BOOST_TEST(absolutePath("..\\\\", reference) == "..\\\\");
|
||||
BOOST_TEST(absolutePath("..\\\\\\", reference) == "..\\\\\\");
|
||||
|
||||
BOOST_TEST(absolutePath("...", reference) == "...");
|
||||
BOOST_TEST(absolutePath("....", reference) == "....");
|
||||
BOOST_TEST(absolutePath("...a", reference) == "...a");
|
||||
|
||||
BOOST_TEST(absolutePath("/./", reference) == "/./");
|
||||
BOOST_TEST(absolutePath("/././", reference) == "/././");
|
||||
BOOST_TEST(absolutePath("/../", reference) == "/../");
|
||||
BOOST_TEST(absolutePath("/../../", reference) == "/../../");
|
||||
BOOST_TEST(absolutePath("//..//..//", reference) == "//..//..//");
|
||||
BOOST_TEST(absolutePath("///..///..///", reference) == "///..///..///");
|
||||
|
||||
BOOST_TEST(absolutePath("@", reference) == "@");
|
||||
BOOST_TEST(absolutePath(":", reference) == ":");
|
||||
BOOST_TEST(absolutePath("|", reference) == "|");
|
||||
BOOST_TEST(absolutePath("<>", reference) == "<>");
|
||||
BOOST_TEST(absolutePath("123", reference) == "123");
|
||||
BOOST_TEST(absolutePath("https://example.com", reference) == "https://example.com");
|
||||
|
||||
BOOST_TEST(absolutePath("a", reference) == "a");
|
||||
BOOST_TEST(absolutePath("a/", reference) == "a/");
|
||||
BOOST_TEST(absolutePath("/a", reference) == "/a");
|
||||
BOOST_TEST(absolutePath("/a/", reference) == "/a/");
|
||||
|
||||
BOOST_TEST(absolutePath("a/b", reference) == "a/b");
|
||||
BOOST_TEST(absolutePath("a/b/", reference) == "a/b/");
|
||||
BOOST_TEST(absolutePath("/a/b", reference) == "/a/b");
|
||||
BOOST_TEST(absolutePath("/a/b/", reference) == "/a/b/");
|
||||
|
||||
BOOST_TEST(absolutePath("/.", reference) == "/.");
|
||||
BOOST_TEST(absolutePath("a.", reference) == "a.");
|
||||
BOOST_TEST(absolutePath("a/.", reference) == "a/.");
|
||||
BOOST_TEST(absolutePath("/a/.", reference) == "/a/.");
|
||||
BOOST_TEST(absolutePath("a/./", reference) == "a/./");
|
||||
BOOST_TEST(absolutePath("/a/./", reference) == "/a/./");
|
||||
|
||||
BOOST_TEST(absolutePath("/..", reference) == "/..");
|
||||
BOOST_TEST(absolutePath("a..", reference) == "a..");
|
||||
BOOST_TEST(absolutePath("a/..", reference) == "a/..");
|
||||
BOOST_TEST(absolutePath("/a/..", reference) == "/a/..");
|
||||
BOOST_TEST(absolutePath("a/../", reference) == "a/../");
|
||||
BOOST_TEST(absolutePath("/a/../", reference) == "/a/../");
|
||||
|
||||
BOOST_TEST(absolutePath("a//", reference) == "a//");
|
||||
BOOST_TEST(absolutePath("//a", reference) == "//a");
|
||||
BOOST_TEST(absolutePath("//a//", reference) == "//a//");
|
||||
|
||||
BOOST_TEST(absolutePath("a//b", reference) == "a//b");
|
||||
BOOST_TEST(absolutePath("a//b//", reference) == "a//b//");
|
||||
BOOST_TEST(absolutePath("//a//b", reference) == "//a//b");
|
||||
BOOST_TEST(absolutePath("//a//b//", reference) == "//a//b//");
|
||||
|
||||
BOOST_TEST(absolutePath("a\\b", reference) == "a\\b");
|
||||
BOOST_TEST(absolutePath("a\\b\\", reference) == "a\\b\\");
|
||||
BOOST_TEST(absolutePath("\\a\\b", reference) == "\\a\\b");
|
||||
BOOST_TEST(absolutePath("\\a\\b\\", reference) == "\\a\\b\\");
|
||||
}
|
||||
|
||||
BOOST_DATA_TEST_CASE(
|
||||
absolutePath_relative_import_no_backtracking_into_reference,
|
||||
boost::unit_test::data::make(std::vector<std::tuple<char const*, std::string>>{
|
||||
{"", ""},
|
||||
{"/", "/"},
|
||||
{"x", ""},
|
||||
{"/x", "/"},
|
||||
{"x/", "x"},
|
||||
{"/x/", "/x"},
|
||||
{"x/y", "x"},
|
||||
{"/x/y", "/x"},
|
||||
{"x/y/", "x/y"},
|
||||
{"/x/y/", "/x/y"},
|
||||
}),
|
||||
reference,
|
||||
parent
|
||||
)
|
||||
{
|
||||
BOOST_TEST(absolutePath(".", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath(".//", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath(".///", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./.", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("././", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath(".//./", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./a", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./a/", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./a/b", reference) == absolutePathJoin(parent, "a/b"));
|
||||
BOOST_TEST(absolutePath("./a/b/", reference) == absolutePathJoin(parent, "a/b"));
|
||||
|
||||
BOOST_TEST(absolutePath("./@", reference) == absolutePathJoin(parent, "@"));
|
||||
BOOST_TEST(absolutePath("./:", reference) == absolutePathJoin(parent, ":"));
|
||||
BOOST_TEST(absolutePath("./|", reference) == absolutePathJoin(parent, "|"));
|
||||
BOOST_TEST(absolutePath("./<>", reference) == absolutePathJoin(parent, "<>"));
|
||||
BOOST_TEST(absolutePath("./123", reference) == absolutePathJoin(parent, "123"));
|
||||
BOOST_TEST(absolutePath("./https://example.com", reference) == absolutePathJoin(parent, "https:/example.com"));
|
||||
|
||||
BOOST_TEST(absolutePath(".//a", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath(".//a//", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath(".//a//b", reference) == absolutePathJoin(parent, "a/b"));
|
||||
BOOST_TEST(absolutePath(".//a//b//", reference) == absolutePathJoin(parent, "a/b"));
|
||||
|
||||
BOOST_TEST(absolutePath("./a\\", reference) == absolutePathJoin(parent, "a\\"));
|
||||
BOOST_TEST(absolutePath("./a\\b", reference) == absolutePathJoin(parent, "a\\b"));
|
||||
BOOST_TEST(absolutePath("./a\\b\\", reference) == absolutePathJoin(parent, "a\\b\\"));
|
||||
|
||||
BOOST_TEST(absolutePath("./a/.", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./a/b/.", reference) == absolutePathJoin(parent, "a/b"));
|
||||
BOOST_TEST(absolutePath("./a/./b/.", reference) == absolutePathJoin(parent, "a/b"));
|
||||
|
||||
BOOST_TEST(absolutePath("./a/..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/../", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/b/..", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./a/b/../", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./a/../b", reference) == absolutePathJoin(parent, "b"));
|
||||
BOOST_TEST(absolutePath("./a/../b/", reference) == absolutePathJoin(parent, "b"));
|
||||
BOOST_TEST(absolutePath("./a/../b/..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/../b/../", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./a\\..", reference) == absolutePathJoin(parent, "a\\.."));
|
||||
BOOST_TEST(absolutePath("./a\\..\\", reference) == absolutePathJoin(parent, "a\\..\\"));
|
||||
BOOST_TEST(absolutePath("./a\\b\\..", reference) == absolutePathJoin(parent, "a\\b\\.."));
|
||||
BOOST_TEST(absolutePath("./a\\b\\..\\", reference) == absolutePathJoin(parent, "a\\b\\..\\"));
|
||||
BOOST_TEST(absolutePath("./a\\..\\b", reference) == absolutePathJoin(parent, "a\\..\\b"));
|
||||
BOOST_TEST(absolutePath("./a\\..\\b\\", reference) == absolutePathJoin(parent, "a\\..\\b\\"));
|
||||
BOOST_TEST(absolutePath("./a\\..\\b\\..\\", reference) == absolutePathJoin(parent, "a\\..\\b\\..\\"));
|
||||
|
||||
BOOST_TEST(absolutePath("./a\\../..", reference) == absolutePathJoin(parent, ""));
|
||||
}
|
||||
|
||||
BOOST_DATA_TEST_CASE(
|
||||
absolutePath_relative_import_with_backtracking_1_level_into_reference,
|
||||
boost::unit_test::data::make(std::vector<std::tuple<char const*, char const*>>{
|
||||
{"", ""},
|
||||
{"/", ""},
|
||||
{"x", ""},
|
||||
{"/x", ""},
|
||||
{"x/", ""},
|
||||
{"/x/", "/"},
|
||||
{"x/y", ""},
|
||||
{"/x/y", "/"},
|
||||
{"x/y/", "x"},
|
||||
{"/x/y/", "/x"},
|
||||
}),
|
||||
reference,
|
||||
parent
|
||||
)
|
||||
{
|
||||
BOOST_TEST(absolutePath("..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("../", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("..//", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("..///", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("../a", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("../a/", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("../a/b", reference) == absolutePathJoin(parent, "a/b"));
|
||||
BOOST_TEST(absolutePath("../a/b/", reference) == absolutePathJoin(parent, "a/b"));
|
||||
|
||||
BOOST_TEST(absolutePath("../@", reference) == absolutePathJoin(parent, "@"));
|
||||
BOOST_TEST(absolutePath("../:", reference) == absolutePathJoin(parent, ":"));
|
||||
BOOST_TEST(absolutePath("../|", reference) == absolutePathJoin(parent, "|"));
|
||||
BOOST_TEST(absolutePath("../<>", reference) == absolutePathJoin(parent, "<>"));
|
||||
BOOST_TEST(absolutePath("../123", reference) == absolutePathJoin(parent, "123"));
|
||||
BOOST_TEST(absolutePath("../https://example.com", reference) == absolutePathJoin(parent, "https:/example.com"));
|
||||
|
||||
BOOST_TEST(absolutePath("../a/..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("../a/b/..", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("../a/b/../..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("../a/../b/..", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./../a/..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./../a/b/..", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("./../a/b/../..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./../a/../b/..", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./a/../..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/b/../../..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/../b/../..", reference) == absolutePathJoin(parent, ""));
|
||||
BOOST_TEST(absolutePath("./a/../../b/..", reference) == absolutePathJoin(parent, ""));
|
||||
|
||||
BOOST_TEST(absolutePath("./a/../../c", reference) == absolutePathJoin(parent, "c"));
|
||||
BOOST_TEST(absolutePath("./a/b/../../../c", reference) == absolutePathJoin(parent, "c"));
|
||||
BOOST_TEST(absolutePath("./a/../b/../../c", reference) == absolutePathJoin(parent, "c"));
|
||||
BOOST_TEST(absolutePath("./a/../../b/../c/d", reference) == absolutePathJoin(parent, "c/d"));
|
||||
|
||||
BOOST_TEST(absolutePath("..//a", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath("..//a//", reference) == absolutePathJoin(parent, "a"));
|
||||
BOOST_TEST(absolutePath(".//a//..//..//b", reference) == absolutePathJoin(parent, "b"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(absolutePath_relative_import_with_backtracking_multiple_levels_level_into_reference)
|
||||
{
|
||||
BOOST_TEST(absolutePath("..", "x/y/z/") == "x/y");
|
||||
BOOST_TEST(absolutePath("../..", "x/y/z/") == "x");
|
||||
BOOST_TEST(absolutePath("../../..", "x/y/z/") == "");
|
||||
BOOST_TEST(absolutePath("../../../..", "x/y/z/") == "");
|
||||
|
||||
BOOST_TEST(absolutePath("..", "/x/y/z/") == "/x/y");
|
||||
BOOST_TEST(absolutePath("../..", "/x/y/z/") == "/x");
|
||||
BOOST_TEST(absolutePath("../../..", "/x/y/z/") == "/");
|
||||
BOOST_TEST(absolutePath("../../../..", "/x/y/z/") == "");
|
||||
|
||||
BOOST_TEST(absolutePath("../../../../a", "x/y/z/") == "a");
|
||||
BOOST_TEST(absolutePath("../../../../a/..", "x/y/z/") == "");
|
||||
BOOST_TEST(absolutePath("../../../../a/../a", "x/y/z/") == "a");
|
||||
|
||||
BOOST_TEST(absolutePath("../.", "x/y/z/") == "x/y");
|
||||
BOOST_TEST(absolutePath(".././..", "x/y/z/") == "x");
|
||||
BOOST_TEST(absolutePath(".././.././..", "x/y/z/") == "");
|
||||
BOOST_TEST(absolutePath("./../././.././.././..", "x/y/z/") == "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(absolutePath_relative_import_and_relative_segments_in_reference)
|
||||
{
|
||||
BOOST_TEST(absolutePath(".", "x/../y/./z/") == "x/../y/./z");
|
||||
BOOST_TEST(absolutePath("..", "x/../y/./z/") == "x/../y/.");
|
||||
BOOST_TEST(absolutePath("../..", "x/../y/./z/") == "x/../y");
|
||||
BOOST_TEST(absolutePath("../../..", "x/../y/./z/") == "x/..");
|
||||
BOOST_TEST(absolutePath("../../../..", "x/../y/./z/") == "x");
|
||||
BOOST_TEST(absolutePath("../../../../..", "x/../y/./z/") == "");
|
||||
BOOST_TEST(absolutePath("../../../../../..", "x/../y/./z/") == "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(absolutePath_relative_import_and_consecutive_slashes_in_reference)
|
||||
{
|
||||
BOOST_TEST(absolutePath(".", "/x/") == "/x");
|
||||
BOOST_TEST(absolutePath("..", "/x/") == "/");
|
||||
BOOST_TEST(absolutePath("../..", "/x/") == "");
|
||||
|
||||
BOOST_TEST(absolutePath(".", "//x//") == "//x//");
|
||||
BOOST_TEST(absolutePath("..", "//x//") == "//x");
|
||||
BOOST_TEST(absolutePath("../..", "//x//") == "");
|
||||
|
||||
BOOST_TEST(absolutePath(".", "///x///") == "///x");
|
||||
BOOST_TEST(absolutePath("..", "///x///") == "/");
|
||||
BOOST_TEST(absolutePath("../..", "///x///") == "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(absolutePath_relative_import_and_unnormalized_slashes_in_reference)
|
||||
{
|
||||
BOOST_TEST(absolutePath(".", "//x//y\\z/\\//") == "//x//y\\z/\\");
|
||||
BOOST_TEST(absolutePath("..", "//x//y\\z/\\//") == "//x//y\\z");
|
||||
BOOST_TEST(absolutePath("../..", "//x//y\\z/\\//") == "//x/");
|
||||
BOOST_TEST(absolutePath("../../..", "//x//y\\z/\\//") == "//x");
|
||||
BOOST_TEST(absolutePath("../../../..", "//x//y\\z/\\//") == "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sanitizePath_direct_import)
|
||||
{
|
||||
BOOST_TEST(sanitizePath("") == "");
|
||||
BOOST_TEST(sanitizePath("/") == "/");
|
||||
BOOST_TEST(sanitizePath("//") == "//");
|
||||
BOOST_TEST(sanitizePath("///") == "///");
|
||||
|
||||
BOOST_TEST(sanitizePath("\\") == "\\");
|
||||
BOOST_TEST(sanitizePath("\\\\") == "\\\\");
|
||||
BOOST_TEST(sanitizePath("\\\\\\") == "\\\\\\");
|
||||
|
||||
BOOST_TEST(sanitizePath(".\\") == ".\\");
|
||||
BOOST_TEST(sanitizePath(".\\\\") == ".\\\\");
|
||||
BOOST_TEST(sanitizePath(".\\\\\\") == ".\\\\\\");
|
||||
|
||||
BOOST_TEST(sanitizePath("..\\") == "..\\");
|
||||
BOOST_TEST(sanitizePath("..\\\\") == "..\\\\");
|
||||
BOOST_TEST(sanitizePath("..\\\\\\") == "..\\\\\\");
|
||||
|
||||
BOOST_TEST(sanitizePath("...") == "...");
|
||||
BOOST_TEST(sanitizePath("....") == "....");
|
||||
BOOST_TEST(sanitizePath("...a") == "...a");
|
||||
|
||||
BOOST_TEST(sanitizePath("/./") == "/./");
|
||||
BOOST_TEST(sanitizePath("/././") == "/././");
|
||||
BOOST_TEST(sanitizePath("/../") == "/../");
|
||||
BOOST_TEST(sanitizePath("/../../") == "/../../");
|
||||
BOOST_TEST(sanitizePath("//..//..//") == "//..//..//");
|
||||
BOOST_TEST(sanitizePath("///..///..///") == "///..///..///");
|
||||
|
||||
BOOST_TEST(sanitizePath("@") == "@");
|
||||
BOOST_TEST(sanitizePath(":") == ":");
|
||||
BOOST_TEST(sanitizePath("|") == "|");
|
||||
BOOST_TEST(sanitizePath("<>") == "<>");
|
||||
BOOST_TEST(sanitizePath("123") == "123");
|
||||
BOOST_TEST(sanitizePath("https://example.com") == "https://example.com");
|
||||
|
||||
BOOST_TEST(sanitizePath("a") == "a");
|
||||
BOOST_TEST(sanitizePath("a/") == "a/");
|
||||
BOOST_TEST(sanitizePath("/a") == "/a");
|
||||
BOOST_TEST(sanitizePath("/a/") == "/a/");
|
||||
|
||||
BOOST_TEST(sanitizePath("a/b") == "a/b");
|
||||
BOOST_TEST(sanitizePath("a/b/") == "a/b/");
|
||||
BOOST_TEST(sanitizePath("/a/b") == "/a/b");
|
||||
BOOST_TEST(sanitizePath("/a/b/") == "/a/b/");
|
||||
|
||||
BOOST_TEST(sanitizePath("/.") == "/.");
|
||||
BOOST_TEST(sanitizePath("a.") == "a.");
|
||||
BOOST_TEST(sanitizePath("a/.") == "a/.");
|
||||
BOOST_TEST(sanitizePath("/a/.") == "/a/.");
|
||||
BOOST_TEST(sanitizePath("a/./") == "a/./");
|
||||
BOOST_TEST(sanitizePath("/a/./") == "/a/./");
|
||||
|
||||
BOOST_TEST(sanitizePath("/..") == "/..");
|
||||
BOOST_TEST(sanitizePath("a..") == "a..");
|
||||
BOOST_TEST(sanitizePath("a/..") == "a/..");
|
||||
BOOST_TEST(sanitizePath("/a/..") == "/a/..");
|
||||
BOOST_TEST(sanitizePath("a/../") == "a/../");
|
||||
BOOST_TEST(sanitizePath("/a/../") == "/a/../");
|
||||
|
||||
BOOST_TEST(sanitizePath("a//") == "a//");
|
||||
BOOST_TEST(sanitizePath("//a") == "//a");
|
||||
BOOST_TEST(sanitizePath("//a//") == "//a//");
|
||||
|
||||
BOOST_TEST(sanitizePath("a//b") == "a//b");
|
||||
BOOST_TEST(sanitizePath("a//b//") == "a//b//");
|
||||
BOOST_TEST(sanitizePath("//a//b") == "//a//b");
|
||||
BOOST_TEST(sanitizePath("//a//b//") == "//a//b//");
|
||||
|
||||
BOOST_TEST(sanitizePath("a\\b") == "a\\b");
|
||||
BOOST_TEST(sanitizePath("a\\b\\") == "a\\b\\");
|
||||
BOOST_TEST(sanitizePath("\\a\\b") == "\\a\\b");
|
||||
BOOST_TEST(sanitizePath("\\a\\b\\") == "\\a\\b\\");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sanitizePath_relative_import)
|
||||
{
|
||||
BOOST_TEST(sanitizePath(".") == ".");
|
||||
BOOST_TEST(sanitizePath("./") == "./");
|
||||
BOOST_TEST(sanitizePath(".//") == ".//");
|
||||
BOOST_TEST(sanitizePath(".///") == ".///");
|
||||
|
||||
BOOST_TEST(sanitizePath("./.") == "./.");
|
||||
BOOST_TEST(sanitizePath("././") == "././");
|
||||
BOOST_TEST(sanitizePath(".//./") == ".//./");
|
||||
|
||||
BOOST_TEST(sanitizePath("./a") == "./a");
|
||||
BOOST_TEST(sanitizePath("./a/") == "./a/");
|
||||
BOOST_TEST(sanitizePath("./a/b") == "./a/b");
|
||||
BOOST_TEST(sanitizePath("./a/b/") == "./a/b/");
|
||||
|
||||
BOOST_TEST(sanitizePath("./@") == "./@");
|
||||
BOOST_TEST(sanitizePath("./:") == "./:");
|
||||
BOOST_TEST(sanitizePath("./|") == "./|");
|
||||
BOOST_TEST(sanitizePath("./<>") == "./<>");
|
||||
BOOST_TEST(sanitizePath("./123") == "./123");
|
||||
BOOST_TEST(sanitizePath("./https://example.com") == "./https://example.com");
|
||||
|
||||
BOOST_TEST(sanitizePath(".//a") == ".//a");
|
||||
BOOST_TEST(sanitizePath(".//a//") == ".//a//");
|
||||
BOOST_TEST(sanitizePath(".//a//b") == ".//a//b");
|
||||
BOOST_TEST(sanitizePath(".//a//b//") == ".//a//b//");
|
||||
|
||||
BOOST_TEST(sanitizePath("./a\\") == "./a\\");
|
||||
BOOST_TEST(sanitizePath("./a\\b") == "./a\\b");
|
||||
BOOST_TEST(sanitizePath("./a\\b\\") == "./a\\b\\");
|
||||
|
||||
BOOST_TEST(sanitizePath("./a/.") == "./a/.");
|
||||
BOOST_TEST(sanitizePath("./a/b/.") == "./a/b/.");
|
||||
BOOST_TEST(sanitizePath("./a/./b/.") == "./a/./b/.");
|
||||
|
||||
BOOST_TEST(sanitizePath("./a/..") == "./a/..");
|
||||
BOOST_TEST(sanitizePath("./a/b/..") == "./a/b/..");
|
||||
BOOST_TEST(sanitizePath("./a/../b/../") == "./a/../b/../");
|
||||
|
||||
BOOST_TEST(sanitizePath("./a\\..\\b\\..\\") == "./a\\..\\b\\..\\");
|
||||
BOOST_TEST(sanitizePath("./a\\../..") == "./a\\../..");
|
||||
|
||||
BOOST_TEST(sanitizePath("..") == "..");
|
||||
BOOST_TEST(sanitizePath("../") == "../");
|
||||
BOOST_TEST(sanitizePath("..//") == "..//");
|
||||
BOOST_TEST(sanitizePath("..///") == "..///");
|
||||
|
||||
BOOST_TEST(sanitizePath("../..") == "../..");
|
||||
BOOST_TEST(sanitizePath("../../") == "../../");
|
||||
BOOST_TEST(sanitizePath("../../../") == "../../../");
|
||||
BOOST_TEST(sanitizePath("../../../../") == "../../../../");
|
||||
|
||||
BOOST_TEST(sanitizePath("../a") == "../a");
|
||||
BOOST_TEST(sanitizePath("../a/..") == "../a/..");
|
||||
BOOST_TEST(sanitizePath("./a/../../b/../c/d") == "./a/../../b/../c/d");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace solidity::util::test
|
||||
|
Loading…
Reference in New Issue
Block a user