mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
added a few tests for :pparse()
This commit is contained in:
19
spec/pparse_spec.lua
Normal file
19
spec/pparse_spec.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
local Parser = require "argparse"
|
||||
|
||||
describe("tests related to :pparse()", function()
|
||||
it("returns true and result on success", function()
|
||||
local parser = Parser()
|
||||
parser:option "-s" "--server"
|
||||
local ok, args = parser:pparse{"--server", "foo"}
|
||||
assert.is_true(ok)
|
||||
assert.same({server = "foo"}, args)
|
||||
end)
|
||||
|
||||
it("returns false and bare error message on failure", function()
|
||||
local parser = Parser()
|
||||
parser:argument "foo"
|
||||
local ok, errmsg = parser:pparse{}
|
||||
assert.is_false(ok)
|
||||
assert.equal("too few arguments", errmsg)
|
||||
end)
|
||||
end)
|
Reference in New Issue
Block a user