summaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-09-04 12:36:30 +0300
committerrobot-piglet <[email protected]>2025-09-04 12:47:15 +0300
commitfead7358fba89416b24101245e1e2d80b511febf (patch)
tree3451403ed7492a117a7699494450ab03f623e0ab /library/cpp
parentc029afad9f05609faea295c8ba76996f9a07fbef (diff)
Intermediate changes
commit_hash:953617f2251dbf97b237f24d08a7b08816adb90b
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/getopt/ut/last_getopt_ut.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp
index e5fc1ccc03f..e3432d7471a 100644
--- a/library/cpp/getopt/ut/last_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/last_getopt_ut.cpp
@@ -867,4 +867,36 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
TOptsParseResultTestWrapper(&opts, {"copy", "-fr"}));
}
}
+
+ Y_UNIT_TEST(TestMutuallyExclusive) {
+ // FIXME: somehow MutuallyExclusive() does not work without SetFlag()
+ bool flag;
+ TOptsNoDefault opts;
+ opts.AddLongOption("do").SetFlag(&flag);
+ opts.AddLongOption("dont").SetFlag(&flag);
+ opts.AddLongOption("maybe-do-maybe-dont").SetFlag(&flag);
+
+ opts.MutuallyExclusive("do", "dont", "maybe-do-maybe-dont");
+
+ UNIT_ASSERT_EXCEPTION(
+ TOptsParseResultTestWrapper(&opts, {"--do", "--dont"}),
+ TUsageException
+ );
+ UNIT_ASSERT_EXCEPTION(
+ TOptsParseResultTestWrapper(&opts, {"--dont", "--maybe-do-maybe-dont"}),
+ TUsageException
+ );
+ UNIT_ASSERT_EXCEPTION(
+ TOptsParseResultTestWrapper(&opts, {"--do", "--maybe-do-maybe-dont"}),
+ TUsageException
+ );
+ UNIT_ASSERT_EXCEPTION(
+ TOptsParseResultTestWrapper(&opts, {"-d", "-n"}),
+ TUsageException
+ );
+ UNIT_ASSERT_EXCEPTION(
+ TOptsParseResultTestWrapper(&opts, {"--do", "--dont", "--maybe-do-maybe-dont"}),
+ TUsageException
+ );
+ }
}