fixed crash on unknown long option

This commit is contained in:
mpeterv
2014-01-19 14:34:42 +04:00
parent 0e367c6f77
commit f7a0703e73
2 changed files with 13 additions and 4 deletions

View File

@@ -181,6 +181,14 @@ describe("tests related to options", function()
assert.has_error(function() parser:parse{"--server"} end, "too few arguments")
end)
it("handles unknown options correctly", function()
local parser = argparse.parser()
assert.has_error(function() parser:parse{"--server"} end, "unknown option --server")
assert.has_error(function() parser:parse{"--server=localhost"} end, "unknown option --server")
assert.has_error(function() parser:parse{"-s"} end, "unknown option -s")
assert.has_error(function() parser:parse{"-slocalhost"} end, "unknown option -s")
end)
it("handles too many arguments correctly", function()
local parser = argparse.parser()
parser:option("-s", "--server")