aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/ut/posix_getopt_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/getopt/ut/posix_getopt_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/getopt/ut/posix_getopt_ut.cpp')
-rw-r--r--library/cpp/getopt/ut/posix_getopt_ut.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/getopt/ut/posix_getopt_ut.cpp b/library/cpp/getopt/ut/posix_getopt_ut.cpp
index b6d374bf28..549a5ae3a2 100644
--- a/library/cpp/getopt/ut/posix_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/posix_getopt_ut.cpp
@@ -1,5 +1,5 @@
#include <library/cpp/getopt/posix_getopt.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
using namespace NLastGetopt;
@@ -7,8 +7,8 @@ using namespace NLastGetopt;
Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
Y_UNIT_TEST(TestSimple) {
int argc = 6;
- const char* argv0[] = {"program", "-b", "-f1", "-f", "2", "zzzz"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "-b", "-f1", "-f", "2", "zzzz"};
+ char** const argv = (char**)argv0;
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('b', NLastGetopt::getopt(argc, argv, "bf:"));
@@ -25,14 +25,14 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
int daggerset = 0;
/* options descriptor */
const NLastGetopt::option longopts[] = {
- {"buffy", no_argument, nullptr, 'b'},
- {"fluoride", required_argument, nullptr, 'f'},
- {"daggerset", no_argument, &daggerset, 1},
- {nullptr, 0, nullptr, 0}};
+ {"buffy", no_argument, nullptr, 'b'},
+ {"fluoride", required_argument, nullptr, 'f'},
+ {"daggerset", no_argument, &daggerset, 1},
+ {nullptr, 0, nullptr, 0}};
int argc = 7;
- const char* argv0[] = {"program", "-b", "--buffy", "-f1", "--fluoride=2", "--daggerset", "zzzz"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "-b", "--buffy", "-f1", "--fluoride=2", "--daggerset", "zzzz"};
+ char** const argv = (char**)argv0;
int longIndex;
@@ -53,14 +53,14 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
int daggerset = 0;
/* options descriptor */
const NLastGetopt::option longopts[] = {
- {"buffy", no_argument, nullptr, 'b'},
- {"fluoride", required_argument, nullptr, 'f'},
- {"daggerset", no_argument, &daggerset, 1},
- {nullptr, 0, nullptr, 0}};
+ {"buffy", no_argument, nullptr, 'b'},
+ {"fluoride", required_argument, nullptr, 'f'},
+ {"daggerset", no_argument, &daggerset, 1},
+ {nullptr, 0, nullptr, 0}};
int argc = 7;
- const char* argv0[] = {"program", "aa", "-b", "bb", "cc", "--buffy", "dd"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "aa", "-b", "bb", "cc", "--buffy", "dd"};
+ char** const argv = (char**)argv0;
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('b', NLastGetopt::getopt_long(argc, argv, "bf:", longopts, nullptr));
@@ -72,13 +72,13 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
Y_UNIT_TEST(TestNoOptionsOptionsWithDoubleDash) {
const NLastGetopt::option longopts[] = {
- {"buffy", no_argument, nullptr, 'b'},
- {"fluoride", no_argument, nullptr, 'f'},
- {nullptr, 0, nullptr, 0}};
+ {"buffy", no_argument, nullptr, 'b'},
+ {"fluoride", no_argument, nullptr, 'f'},
+ {nullptr, 0, nullptr, 0}};
int argc = 2;
- const char* argv0[] = {"program", "--bf"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "--bf"};
+ char** const argv = (char**)argv0;
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('?', NLastGetopt::getopt_long(argc, argv, "bf", longopts, nullptr));
@@ -86,32 +86,32 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
Y_UNIT_TEST(TestLongOnly) {
const NLastGetopt::option longopts[] = {
- {"foo", no_argument, nullptr, 'F'},
- {"fluoride", no_argument, nullptr, 'f'},
- {"ogogo", no_argument, nullptr, 'o'},
- {nullptr, 0, nullptr, 0}};
+ {"foo", no_argument, nullptr, 'F'},
+ {"fluoride", no_argument, nullptr, 'f'},
+ {"ogogo", no_argument, nullptr, 'o'},
+ {nullptr, 0, nullptr, 0}};
int argc = 4;
- const char* argv0[] = {"program", "--foo", "-foo", "-fo"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "--foo", "-foo", "-fo"};
+ char** const argv = (char**)argv0;
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('F', NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
UNIT_ASSERT_VALUES_EQUAL('F', NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
UNIT_ASSERT_VALUES_EQUAL('f', NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
UNIT_ASSERT_VALUES_EQUAL('o', NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
- UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
+ UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt_long_only(argc, argv, "fo", longopts, nullptr));
}
Y_UNIT_TEST(TestLongWithoutOnlySingleDashNowAllowed) {
const NLastGetopt::option longopts[] = {
- {"foo", no_argument, nullptr, 'F'},
- {"zoo", no_argument, nullptr, 'z'},
- {nullptr, 0, nullptr, 0}};
+ {"foo", no_argument, nullptr, 'F'},
+ {"zoo", no_argument, nullptr, 'z'},
+ {nullptr, 0, nullptr, 0}};
int argc = 2;
- const char* argv0[] = {"program", "-foo"};
- char** const argv = (char**)argv0;
+ const char* argv0[] = {"program", "-foo"};
+ char** const argv = (char**)argv0;
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('?', NLastGetopt::getopt_long(argc, argv, "z", longopts, nullptr));