aboutsummaryrefslogtreecommitdiff
path: root/test/unit/helpers.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-09-03 19:57:24 +0300
committerZyX <kp-pav@yandex.ru>2017-10-08 22:12:00 +0300
commit919223c23ae3c8c904f35e7d605b1cf14d44a5f0 (patch)
treef4bf252835533c02e9111f1463a6688766d48073 /test/unit/helpers.lua
parent1265da028882d9877a5ebbd3f3f52cb4b52a4b94 (diff)
downloadrneovim-919223c23ae3c8c904f35e7d605b1cf14d44a5f0.tar.gz
rneovim-919223c23ae3c8c904f35e7d605b1cf14d44a5f0.tar.bz2
rneovim-919223c23ae3c8c904f35e7d605b1cf14d44a5f0.zip
unittests: Move some functions into helpers modules
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r--test/unit/helpers.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index a629fca9a2..a5ca7b069b 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -760,6 +760,29 @@ end
cimport('./src/nvim/types.h', './src/nvim/main.h', './src/nvim/os/time.h')
+local function conv_enum(etab, eval)
+ local n = tonumber(eval)
+ return etab[n] or n
+end
+
+local function array_size(arr)
+ return ffi.sizeof(arr) / ffi.sizeof(arr[0])
+end
+
+local function kvi_size(kvi)
+ return array_size(kvi.init_array)
+end
+
+local function kvi_init(kvi)
+ kvi.capacity = kvi_size(kvi)
+ kvi.items = kvi.init_array
+ return kvi
+end
+
+local function kvi_new(ct)
+ return kvi_init(ffi.new(ct))
+end
+
local module = {
cimport = cimport,
cppimport = cppimport,
@@ -780,6 +803,11 @@ local module = {
child_call_once = child_call_once,
child_cleanup_once = child_cleanup_once,
sc = sc,
+ conv_enum = conv_enum,
+ array_size = array_sive,
+ kvi_size = kvi_size,
+ kvi_init = kvi_init,
+ kvi_new = kvi_new,
}
return function()
return module