|
|
|
@ -58,17 +58,23 @@ function test.processArgsGetopt_happy_path()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function test.processArgsGetopt_action_errors()
|
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
|
function()
|
|
|
|
|
argparse.processArgsGetopt({}, {{handler=function() end}})
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
|
function() argparse.processArgsGetopt({}, {{'notoneletter'}}) end)
|
|
|
|
|
|
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
|
function() argparse.processArgsGetopt({}, {{function() end}}) end)
|
|
|
|
|
|
|
|
|
|
expect.error_match('long option name',
|
|
|
|
|
function() argparse.processArgsGetopt({}, {{'', ''}}) end)
|
|
|
|
|
|
|
|
|
|
expect.error_match('long option name',
|
|
|
|
|
function() argparse.processArgsGetopt({}, {{'a', ''}}) end)
|
|
|
|
|
|
|
|
|
|
expect.error_match('handler missing',
|
|
|
|
|
function() argparse.processArgsGetopt({}, {{'r'}}) end)
|
|
|
|
|
end
|
|
|
|
@ -107,6 +113,15 @@ function test.processArgsGetopt_parsing_errors()
|
|
|
|
|
'fail to pass value to long param that requires one')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function test.processArgsGetopt_long_opt_without_short_opt()
|
|
|
|
|
local var = false
|
|
|
|
|
local nonoptions = argparse.processArgsGetopt(
|
|
|
|
|
{'--long'},
|
|
|
|
|
{{'', 'long', handler=function() var = true end}})
|
|
|
|
|
expect.true_(var)
|
|
|
|
|
expect.table_eq({}, nonoptions)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function test.stringList()
|
|
|
|
|
expect.table_eq({'happy', 'path'}, argparse.stringList(' happy , path'),
|
|
|
|
|
'ensure elements are trimmed')
|
|
|
|
|