mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Add another test for remaining
This commit is contained in:
parent
2cfe115dfb
commit
aae2e9347a
@ -133,3 +133,16 @@ TEST_CASE("Users can use actions on nargs=ANY arguments" *
|
||||
program.parse_args({"sum", "42", "100", "-3", "-20"});
|
||||
REQUIRE(result == 119);
|
||||
}
|
||||
|
||||
TEST_CASE("Users can use actions on remaining arguments" *
|
||||
test_suite("actions")) {
|
||||
argparse::ArgumentParser program("concat");
|
||||
|
||||
std::string result = "";
|
||||
program.add_argument("all").remaining().action(
|
||||
[](std::string &sum, std::string const &value) { sum += value; },
|
||||
std::ref(result));
|
||||
|
||||
program.parse_args({"concat", "a", "-b", "-c", "--d"});
|
||||
REQUIRE(result == "a-b-c--d");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user