remove redundant tests

develop
myk002 2021-07-02 23:29:02 -07:00
parent 37e8dd4a10
commit aefb893daa
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 0 additions and 115 deletions

@ -55,106 +55,3 @@ function test.invert_overwrite()
expect.eq(i.a, 3)
end
function test.processArgsGetopt_happy_path()
local quiet, verbose, name
local function process(args, expected_q, expected_v, expected_n)
quiet, verbose, name = false, false, nil
local nonoptions = utils.processArgsGetopt(args, {
{'q', handler=function() quiet = true end},
{'v', 'verbose', handler=function() verbose = true end},
{'n', 'name', hasArg=true,
handler=function(optarg) name = optarg end},
})
expect.eq(expected_q, quiet)
expect.eq(expected_v, verbose)
expect.eq(expected_n, name)
return nonoptions
end
local args = {}
expect.table_eq({}, process(args, false, false, nil))
args = {'-q'}
expect.table_eq({}, process(args, true, false, nil))
args = {'-v'}
expect.table_eq({}, process(args, false, true, nil))
args = {'--verbose'}
expect.table_eq({}, process(args, false, true, nil))
args = {'-n', 'foo'}
expect.table_eq({}, process(args, false, false, 'foo'))
args = {'-n', 'foo'}
expect.table_eq({}, process(args, false, false, 'foo'))
args = {'-nfoo'}
expect.table_eq({}, process(args, false, false, 'foo'))
args = {'--name', 'foo'}
expect.table_eq({}, process(args, false, false, 'foo'))
args = {'--name=foo'}
expect.table_eq({}, process(args, false, false, 'foo'))
args = {'-vqnfoo'}
expect.table_eq({}, process(args, true, true, 'foo'))
args = {'nonopt1', '-nfoo', 'nonopt2', '-1', '-10', '-0v'}
expect.table_eq({'nonopt1', 'nonopt2', '-1', '-10', '-0v'},
process(args, false, false, 'foo'))
args = {'nonopt1', '--', '-nfoo', '--nonopt2', 'nonopt3'}
expect.table_eq({'nonopt1', '-nfoo', '--nonopt2', 'nonopt3'},
process(args, false, false, nil))
end
function test.processArgsGetopt_action_errors()
expect.error_match('missing option letter',
function() utils.processArgsGetopt({}, {{handler=function() end}}) end)
expect.error_match('missing option letter',
function() utils.processArgsGetopt({}, {{'notoneletter'}}) end)
expect.error_match('missing option letter',
function() utils.processArgsGetopt({}, {{function() end}}) end)
expect.error_match('handler missing',
function() utils.processArgsGetopt({}, {{'r'}}) end)
end
function test.processArgsGetopt_parsing_errors()
expect.error_match('Unknown option',
function() utils.processArgsGetopt({'-abc'},
{{'a', handler=function() end}})
end,
'use undefined short option')
expect.error_match('Unknown option',
function() utils.processArgsGetopt({'--abc'},
{{'a', handler=function() end}})
end,
'use undefined long option')
expect.error_match('Bad usage',
function() utils.processArgsGetopt({'--ab=c'},
{{'a', 'ab', handler=function() end}})
end,
'pass value to param that does not take one')
expect.error_match('Missing value',
function() utils.processArgsGetopt({'-a'},
{{'a', 'ab', hasArg=true,
handler=function() end}})
end,
'fail to pass value to short param that requires one')
expect.error_match('Missing value',
function() utils.processArgsGetopt({'--ab'},
{{'a', 'ab', hasArg=true,
handler=function() end}})
end,
'fail to pass value to long param that requires one')
end

@ -23,18 +23,6 @@ function test.parse_gui_commandline()
expect.table_eq({auto_phase=true, name='blueprint', start={x=1,y=2,z=3}},
opts)
opts = {}
expect.error_match('invalid argument',
function() b.parse_gui_commandline(
opts, {'--cursor=-1,2,3'}) end,
'negative coordinate')
opts = {}
expect.error_match('invalid argument',
function() b.parse_gui_commandline(
opts, {'--cursor=1,b,3'}) end,
'non-numeric coordinate')
opts = {}
b.parse_gui_commandline(opts, {'imaname'})
expect.table_eq({auto_phase=true, name='imaname'}, opts)