aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorStefan Hoffmann <stefan991@gmail.com>2014-03-06 23:20:29 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-13 17:18:44 -0300
commitce31410c7953a19421a2f2df2d3e6654601da930 (patch)
treed07b8af604b81c6323ba5dc405fcdd7f9397abf6 /test/unit
parent6fd9f090fc66c3ba38dc07ea6c982c3124735f32 (diff)
downloadrneovim-ce31410c7953a19421a2f2df2d3e6654601da930.tar.gz
rneovim-ce31410c7953a19421a2f2df2d3e6654601da930.tar.bz2
rneovim-ce31410c7953a19421a2f2df2d3e6654601da930.zip
moved mch_get_user_name() and mch_get_uname() into os/users.c
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/os/users.moon31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/unit/os/users.moon b/test/unit/os/users.moon
index 366407d5c8..2f08bdbdf5 100644
--- a/test/unit/os/users.moon
+++ b/test/unit/os/users.moon
@@ -12,6 +12,9 @@ typedef struct growarray {
void *ga_data;
} garray_T;
int mch_get_usernames(garray_T *usernames);
+int mch_get_user_name(char *s, size_t len);
+int mch_get_uname(int uid, char *s, size_t len);
+int getuid(void);
]]
NULL = ffi.cast 'void*', 0
@@ -30,10 +33,10 @@ garray_get_item = (array, index) ->
describe 'users function', ->
- describe 'mch_get_usernames', ->
+ -- will probably not work on windows
+ current_username = os.getenv 'USER'
- -- will probably not work on windows
- current_username = os.getenv 'USER'
+ describe 'mch_get_usernames', ->
it 'returns FAIL if called with NULL', ->
eq FAIL, users.mch_get_usernames NULL
@@ -50,3 +53,25 @@ describe 'users function', ->
current_username_found = true
assert.is_true current_username_found
+ describe 'mch_get_user_name', ->
+
+ it 'should write the username into the buffer and return OK', ->
+ name_out = ffi.new 'char[100]'
+ eq OK, users.mch_get_user_name(name_out, 100)
+ eq current_username, ffi.string name_out
+
+ describe 'mch_get_uname', ->
+
+ it 'should write the username into the buffer and return OK', ->
+ name_out = ffi.new 'char[100]'
+ user_id = lib.getuid!
+ eq OK, users.mch_get_uname(user_id, name_out, 100)
+ eq current_username, ffi.string name_out
+
+ it 'should FAIL if the userid is not found', ->
+ name_out = ffi.new 'char[100]'
+ -- hoping nobody has this uid
+ user_id = 2342
+ eq FAIL, users.mch_get_uname(user_id, name_out, 100)
+ eq '2342', ffi.string name_out
+