refactor/rename: path_try_shorten_fname()

This commit is contained in:
Justin M. Keyes
2018-03-24 13:56:55 +01:00
parent 998a16c926
commit 7ae4144208
5 changed files with 12 additions and 12 deletions

View File

@@ -261,7 +261,7 @@ describe('path.c', function()
end)
end)
describe('path_shorten_fname_if_possible', function()
describe('path_try_shorten_fname', function()
local cwd = lfs.currentdir()
before_each(function()
@@ -273,22 +273,22 @@ describe('path_shorten_fname_if_possible', function()
lfs.rmdir('ut_directory')
end)
describe('path_shorten_fname_if_possible', function()
describe('path_try_shorten_fname', function()
itp('returns shortened path if possible', function()
lfs.chdir('ut_directory')
local full = to_cstr(lfs.currentdir() .. '/subdir/file.txt')
eq('subdir/file.txt', (ffi.string(cimp.path_shorten_fname_if_possible(full))))
eq('subdir/file.txt', (ffi.string(cimp.path_try_shorten_fname(full))))
end)
itp('returns `full_path` if a shorter version is not possible', function()
local old = lfs.currentdir()
lfs.chdir('ut_directory')
local full = old .. '/subdir/file.txt'
eq(full, (ffi.string(cimp.path_shorten_fname_if_possible(to_cstr(full)))))
eq(full, (ffi.string(cimp.path_try_shorten_fname(to_cstr(full)))))
end)
itp('returns NULL if `full_path` is NULL', function()
eq(NULL, (cimp.path_shorten_fname_if_possible(NULL)))
eq(NULL, (cimp.path_try_shorten_fname(NULL)))
end)
end)
end)