From 692e1c6fa31c41df11e6ade55fd601ffabcd8fe0 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 16:51:06 +0200 Subject: [PATCH 1/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index f5e98c2..11b19a1 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2808,3 +2808,13 @@ TEST_CASE("Parsing joined flags does not affect long options") CHECK(args.get_value("a") == true); CHECK(args.get_value("r") == true); } + +TEST_CASE("Parsing an optional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("-n").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "-n", "65"}); + + CHECK(args.get_value("n") == 65); +} From dd0966eb55d87d2f700235385f61d55d7f397cf5 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 16:51:55 +0200 Subject: [PATCH 2/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index 11b19a1..03210cb 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2818,3 +2818,13 @@ TEST_CASE("Parsing an optional argument yields correct value for positive number CHECK(args.get_value("n") == 65); } + +TEST_CASE("Parsing an optional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("-n").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "-n65"}); + + CHECK(args.get_value("n") == 65); +} From 1ce4c9c6474c1453a45b22a225ffdb93c064ae33 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 16:52:33 +0200 Subject: [PATCH 3/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index 03210cb..3f90aa3 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2828,3 +2828,13 @@ TEST_CASE("Parsing an optional argument yields correct value for positive number CHECK(args.get_value("n") == 65); } + +TEST_CASE("Parsing an optional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("--number").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "--number", "65"}); + + CHECK(args.get_value("number") == 65); +} From dfae9f18107d93784dbba2c26f89a340d3e3be05 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 16:53:16 +0200 Subject: [PATCH 4/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index 3f90aa3..e50c4c1 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2838,3 +2838,13 @@ TEST_CASE("Parsing an optional argument yields correct value for positive number CHECK(args.get_value("number") == 65); } + +TEST_CASE("Parsing an optional argument yields correct value for positive number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("--number").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "--number=65"}); + + CHECK(args.get_value("number") == 65); +} From e81ea6051270d5a9f63d96274da3fc63b48f9148 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:21:34 +0200 Subject: [PATCH 5/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index e50c4c1..1bea446 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2848,3 +2848,13 @@ TEST_CASE("Parsing an optional argument yields correct value for positive number CHECK(args.get_value("number") == 65); } + +TEST_CASE("Parsing an optional argument yields correct value for negative number" * doctest::skip()) +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("-n").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "-n", "-65"}); + + CHECK(args.get_value("n") == -65); +} From bbf1bfbd0cf33c3994734720234e627fd5687311 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:22:07 +0200 Subject: [PATCH 6/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index 1bea446..5884d8e 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2858,3 +2858,13 @@ TEST_CASE("Parsing an optional argument yields correct value for negative number CHECK(args.get_value("n") == -65); } + +TEST_CASE("Parsing an optional argument yields correct value for negative number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("-n").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "-n-65"}); + + CHECK(args.get_value("n") == -65); +} From 91f34163278ffb5b7fdee4f28b34c4e0385d5cd6 Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:23:06 +0200 Subject: [PATCH 7/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index 5884d8e..af9efde 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2868,3 +2868,13 @@ TEST_CASE("Parsing an optional argument yields correct value for negative number CHECK(args.get_value("n") == -65); } + +TEST_CASE("Parsing an optional argument yields correct value for negative number" * doctest::skip()) +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("--number").type(); + + auto const args = parser.parse_args(3, cstr_arr{"prog", "--number", "-65"}); + + CHECK(args.get_value("number") == -65); +} From 6b6a477fff03c486573fc4a9af71e3e00c118eac Mon Sep 17 00:00:00 2001 From: Krzysiek Karbowiak Date: Wed, 1 Oct 2025 20:27:32 +0200 Subject: [PATCH 8/8] Add unit test --- test/unittest/test_parsing_optional.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unittest/test_parsing_optional.cpp b/test/unittest/test_parsing_optional.cpp index af9efde..4b6e0d1 100644 --- a/test/unittest/test_parsing_optional.cpp +++ b/test/unittest/test_parsing_optional.cpp @@ -2878,3 +2878,13 @@ TEST_CASE("Parsing an optional argument yields correct value for negative number CHECK(args.get_value("number") == -65); } + +TEST_CASE("Parsing an optional argument yields correct value for negative number") +{ + auto parser = argparse::ArgumentParser(); + parser.add_argument("--number").type(); + + auto const args = parser.parse_args(2, cstr_arr{"prog", "--number=-65"}); + + CHECK(args.get_value("number") == -65); +}