Skip to content

Commit

Permalink
Added unit test for #239
Browse files Browse the repository at this point in the history
  • Loading branch information
p-ranav committed Nov 4, 2023
1 parent 281f1ab commit bbb2ea5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test_optional_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,30 @@ TEST_CASE("Parse arguments of different types" *
REQUIRE(program["-string-view"] == true);
REQUIRE(program["-builtin"s] == true);
}

TEST_CASE("Parse quoted negative numbers as values to optional arguments" *
test_suite("optional_arguments")) {
using namespace std::literals;

argparse::ArgumentParser program("test");

program.add_argument( "--user-origin")
.default_value( std::string() )
.help( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" );

SUBCASE("Double quotes, positive number") {
REQUIRE_NOTHROW(program.parse_args({"test", "--user-origin=\"56.100000x27.000000mm\""}));
}

SUBCASE("Single quotes, positive number") {
REQUIRE_NOTHROW(program.parse_args({"test", "--user-origin='56.100000x27.000000mm'"}));
}

SUBCASE("Double quotes, negative number") {
REQUIRE_NOTHROW(program.parse_args({"test", "--user-origin=\"-56.100000x27.000000mm\""}));
}

SUBCASE("Single quotes, negative number") {
REQUIRE_NOTHROW(program.parse_args({"test", "--user-origin='-56.100000x27.000000mm'"}));
}
}

0 comments on commit bbb2ea5

Please sign in to comment.