mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Added test to square a number
This commit is contained in:
parent
02f40c3721
commit
eb341685bf
@ -44,7 +44,7 @@ TEST_CASE("Parse positional arguments with optional arguments", "[positional_arg
|
||||
REQUIRE(outputs[1] == "output.mesh");
|
||||
}
|
||||
|
||||
TEST_CASE("Parse positional arguments with optional arguments in the middle", "[parse_args]") {
|
||||
TEST_CASE("Parse positional arguments with optional arguments in the middle", "[positional_arguments]") {
|
||||
argparse::ArgumentParser program("test");
|
||||
program.add_argument("input");
|
||||
program.add_argument("output").nargs(2);
|
||||
@ -60,3 +60,13 @@ TEST_CASE("Parse positional arguments with optional arguments in the middle", "[
|
||||
REQUIRE(outputs[0] == "thrust_profile.csv");
|
||||
REQUIRE(outputs[1] == "output.mesh");
|
||||
}
|
||||
|
||||
TEST_CASE("Square a number", "[positional_arguments]") {
|
||||
argparse::ArgumentParser program;
|
||||
program.add_argument("square")
|
||||
.help("display a square of a given number")
|
||||
.action([](const std::string& value) { auto integer = std::stoi(value); return integer * integer; });
|
||||
|
||||
program.parse_args({"./main", "15"});
|
||||
REQUIRE(program.get<int>("square") == 225);
|
||||
}
|
Loading…
Reference in New Issue
Block a user