test(lsp): file URIs without a hostname

This commit is contained in:
Alessandro Pezzoni 2021-07-07 23:39:27 +01:00
parent a2c2a08652
commit ce5f4228aa

View File

@ -53,12 +53,18 @@ describe('URI methods', function()
describe('uri to filepath', function()
describe('decode Unix file path', function()
it('file path includes only ascii charactors', function()
it('file path includes only ascii characters', function()
exec_lua("uri = 'file:///Foo/Bar/Baz.txt'")
eq('/Foo/Bar/Baz.txt', exec_lua("return vim.uri_to_fname(uri)"))
end)
it('local file path without hostname', function()
exec_lua("uri = 'file:/Foo/Bar/Baz.txt'")
eq('/Foo/Bar/Baz.txt', exec_lua("return vim.uri_to_fname(uri)"))
end)
it('file path including white space', function()
exec_lua("uri = 'file:///Foo%20/Bar/Baz.txt'")
@ -85,6 +91,15 @@ describe('URI methods', function()
eq('C:\\Foo\\Bar\\Baz.txt', exec_lua(test_case))
end)
it('local file path without hostname', function()
local test_case = [[
local uri = 'file:/C:/Foo/Bar/Baz.txt'
return vim.uri_to_fname(uri)
]]
eq('C:\\Foo\\Bar\\Baz.txt', exec_lua(test_case))
end)
it('file path includes only ascii charactors with encoded colon character', function()
local test_case = [[
local uri = 'file:///C%3A/Foo/Bar/Baz.txt'