aboutsummaryrefslogtreecommitdiff
path: root/test/helpers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/helpers.lua')
-rw-r--r--test/helpers.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index 795808005d..89cf13f917 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -627,6 +627,19 @@ local function table_flatten(arr)
return result
end
+-- Checks if a list-like (vector) table contains `value`.
+local function table_contains(t, value)
+ if type(t) ~= 'table' then
+ error('t must be a table')
+ end
+ for _,v in ipairs(t) do
+ if v == value then
+ return true
+ end
+ end
+ return false
+end
+
local function hexdump(str)
local len = string.len(str)
local dump = ""
@@ -771,6 +784,7 @@ local module = {
repeated_read_cmd = repeated_read_cmd,
shallowcopy = shallowcopy,
sleep = sleep,
+ table_contains = table_contains,
table_flatten = table_flatten,
tmpname = tmpname,
uname = uname,