test(unit): add unit tests for path_with_url

This commit is contained in:
zeertzjq 2022-01-24 13:01:35 +08:00
parent 9bb9f17592
commit c0a97d982a

View File

@ -626,4 +626,20 @@ describe('path.c', function()
eq(false, path_with_extension('/some/path/file', 'lua'))
end)
end)
describe('path_with_url', function()
itp('scheme is alpha and inner hyphen only', function()
local function path_with_url(fname)
return cimp.path_with_url(to_cstr(fname))
end
eq(1, path_with_url([[test://xyz/foo/b0]]))
eq(2, path_with_url([[test:\\xyz\foo\b0]]))
eq(0, path_with_url([[test+abc://xyz/foo/b1]]))
eq(0, path_with_url([[test_abc://xyz/foo/b2]]))
eq(1, path_with_url([[test-abc://xyz/foo/b3]]))
eq(2, path_with_url([[test-abc:\\xyz\foo\b3]]))
eq(0, path_with_url([[-test://xyz/foo/b4]]))
eq(0, path_with_url([[test-://xyz/foo/b5]]))
end)
end)
end)