GitHub PullRequestReviewCommentEvent at 2014-03-09 14:46:26
Repository: neovim
Actor: lslah
Payload: {"comment":{"url":"https://api.github.com/repos/neovim/neovim/pulls/comments/10414078","id":10414078,"diff_hunk":"@@ -0,0 +1,90 @@\n+{:cimport, :internalize, :eq, :ffi, :lib, :cstr} = require 'test.unit.helpers'\n+\n+-- fs = cimport './src/os/os.h'\n+-- remove these statements once 'cimport' is working properly for misc1.h\n+users = lib\n+ffi.cdef [[\n+typedef struct growarray {\n+  int ga_len;\n+  int ga_maxlen;\n+  int ga_itemsize;\n+  int ga_growsize;\n+  void    *ga_data;\n+} garray_T;\n+int mch_get_usernames(garray_T *usernames);\n+int mch_get_user_name(char *s, size_t len);\n+int mch_get_uname(int uid, char *s, size_t len);\n+char *mch_get_user_directory(const char *name);\n+int getuid(void);\n+]]\n+\n+NULL = ffi.cast 'void*', 0\n+OK = 1\n+FAIL = 0\n+\n+garray_new = () ->\n+  ffi.new 'garray_T[1]'\n+\n+garray_get_len = (array) ->\n+  array[0].ga_len\n+\n+garray_get_item = (array, index) ->\n+  (ffi.cast 'void **', array[0].ga_data)[index]\n+\n+\n+describe 'users function', ->\n+\n+  -- will probably not work on windows\n+  current_username = os.getenv 'USER'\n+\n+  describe 'mch_get_usernames', ->\n+\n+    it 'returns FAIL if called with NULL', ->\n+      eq FAIL, users.mch_get_usernames NULL\n+\n+    it 'fills the names garray with os usernames and returns OK', ->\n+      ga_users = garray_new!\n+      eq OK, users.mch_get_usernames ga_users\n+      user_count = garray_get_len ga_users\n+      eq true, user_count > 0\n+      current_username_found = false\n+      for i = 0, user_count - 1\n+        name = ffi.string (garray_get_item ga_users, i)\n+        if name == current_username\n+          current_username_found = true\n+      eq true, current_username_found","path":"test/unit/os/users.moon","position":55,"original_position":55,"commit_id":"cb8c73af44b9e47671258fd5f49c5af92e2b201c","original_commit_id":"cb8c73af44b9e47671258fd5f49c5af92e2b201c","user":{"login":"lslah","id":340100,"avatar_url":"https://gravatar.com/avatar/3c8f885beca04f196a7a7085639c7fd7?d=https%3A%2F%2Fidenticons.github.com%2F5b63cbe7f289a2b42c119b163541758a.png&r=x","gravatar_id":"3c8f885beca04f196a7a7085639c7fd7","url":"https://api.github.com/users/lslah","html_url":"https://github.com/lslah","followers_url":"https://api.github.com/users/lslah/followers","following_url":"https://api.github.com/users/lslah/following{/other_user}","gists_url":"https://api.github.com/users/lslah/gists{/gist_id}","starred_url":"https://api.github.com/users/lslah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lslah/subscriptions","organizations_url":"https://api.github.com/users/lslah/orgs","repos_url":"https://api.github.com/users/lslah/repos","events_url":"https://api.github.com/users/lslah/events{/privacy}","received_events_url":"https://api.github.com/users/lslah/received_events","type":"User","site_admin":false},"body":"`assert.is_true current_username_found` would be more readable here.","created_at":"2014-03-09T14:46:26Z","updated_at":"2014-03-09T14:46:26Z","html_url":"https://github.com/neovim/neovim/pull/313#discussion_r10414078","pull_request_url":"https://api.github.com/repos/neovim/neovim/pulls/313","_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments/10414078"},"html":{"href":"https://github.com/neovim/neovim/pull/313#discussion_r10414078"},"pull_request":{"href":"https://api.github.com/repos/neovim/neovim/pulls/313"}}}}