summaryrefslogtreecommitdiff
path: root/tests/modules/path/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-10 00:57:05 +0800
committerruki <[email protected]>2022-03-10 00:57:05 +0800
commit205f1d2ae8281955b22b868eb16741a86e44da58 (patch)
treeda3661eef0fe90aee853ae207fdb61727436d98b /tests/modules/path/test.lua
parent01afb1c8e997a4ce98bf107393101ea4cbb7e26b (diff)
add path.normalize
Diffstat (limited to 'tests/modules/path/test.lua')
-rw-r--r--tests/modules/path/test.lua40
1 files changed, 23 insertions, 17 deletions
diff --git a/tests/modules/path/test.lua b/tests/modules/path/test.lua
index 3df399b65..2d4b09238 100644
--- a/tests/modules/path/test.lua
+++ b/tests/modules/path/test.lua
@@ -90,34 +90,40 @@ function test_translate(t)
t:are_equal(path.translate(""), nil)
t:are_equal(path.translate("."), ".")
t:are_equal(path.translate(".."), "..")
- t:are_equal(path.translate("././.", {normalize = true}), ".")
- t:are_equal(path.translate("../foo/..", {normalize = true}), "..")
- t:are_equal(path.translate("../foo/bar/../..", {normalize = true}), "..")
if is_host("windows") then
t:are_equal(path.translate("c:"), "c:")
t:are_equal(path.translate("c:\\"), "c:")
t:are_equal(path.translate("c:\\foo\\\\\\"), "c:\\foo")
t:are_equal(path.translate("c:\\foo\\..\\.."), "c:\\foo\\..\\..")
- t:are_equal(path.translate("c:\\foo\\.\\.\\", {normalize = true}), "c:\\foo")
- t:are_equal(path.translate("c:\\foo\\bar\\.\\..\\xyz", {normalize = true}), "c:\\foo\\xyz")
- t:are_equal(path.translate("c:\\foo\\.\\..", {normalize = true}), "c:")
- t:are_equal(path.translate("../..", {normalize = true}), "..\\..")
- t:are_equal(path.translate("../foo/bar/..", {normalize = true}), "..\\foo")
- t:are_equal(path.translate("../foo/bar/../../..", {normalize = true}), "..\\..")
else
t:are_equal(path.translate("/"), "/");
t:are_equal(path.translate("////"), "/");
t:are_equal(path.translate("/foo//////"), "/foo");
t:are_equal(path.translate("/foo/../.."), "/foo/../..");
t:are_equal(path.translate("/foo/../../"), "/foo/../..");
- t:are_equal(path.translate("/foo/././", {normalize = true}), "/foo");
- t:are_equal(path.translate("/./././", {normalize = true}), "/");
- t:are_equal(path.translate("/foo/bar/.//..//xyz", {normalize = true}), "/foo/xyz");
- t:are_equal(path.translate("/foo/../..", {normalize = true}), "/");
- t:are_equal(path.translate("/foo/bar../..", {normalize = true}), "/foo");
- t:are_equal(path.translate("../..", {normalize = true}), "../..");
- t:are_equal(path.translate("../foo/bar/..", {normalize = true}), "../foo");
- t:are_equal(path.translate("../foo/bar/../../..", {normalize = true}), "../..");
+ end
+end
+
+function test_normalize(t)
+ t:are_equal(path.normalize("././."), ".")
+ t:are_equal(path.normalize("../foo/.."), "..")
+ t:are_equal(path.normalize("../foo/bar/../.."), "..")
+ if is_host("windows") then
+ t:are_equal(path.normalize("c:\\foo\\.\\.\\"), "c:\\foo")
+ t:are_equal(path.normalize("c:\\foo\\bar\\.\\..\\xyz"), "c:\\foo\\xyz")
+ t:are_equal(path.normalize("c:\\foo\\.\\.."), "c:")
+ t:are_equal(path.normalize("../.."), "..\\..")
+ t:are_equal(path.normalize("../foo/bar/.."), "..\\foo")
+ t:are_equal(path.normalize("../foo/bar/../../.."), "..\\..")
+ else
+ t:are_equal(path.normalize("/foo/././"), "/foo");
+ t:are_equal(path.normalize("/./././"), "/");
+ t:are_equal(path.normalize("/foo/bar/.//..//xyz"), "/foo/xyz");
+ t:are_equal(path.normalize("/foo/../.."), "/");
+ t:are_equal(path.normalize("/foo/bar../.."), "/foo");
+ t:are_equal(path.normalize("../.."), "../..");
+ t:are_equal(path.normalize("../foo/bar/.."), "../foo");
+ t:are_equal(path.normalize("../foo/bar/../../.."), "../..");
end
end