Added test to square a number

This commit is contained in:
Pranav Srinivas Kumar 2019-03-31 16:59:45 -04:00
parent 02f40c3721
commit eb341685bf

View File

@ -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);
}