aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/ut/last_getopt_ut.cpp
diff options
context:
space:
mode:
authorbulatkhr <bulatkhr@yandex-team.com>2022-07-15 10:12:22 +0300
committerbulatkhr <bulatkhr@yandex-team.com>2022-07-15 10:12:22 +0300
commit03cf908feb326c966c4384fde4360f08d9b5b4e1 (patch)
tree29faaf859522f25ba29220000dac674ac364569a /library/cpp/getopt/ut/last_getopt_ut.cpp
parentb63fb26957f120f5cbf2a363d9fef60df2e7c2ae (diff)
downloadydb-03cf908feb326c966c4384fde4360f08d9b5b4e1.tar.gz
Allow skip arg in opt parser
add UnnecessaryArgument
Diffstat (limited to 'library/cpp/getopt/ut/last_getopt_ut.cpp')
-rw-r--r--library/cpp/getopt/ut/last_getopt_ut.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp
index c99a1d053d..6606000ca6 100644
--- a/library/cpp/getopt/ut/last_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/last_getopt_ut.cpp
@@ -415,6 +415,40 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
}
#endif
+ Y_UNIT_TEST(TestEqParseOnly) {
+ TOptsParserTester tester;
+
+ tester.Argv_.push_back("cmd");
+ tester.Argv_.push_back("--data=jjhh");
+ tester.Argv_.push_back("-n");
+ tester.Argv_.push_back("11");
+ tester.Argv_.push_back("--optional-number-1=8");
+ tester.Argv_.push_back("--optional-string-1=os1");
+ tester.Argv_.push_back("--optional-number-2");
+ tester.Argv_.push_back("10");
+ tester.Argv_.push_back("--optional-string-2");
+ tester.Argv_.push_back("freearg");
+
+ tester.Opts_.AddLongOption('d', "data");
+ tester.Opts_.AddLongOption('n', "number");
+ tester.Opts_.AddLongOption("optional-string-0");
+ tester.Opts_.AddLongOption("optional-number-0");
+ tester.Opts_.AddLongOption("optional-string-1");
+ tester.Opts_.AddLongOption("optional-number-1");
+ tester.Opts_.AddLongOption("optional-string-2").OptionalArgument().DisableSpaceParse();
+ tester.Opts_.AddLongOption("optional-number-2").OptionalArgument();
+
+ tester.AcceptOptionWithValue("data", "jjhh");
+ tester.AcceptOptionWithValue('n', "11");
+ tester.AcceptOptionWithValue("optional-number-1", "8");
+ tester.AcceptOptionWithValue("optional-string-1", "os1");
+ tester.AcceptOptionWithValue("optional-number-2", "10");
+ tester.AcceptOptionWithoutValue("optional-string-2");
+ tester.AcceptEndOfOptions();
+ tester.AcceptFreeArg("freearg");
+ tester.AcceptEndOfFreeArgs();
+ }
+
Y_UNIT_TEST(TestStoreResult) {
TOptsNoDefault opts;
TString data;