From b6cedf4d56f8197a9e8a50cfda04ce0ab7d8f005 Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Thu, 22 Jul 2021 06:45:44 -0700 Subject: [PATCH] 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 --- test/test_parse_args.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_parse_args.cpp b/test/test_parse_args.cpp index a3a0452..f77d122 100644 --- a/test/test_parse_args.cpp +++ b/test/test_parse_args.cpp @@ -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");