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:
Sean Robinson 2021-07-22 06:45:44 -07:00
parent 67d56afef8
commit b6cedf4d56

View File

@ -3,6 +3,14 @@
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")) {
argparse::ArgumentParser program("test");
program.add_argument("--config");