wireshark/test/lua/script_args.lua
Pascal Quantin 58db464aff Remove executable bit from a few files
Change-Id: Ib9be221e3d325379c8b665ab73d976254bb23bb6
Reviewed-on: https://code.wireshark.org/review/342
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-02-24 22:34:26 +00:00

37 lines
832 B
Lua

----------------------------------------
-- This just verifies the number of args it got is what it expected.
-- The first arg should be a number, for how many total args to expect,
-- including itself.
local function testing(...)
print("---- Testing "..tostring(...).." ----")
end
local function test(name, result)
io.stdout:write("test "..name.."...")
if result == true then
io.stdout:write("passed\n")
else
io.stdout:write("failed!\n")
error(name.." test failed!")
end
end
-----------------------------
testing("Command-line args")
local arg={...} -- get passed-in args
test("arg1", arg ~= nil and #arg > 0)
local numargs = tonumber(arg[1])
test("arg2", numargs ~= nil)
test("arg3", #arg == numargs)
print("\n-----------------------------\n")
print("All tests passed!\n\n")