mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Add test case for missing argument value
While it's good to test around error conditions, the main purpose of this test is to catch future changes in the error type and message. Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
parent
67d56afef8
commit
b6cedf4d56
@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
using doctest::test_suite;
|
using doctest::test_suite;
|
||||||
|
|
||||||
|
TEST_CASE("Missing argument" * test_suite("parse_args")) {
|
||||||
|
argparse::ArgumentParser program("test");
|
||||||
|
program.add_argument("--config").nargs(1);
|
||||||
|
REQUIRE_THROWS_WITH_AS(program.parse_args({ "test", "--config" }),
|
||||||
|
"Too few arguments",
|
||||||
|
std::runtime_error);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Parse a string argument with value" * test_suite("parse_args")) {
|
TEST_CASE("Parse a string argument with value" * test_suite("parse_args")) {
|
||||||
argparse::ArgumentParser program("test");
|
argparse::ArgumentParser program("test");
|
||||||
program.add_argument("--config");
|
program.add_argument("--config");
|
||||||
|
Loading…
Reference in New Issue
Block a user