aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-03-04 12:55:24 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-05 15:01:19 -0300
commitc6917641c2793fe27c88659dcf466612957f2ec3 (patch)
treeb23827c1ffb1534631c0a5adcb042b92563f7329
parentd3be9f37969c2cda2acb138af717c3e490b4a548 (diff)
downloadrneovim-c6917641c2793fe27c88659dcf466612957f2ec3.tar.gz
rneovim-c6917641c2793fe27c88659dcf466612957f2ec3.tar.bz2
rneovim-c6917641c2793fe27c88659dcf466612957f2ec3.zip
Add unit tests for mch_isdir.
-rw-r--r--test/unit/os_unix.moon40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/os_unix.moon b/test/unit/os_unix.moon
new file mode 100644
index 0000000000..2e817673a4
--- /dev/null
+++ b/test/unit/os_unix.moon
@@ -0,0 +1,40 @@
+{:cimport, :eq, :ffi} = require 'test.unit.helpers'
+
+cstr = ffi.typeof 'char[?]'
+os = cimport './src/os_unix.h'
+
+describe 'os_unix function', ->
+ describe 'mch_isdir', ->
+ TRUE = 1
+ FALSE = 0
+
+ ffi.cdef('int mch_isdir(char * name);')
+
+ mch_isdir = (name) ->
+ name = cstr (string.len name), name
+ os.mch_isdir(name)
+
+ setup ->
+ lfs.mkdir 'empty-test-directory'
+ lfs.touch 'empty-test-directory/test.file'
+
+ teardown ->
+ lfs.rmdir 'empty-test-directory'
+
+ it 'returns false if an empty string is given', ->
+ eq FALSE, (mch_isdir '')
+
+ it 'returns false if a nonexisting directory is given', ->
+ eq FALSE, (mch_isdir 'non-existing-directory')
+
+ it 'returns false if an existing file is given', ->
+ eq FALSE, (mch_isdir 'non-existing-directory/test.file')
+
+ it 'returns true if the current directory is given', ->
+ eq TRUE, (mch_isdir '.')
+
+ it 'returns true if the parent directory is given', ->
+ eq TRUE, (mch_isdir '..')
+
+ it 'returns true if an newly created directory is given', ->
+ eq TRUE, (mch_isdir 'empty-test-directory')