mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
19 lines
591 B
C++
19 lines
591 B
C++
#pragma once
|
|
#include <catch.hpp>
|
|
#include <argparse.hpp>
|
|
|
|
TEST_CASE("Users can use defaul value inside actions", "[actions]") {
|
|
argparse::ArgumentParser program("test");
|
|
program.add_argument("input")
|
|
.default_value("bar")
|
|
.action([=](const std::string& value) {
|
|
static const std::vector<std::string> choices = { "foo", "bar", "baz" };
|
|
if (std::find(choices.begin(), choices.end(), value) != choices.end()) {
|
|
return value;
|
|
}
|
|
return std::string{ "bar" };
|
|
});
|
|
|
|
program.parse_args({ "test", "fez" });
|
|
REQUIRE(program.get("input") == "bar");
|
|
} |