diff options
author | lightqwant <lightqwant@yandex-team.com> | 2022-09-01 20:05:05 +0300 |
---|---|---|
committer | lightqwant <lightqwant@yandex-team.com> | 2022-09-01 20:05:05 +0300 |
commit | 7cfd122cb661b485fb0fb4139573a0beac97ae48 (patch) | |
tree | 5f205aaa2d0cdbc28370858218ff766fff8646a5 /library/cpp/getopt/ut/last_getopt_ut.cpp | |
parent | c1f7f3324e630e845df52ba0d4ac0a7e0e7f0f9d (diff) | |
download | ydb-7cfd122cb661b485fb0fb4139573a0beac97ae48.tar.gz |
[getopt] Add typo check for long options
Diffstat (limited to 'library/cpp/getopt/ut/last_getopt_ut.cpp')
-rw-r--r-- | library/cpp/getopt/ut/last_getopt_ut.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index 6606000ca6..c2ee4f0c40 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -825,4 +825,29 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { UNIT_ASSERT_VALUES_EQUAL(25, number); UNIT_ASSERT_VALUES_EQUAL(2, r.GetFreeArgCount()); } + + Y_UNIT_TEST(TestCheckUserTypos) { + { + TOptsNoDefault opts; + opts.SetCheckUserTypos(); + opts.AddLongOption("from"); + opts.AddLongOption("to"); + + UNIT_ASSERT_EXCEPTION( + TOptsParseResultTestWrapper(&opts, V({"copy", "-from", "/home", "--to=/etc"})), + TUsageException); + UNIT_ASSERT_NO_EXCEPTION( + TOptsParseResultTestWrapper(&opts, V({"copy", "--from", "from", "--to=/etc"}))); + } + + { + TOptsNoDefault opts; + opts.SetCheckUserTypos(); + opts.AddLongOption('f', "file", ""); + opts.AddLongOption('r', "read", ""); + opts.AddLongOption("fr"); + UNIT_ASSERT_NO_EXCEPTION( + TOptsParseResultTestWrapper(&opts, V({"copy", "-fr"}))); + } + } } |