From ec57acfb24beb36cf0bc8a24d9ed91db9548c3d6 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:35:17 +0200 Subject: [PATCH 1/4] Add unit test --- test/unittest/test_parsing_positional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_positional.cpp b/test/unittest/test_parsing_positional.cpp index bba33cd..f2c456c 100644 --- a/test/unittest/test_parsing_positional.cpp +++ b/test/unittest/test_parsing_positional.cpp @@ -1914,3 +1914,13 @@ TEST_CASE("Parsing missing positional argument with nargs set throws an exceptio CHECK_THROWS_WITH_AS(parser.parse_args(1, cstr_arr{"prog"}), "the following arguments are required: p1 p2 p3", argparse::parsing_error); } + +TEST_CASE("Parsing a positional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("num").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "65"}); + + CHECK(args.get_value("num") == 65); +} From a8d238de497f2f3eb1f68aa19fe6824e6a98e237 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:36:17 +0200 Subject: [PATCH 2/4] Add unit test --- test/unittest/test_parsing_positional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_positional.cpp b/test/unittest/test_parsing_positional.cpp index f2c456c..2cf05a3 100644 --- a/test/unittest/test_parsing_positional.cpp +++ b/test/unittest/test_parsing_positional.cpp @@ -1924,3 +1924,13 @@ TEST_CASE("Parsing a positional argument yields correct value for positive numbe CHECK(args.get_value("num") == 65); } + +TEST_CASE("Parsing a positional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("num").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "--", "65"}); + + CHECK(args.get_value("num") == 65); +} From f90648fb14d66d760a1b14027208ad78a7dfd472 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:38:15 +0200 Subject: [PATCH 3/4] Add unit test --- test/unittest/test_parsing_positional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_positional.cpp b/test/unittest/test_parsing_positional.cpp index 2cf05a3..9fa5b59 100644 --- a/test/unittest/test_parsing_positional.cpp +++ b/test/unittest/test_parsing_positional.cpp @@ -1934,3 +1934,13 @@ TEST_CASE("Parsing a positional argument yields correct value for positive numbe CHECK(args.get_value("num") == 65); } + +TEST_CASE("Parsing a positional argument yields correct value for negative number" * doctest::skip()) +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("num").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "-65"}); + + CHECK(args.get_value("num") == -65); +} From 844d84b1e3c85fd3c426b549cf44632580ab4fae Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:39:05 +0200 Subject: [PATCH 4/4] Add unit test --- test/unittest/test_parsing_positional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_positional.cpp b/test/unittest/test_parsing_positional.cpp index 9fa5b59..bc43819 100644 --- a/test/unittest/test_parsing_positional.cpp +++ b/test/unittest/test_parsing_positional.cpp @@ -1944,3 +1944,13 @@ TEST_CASE("Parsing a positional argument yields correct value for negative numbe CHECK(args.get_value("num") == -65); } + +TEST_CASE("Parsing a positional argument yields correct value for negative number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("num").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "--", "-65"}); + + CHECK(args.get_value("num") == -65); +}