From aae2e9347a2c036a81ce6f1ad1bad72fd5904de8 Mon Sep 17 00:00:00 2001 From: Yoshihiro Hokazono Date: Thu, 16 Sep 2021 06:42:01 +0900 Subject: [PATCH] Add another test for remaining --- test/test_actions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_actions.cpp b/test/test_actions.cpp index 1aff18f..b315d16 100644 --- a/test/test_actions.cpp +++ b/test/test_actions.cpp @@ -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"); +}