From 13b88573005d84cc0ebcd7e7bf4dd488673919d3 Mon Sep 17 00:00:00 2001 From: dm1try Date: Sun, 3 May 2020 23:46:55 +0300 Subject: path: add helper for checking a file extension --- test/unit/path_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua index 356c4997fa..41954de9be 100644 --- a/test/unit/path_spec.lua +++ b/test/unit/path_spec.lua @@ -603,4 +603,21 @@ describe('path.c', function() eq(FAIL, path_is_absolute('not/in/my/home~/directory')) end) end) + + describe('path_with_extension', function() + local function path_with_extension(filename, extension) + local c_filename = to_cstr(filename) + local c_extension = to_cstr(extension) + return cimp.path_with_extension(c_filename, c_extension) + end + + itp('returns true if filename includes a provided extension', function() + eq(true, path_with_extension('/some/path/file.lua', 'lua')) + end) + + itp('returns false if filename does not include a provided extension', function() + eq(false, path_with_extension('/some/path/file.vim', 'lua')) + eq(false, path_with_extension('/some/path/file', 'lua')) + end) + end) end) -- cgit