aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-03-30 13:42:03 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-03 10:32:41 -0300
commit77bfb6cd990c67e4191d4858af82de42303e1939 (patch)
treed7c6fbf45cbe581fbf4e3edabf506d8fcf153037 /test
parent6d712defa52e58627aca5c875677d14d705300e8 (diff)
downloadrneovim-77bfb6cd990c67e4191d4858af82de42303e1939.tar.gz
rneovim-77bfb6cd990c67e4191d4858af82de42303e1939.tar.bz2
rneovim-77bfb6cd990c67e4191d4858af82de42303e1939.zip
Test and refactor gettail -> path_tail.
Diffstat (limited to 'test')
-rw-r--r--test/unit/path.moon15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/unit/path.moon b/test/unit/path.moon
index b989283c1d..9004cc241c 100644
--- a/test/unit/path.moon
+++ b/test/unit/path.moon
@@ -1,4 +1,4 @@
-{:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
+{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
path = lib
@@ -7,10 +7,12 @@ typedef enum file_comparison {
FPC_SAME = 1, FPC_DIFF = 2, FPC_NOTX = 4, FPC_DIFFX = 6, FPC_SAMEX = 7
} FileComparison;
FileComparison path_full_compare(char_u *s1, char_u *s2, int checkname);
+char_u *path_tail(char_u *fname);
]]
-- import constants parsed by ffi
{:FPC_SAME, :FPC_DIFF, :FPC_NOTX, :FPC_DIFFX, :FPC_SAMEX} = path
+NULL = ffi.cast 'void*', 0
describe 'path function', ->
describe 'path_full_compare', ->
@@ -49,3 +51,14 @@ describe 'path function', ->
eq FPC_DIFFX, (path_full_compare f1, 'null.txt')
eq FPC_DIFFX, (path_full_compare 'null.txt', f1)
+ describe 'path_tail', ->
+ path_tail = (file) ->
+ res = path.path_tail (to_cstr file)
+ neq NULL, res
+ ffi.string res
+
+ it 'returns the tail of a given file path', ->
+ eq 'file.txt', path_tail 'directory/file.txt'
+
+ it 'returns an empty string if file ends in a slash', ->
+ eq '', path_tail 'directory/'