From eb341685bf126bf082ad47fac1155839c8a9dcc6 Mon Sep 17 00:00:00 2001 From: Pranav Srinivas Kumar Date: Sun, 31 Mar 2019 16:59:45 -0400 Subject: [PATCH] Added test to square a number --- tests/test_positional_arguments.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_positional_arguments.hpp b/tests/test_positional_arguments.hpp index a5164ac..67a1c8b 100644 --- a/tests/test_positional_arguments.hpp +++ b/tests/test_positional_arguments.hpp @@ -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); @@ -59,4 +59,14 @@ TEST_CASE("Parse positional arguments with optional arguments in the middle", "[ REQUIRE(outputs.size() == 2); 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("square") == 225); } \ No newline at end of file