aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/ut
diff options
context:
space:
mode:
authorVlad Yaroslavlev <vladon@vladon.com>2022-02-10 16:46:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:25 +0300
commit344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/getopt/ut
parent706b83ed7de5a473436620367af31fc0ceecde07 (diff)
downloadydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/ut')
-rw-r--r--library/cpp/getopt/ut/last_getopt_ut.cpp92
-rw-r--r--library/cpp/getopt/ut/opt_ut.cpp4
-rw-r--r--library/cpp/getopt/ut/posix_getopt_ut.cpp4
-rw-r--r--library/cpp/getopt/ut/ygetopt_ut.cpp4
4 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp
index d35a493021..c99a1d053d 100644
--- a/library/cpp/getopt/ut/last_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/last_getopt_ut.cpp
@@ -19,22 +19,22 @@ namespace {
};
class TOptsParseResultTestWrapper: public TOptsParseResultException {
- TVector<const char*> Argv_;
+ TVector<const char*> Argv_;
public:
- TOptsParseResultTestWrapper(const TOpts* opts, TVector<const char*> argv)
+ TOptsParseResultTestWrapper(const TOpts* opts, TVector<const char*> argv)
: Argv_(argv)
{
Init(opts, (int)Argv_.size(), Argv_.data());
}
};
- using V = TVector<const char*>;
+ using V = TVector<const char*>;
}
struct TOptsParserTester {
TOptsNoDefault Opts_;
- TVector<const char*> Argv_;
+ TVector<const char*> Argv_;
THolder<TOptsParser> Parser_;
@@ -58,13 +58,13 @@ struct TOptsParserTester {
UNIT_ASSERT(Parser_->CurOpt()->CharIs(c));
}
- void AcceptOption(const TString& optName) {
+ void AcceptOption(const TString& optName) {
AcceptOption();
UNIT_ASSERT(Parser_->CurOpt()->NameIs(optName));
}
template <typename TOpt>
- void AcceptOptionWithValue(TOpt optName, const TString& value) {
+ void AcceptOptionWithValue(TOpt optName, const TString& value) {
AcceptOption(optName);
UNIT_ASSERT_VALUES_EQUAL_C(value, Parser_->CurValStr(), "; option " << optName);
}
@@ -75,7 +75,7 @@ struct TOptsParserTester {
UNIT_ASSERT_C(!Parser_->CurVal(), ": opt " << optName << " must have no param");
}
- void AcceptFreeArgInOrder(const TString& expected) {
+ void AcceptFreeArgInOrder(const TString& expected) {
Accept();
UNIT_ASSERT(!Parser_->CurOpt());
UNIT_ASSERT_VALUES_EQUAL(expected, Parser_->CurValStr());
@@ -114,7 +114,7 @@ struct TOptsParserTester {
UNIT_ASSERT_VALUES_EQUAL(sop, Parser_->Sop_);
}
- void AcceptFreeArg(const TString& expected) {
+ void AcceptFreeArg(const TString& expected) {
UNIT_ASSERT(Pos_ < Parser_->Argc_);
UNIT_ASSERT_VALUES_EQUAL(expected, Parser_->Argv_[Pos_]);
++Pos_;
@@ -417,7 +417,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
Y_UNIT_TEST(TestStoreResult) {
TOptsNoDefault opts;
- TString data;
+ TString data;
int number;
TMaybe<TString> optionalString0, optionalString1;
TMaybe<int> optionalNumber0, optionalNumber1;
@@ -483,10 +483,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
Y_UNIT_TEST(TestSplitValue) {
TOptsNoDefault opts;
- TVector<TString> vals;
+ TVector<TString> vals;
opts.AddLongOption('s', "split").SplitHandler(&vals, ',');
TOptsParseResultTestWrapper r(&opts, V({"prog", "--split=a,b,c"}));
- UNIT_ASSERT_EQUAL(vals.size(), 3);
+ UNIT_ASSERT_EQUAL(vals.size(), 3);
UNIT_ASSERT_EQUAL(vals[0], "a");
UNIT_ASSERT_EQUAL(vals[1], "b");
UNIT_ASSERT_EQUAL(vals[2], "c");
@@ -494,10 +494,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
Y_UNIT_TEST(TestRangeSplitValue) {
TOptsNoDefault opts;
- TVector<ui32> vals;
+ TVector<ui32> vals;
opts.AddLongOption('s', "split").RangeSplitHandler(&vals, ',', '-');
TOptsParseResultTestWrapper r(&opts, V({"prog", "--split=1,8-10", "--split=12-14"}));
- UNIT_ASSERT_EQUAL(vals.size(), 7);
+ UNIT_ASSERT_EQUAL(vals.size(), 7);
UNIT_ASSERT_EQUAL(vals[0], 1);
UNIT_ASSERT_EQUAL(vals[1], 8);
UNIT_ASSERT_EQUAL(vals[2], 9);
@@ -577,7 +577,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
Y_UNIT_TEST(TestTitleAndPrintUsage) {
TOpts opts;
const char* prog = "my_program";
- TString title = TString("Sample ") + TString(prog).Quote() + " application";
+ TString title = TString("Sample ") + TString(prog).Quote() + " application";
opts.SetTitle(title);
int argc = 2;
const char* cmd[] = {prog};
@@ -585,15 +585,15 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
TStringStream out;
parser.PrintUsage(out);
// find title
- UNIT_ASSERT(out.Str().find(title) != TString::npos);
+ UNIT_ASSERT(out.Str().find(title) != TString::npos);
// find usage
- UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos);
+ UNIT_ASSERT(out.Str().find(" " + TString(prog) + " ") != TString::npos);
}
Y_UNIT_TEST(TestCustomCmdLineDescr) {
TOpts opts;
const char* prog = "my_program";
- TString customDescr = "<FILE|TABLE> USER [OPTIONS]";
+ TString customDescr = "<FILE|TABLE> USER [OPTIONS]";
int argc = 2;
const char* cmd[] = {prog};
opts.SetCmdLineDescr(customDescr);
@@ -601,7 +601,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
TStringStream out;
parser.PrintUsage(out);
// find custom usage
- UNIT_ASSERT(out.Str().find(customDescr) != TString::npos);
+ UNIT_ASSERT(out.Str().find(customDescr) != TString::npos);
}
Y_UNIT_TEST(TestColorPrint) {
@@ -622,28 +622,28 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
parser.PrintUsage(out, colors);
// find options and green color
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--long_option" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--other" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-o" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-d" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-s" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--long_option" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "--other" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-o" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-d" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "-s" << colors.OldColor()) != TString::npos);
// find default values
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "42" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "\"str_default\"" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "42" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.CyanColor() << "\"str_default\"" << colors.OldColor()) != TString::npos);
// find free args
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "123" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "456" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "first_free_arg" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "123" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "456" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "first_free_arg" << colors.OldColor()) != TString::npos);
// free args without help not rendered even if they have custom title
UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.GreenColor() << "second_free_arg" << colors.OldColor()) == TString::npos);
// find signatures
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Usage" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Required parameters" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Optional parameters" << colors.OldColor()) != TString::npos);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Free args" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Usage" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Required parameters" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Optional parameters" << colors.OldColor()) != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Free args" << colors.OldColor()) != TString::npos);
// find sections
UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Section" << colors.OldColor() << ":") != TString::npos);
@@ -652,10 +652,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
// print without colors
TStringStream out2;
opts.PrintUsage(prog, out2);
- UNIT_ASSERT(out2.Str().find(colors.GreenColor()) == TString::npos);
- UNIT_ASSERT(out2.Str().find(colors.CyanColor()) == TString::npos);
- UNIT_ASSERT(out2.Str().find(colors.BoldColor()) == TString::npos);
- UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos);
+ UNIT_ASSERT(out2.Str().find(colors.GreenColor()) == TString::npos);
+ UNIT_ASSERT(out2.Str().find(colors.CyanColor()) == TString::npos);
+ UNIT_ASSERT(out2.Str().find(colors.BoldColor()) == TString::npos);
+ UNIT_ASSERT(out2.Str().find(colors.OldColor()) == TString::npos);
}
Y_UNIT_TEST(TestPadding) {
@@ -675,21 +675,21 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
NColorizer::TColors colors(withColors);
parser.PrintUsage(out, colors);
- TString printed = out.Str();
+ TString printed = out.Str();
if (withColors) {
// remove not printable characters
- SubstGlobal(printed, TString(colors.BoldColor()), "");
- SubstGlobal(printed, TString(colors.GreenColor()), "");
- SubstGlobal(printed, TString(colors.CyanColor()), "");
- SubstGlobal(printed, TString(colors.OldColor()), "");
+ SubstGlobal(printed, TString(colors.BoldColor()), "");
+ SubstGlobal(printed, TString(colors.GreenColor()), "");
+ SubstGlobal(printed, TString(colors.CyanColor()), "");
+ SubstGlobal(printed, TString(colors.OldColor()), "");
}
- TVector<TString> lines;
+ TVector<TString> lines;
StringSplitter(printed).Split('\n').SkipEmpty().Collect(&lines);
UNIT_ASSERT(!lines.empty());
- TVector<size_t> indents;
- for (const TString& line : lines) {
+ TVector<size_t> indents;
+ for (const TString& line : lines) {
const size_t indent = line.find("description ");
- if (indent != TString::npos)
+ if (indent != TString::npos)
indents.push_back(indent);
}
UNIT_ASSERT_VALUES_EQUAL(indents.size(), 7);
@@ -701,7 +701,7 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
}
Y_UNIT_TEST(TestAppendTo) {
- TVector<int> ints;
+ TVector<int> ints;
TOptsNoDefault opts;
opts.AddLongOption("size").AppendTo(&ints);
diff --git a/library/cpp/getopt/ut/opt_ut.cpp b/library/cpp/getopt/ut/opt_ut.cpp
index aad842a46e..441aa493a0 100644
--- a/library/cpp/getopt/ut/opt_ut.cpp
+++ b/library/cpp/getopt/ut/opt_ut.cpp
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(OptTest) {
int argc = 5;
Opt opts(argc, argv, "", options);
- UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3");
+ UNIT_ASSERT_VALUES_EQUAL(JoinStrings(opts.GetFreeArgs(), ", "), "ARG1, ARG3");
}
Y_UNIT_TEST(TestLongOption) {
@@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(OptTest) {
int argc = 5;
Opt opts(argc, argv, "", options);
- TString optionValue = "";
+ TString optionValue = "";
int optlet = 0;
while ((optlet = opts.Get()) != EOF) {
if (optlet == SOME_OPTION_ID) {
diff --git a/library/cpp/getopt/ut/posix_getopt_ut.cpp b/library/cpp/getopt/ut/posix_getopt_ut.cpp
index 7a9dbf6c5c..b6d374bf28 100644
--- a/library/cpp/getopt/ut/posix_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/posix_getopt_ut.cpp
@@ -13,9 +13,9 @@ Y_UNIT_TEST_SUITE(TPosixGetoptTest) {
NLastGetopt::optreset = 1;
UNIT_ASSERT_VALUES_EQUAL('b', NLastGetopt::getopt(argc, argv, "bf:"));
UNIT_ASSERT_VALUES_EQUAL('f', NLastGetopt::getopt(argc, argv, "bf:"));
- UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("1"));
+ UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("1"));
UNIT_ASSERT_VALUES_EQUAL('f', NLastGetopt::getopt(argc, argv, "bf:"));
- UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("2"));
+ UNIT_ASSERT_VALUES_EQUAL(NLastGetopt::optarg, TString("2"));
UNIT_ASSERT_VALUES_EQUAL(-1, NLastGetopt::getopt(argc, argv, "bf:"));
UNIT_ASSERT_VALUES_EQUAL(5, NLastGetopt::optind);
diff --git a/library/cpp/getopt/ut/ygetopt_ut.cpp b/library/cpp/getopt/ut/ygetopt_ut.cpp
index 29cfb0e8e3..a76f117216 100644
--- a/library/cpp/getopt/ut/ygetopt_ut.cpp
+++ b/library/cpp/getopt/ut/ygetopt_ut.cpp
@@ -29,8 +29,8 @@ void TGetOptTest::TestGetOpt() {
"-q",
nullptr};
- TString res;
- const TString format = "qzp:f";
+ TString res;
+ const TString format = "qzp:f";
TGetOpt opt(sizeof(argv) / sizeof(*argv) - 1, argv, format);
for (TGetOpt::TIterator it = opt.Begin(); it != opt.End(); ++it) {