Throw in ParseResult::as when option isn't present

Fixes #124.
This commit is contained in:
Jarryd Beck
2018-11-19 17:45:51 +11:00
parent c713b44d92
commit 84feb4bd87
3 changed files with 8 additions and 0 deletions
+3
View File
@@ -53,6 +53,7 @@ TEST_CASE("Basic options", "[options]")
("a,av", "a short option with a value", cxxopts::value<std::string>())
("6,six", "a short number option")
("p, space", "an option with space between short and long")
("nothing", "won't exist", cxxopts::value<std::string>())
;
Argv argv({
@@ -92,6 +93,8 @@ TEST_CASE("Basic options", "[options]")
CHECK(arguments[1].key() == "short");
CHECK(arguments[2].key() == "value");
CHECK(arguments[3].key() == "av");
CHECK_THROWS_AS(result["nothing"].as<std::string>(), std::domain_error);
}
TEST_CASE("Short options", "[options]")