|
|
@ -58,17 +58,23 @@ function test.processArgsGetopt_happy_path()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function test.processArgsGetopt_action_errors()
|
|
|
|
function test.processArgsGetopt_action_errors()
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
function()
|
|
|
|
function()
|
|
|
|
argparse.processArgsGetopt({}, {{handler=function() end}})
|
|
|
|
argparse.processArgsGetopt({}, {{handler=function() end}})
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
function() argparse.processArgsGetopt({}, {{'notoneletter'}}) end)
|
|
|
|
function() argparse.processArgsGetopt({}, {{'notoneletter'}}) end)
|
|
|
|
|
|
|
|
|
|
|
|
expect.error_match('missing option letter',
|
|
|
|
expect.error_match('option letter not found',
|
|
|
|
function() argparse.processArgsGetopt({}, {{function() end}}) end)
|
|
|
|
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',
|
|
|
|
expect.error_match('handler missing',
|
|
|
|
function() argparse.processArgsGetopt({}, {{'r'}}) end)
|
|
|
|
function() argparse.processArgsGetopt({}, {{'r'}}) end)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -107,6 +113,15 @@ function test.processArgsGetopt_parsing_errors()
|
|
|
|
'fail to pass value to long param that requires one')
|
|
|
|
'fail to pass value to long param that requires one')
|
|
|
|
end
|
|
|
|
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()
|
|
|
|
function test.stringList()
|
|
|
|
expect.table_eq({'happy', 'path'}, argparse.stringList(' happy , path'),
|
|
|
|
expect.table_eq({'happy', 'path'}, argparse.stringList(' happy , path'),
|
|
|
|
'ensure elements are trimmed')
|
|
|
|
'ensure elements are trimmed')
|
|
|
|