aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/ut
diff options
context:
space:
mode:
authoramatanhead <amatanhead@yandex-team.ru>2022-02-10 16:50:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:04 +0300
commitb6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/getopt/ut
parent8879605a63ac17539be5b3bd41b529791f4d4b02 (diff)
downloadydb-b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9.tar.gz
Restoring authorship annotation for <amatanhead@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/ut')
-rw-r--r--library/cpp/getopt/ut/last_getopt_ut.cpp18
-rw-r--r--library/cpp/getopt/ut/wrap.cpp188
-rw-r--r--library/cpp/getopt/ut/ya.make2
3 files changed, 104 insertions, 104 deletions
diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp
index 9d2a46a51d..c99a1d053d 100644
--- a/library/cpp/getopt/ut/last_getopt_ut.cpp
+++ b/library/cpp/getopt/ut/last_getopt_ut.cpp
@@ -612,9 +612,9 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
opts.AddCharOption('d').DefaultValue("42");
opts.AddCharOption('s').DefaultValue("str_default");
opts.SetFreeArgsNum(123, 456);
- opts.SetFreeArgTitle(0, "first_free_arg", "help");
- opts.SetFreeArgTitle(2, "second_free_arg");
- opts.AddSection("Section", "Section\n text");
+ opts.SetFreeArgTitle(0, "first_free_arg", "help");
+ opts.SetFreeArgTitle(2, "second_free_arg");
+ opts.AddSection("Section", "Section\n text");
const char* cmd[] = {prog};
TOptsParser parser(&opts, Y_ARRAY_SIZE(cmd), cmd);
TStringStream out;
@@ -636,8 +636,8 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
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);
+ // 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);
@@ -645,10 +645,10 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) {
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);
- UNIT_ASSERT(out.Str().find(TStringBuilder() << " Section\n text") != TString::npos);
-
+ // find sections
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << colors.BoldColor() << "Section" << colors.OldColor() << ":") != TString::npos);
+ UNIT_ASSERT(out.Str().find(TStringBuilder() << " Section\n text") != TString::npos);
+
// print without colors
TStringStream out2;
opts.PrintUsage(prog, out2);
diff --git a/library/cpp/getopt/ut/wrap.cpp b/library/cpp/getopt/ut/wrap.cpp
index 2d78a8ba4d..3444eea102 100644
--- a/library/cpp/getopt/ut/wrap.cpp
+++ b/library/cpp/getopt/ut/wrap.cpp
@@ -1,96 +1,96 @@
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <library/cpp/getopt/small/wrap.h>
-
-Y_UNIT_TEST_SUITE(Wrap) {
- Y_UNIT_TEST(TestWrapping) {
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b c d eeffeff").Quote(),
- TString("a b c\nd\neeffeff").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\nc d\neeffeff").Quote(),
- TString("a b\nc d\neeffeff").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\n c d\neeffeff").Quote(),
- TString("a b\n c\nd\neeffeff").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\nx c d\neeffeff").Quote(),
- TString("a b\nx\nc d\neeffeff").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\nx \n c d\neeffeff").Quote(),
- TString("a b\nx\n c\nd\neeffeff").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\nx \n c d\neeffeff").Quote(),
- TString("a b\nx\n c\nd\neeffeff").Quote()
- );
- }
-
- Y_UNIT_TEST(TestWrappingIndent) {
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b c d", "|>").Quote(),
- TString("a b\n|>c d").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b\n\nc d", "|>").Quote(),
- TString("a b\n|>\n|>c d").Quote()
- );
- }
-
- Y_UNIT_TEST(TestWrappingAnsi) {
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5m").Quote(),
- TString("\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5m").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a \033[1;2;3;4;5mb c\033[1;2;3;4;5m \033[1;2;3;4;5md e f").Quote(),
- TString("a \033[1;2;3;4;5mb c\033[1;2;3;4;5m\n\033[1;2;3;4;5md e f").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b \033[1;2;3;4;5m c d").Quote(),
- TString("a b \033[1;2;3;4;5m\nc d").Quote()
- );
-
- UNIT_ASSERT_STRINGS_EQUAL(
- NLastGetopt::Wrap(5, "a b \033[1;2;3;4;5m c d").Quote(),
- TString("a b\n\033[1;2;3;4;5m c d").Quote()
- );
- }
-
- Y_UNIT_TEST(TestTextInfo) {
- size_t lastLineLen;
- bool hasParagraphs;
-
- NLastGetopt::Wrap(5, "a b c d e", "", &lastLineLen, &hasParagraphs);
- UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 3);
- UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, false);
-
- NLastGetopt::Wrap(5, "a b c\n\nd e f h", "", &lastLineLen, &hasParagraphs);
- UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 1);
- UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
-
- NLastGetopt::Wrap(5, "a b c\n\n", "", &lastLineLen, &hasParagraphs);
- UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 0);
- UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
-
- NLastGetopt::Wrap(5, "\n \na b c", "", &lastLineLen, &hasParagraphs);
- UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 5);
- UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
-
- NLastGetopt::Wrap(5, "\nx\na b c", "", &lastLineLen, &hasParagraphs);
- UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 5);
- UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, false);
- }
-}
+
+Y_UNIT_TEST_SUITE(Wrap) {
+ Y_UNIT_TEST(TestWrapping) {
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b c d eeffeff").Quote(),
+ TString("a b c\nd\neeffeff").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\nc d\neeffeff").Quote(),
+ TString("a b\nc d\neeffeff").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\n c d\neeffeff").Quote(),
+ TString("a b\n c\nd\neeffeff").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\nx c d\neeffeff").Quote(),
+ TString("a b\nx\nc d\neeffeff").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\nx \n c d\neeffeff").Quote(),
+ TString("a b\nx\n c\nd\neeffeff").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\nx \n c d\neeffeff").Quote(),
+ TString("a b\nx\n c\nd\neeffeff").Quote()
+ );
+ }
+
+ Y_UNIT_TEST(TestWrappingIndent) {
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b c d", "|>").Quote(),
+ TString("a b\n|>c d").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b\n\nc d", "|>").Quote(),
+ TString("a b\n|>\n|>c d").Quote()
+ );
+ }
+
+ Y_UNIT_TEST(TestWrappingAnsi) {
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5m").Quote(),
+ TString("\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5mx\033[1;2;3;4;5m").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a \033[1;2;3;4;5mb c\033[1;2;3;4;5m \033[1;2;3;4;5md e f").Quote(),
+ TString("a \033[1;2;3;4;5mb c\033[1;2;3;4;5m\n\033[1;2;3;4;5md e f").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b \033[1;2;3;4;5m c d").Quote(),
+ TString("a b \033[1;2;3;4;5m\nc d").Quote()
+ );
+
+ UNIT_ASSERT_STRINGS_EQUAL(
+ NLastGetopt::Wrap(5, "a b \033[1;2;3;4;5m c d").Quote(),
+ TString("a b\n\033[1;2;3;4;5m c d").Quote()
+ );
+ }
+
+ Y_UNIT_TEST(TestTextInfo) {
+ size_t lastLineLen;
+ bool hasParagraphs;
+
+ NLastGetopt::Wrap(5, "a b c d e", "", &lastLineLen, &hasParagraphs);
+ UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 3);
+ UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, false);
+
+ NLastGetopt::Wrap(5, "a b c\n\nd e f h", "", &lastLineLen, &hasParagraphs);
+ UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 1);
+ UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
+
+ NLastGetopt::Wrap(5, "a b c\n\n", "", &lastLineLen, &hasParagraphs);
+ UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 0);
+ UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
+
+ NLastGetopt::Wrap(5, "\n \na b c", "", &lastLineLen, &hasParagraphs);
+ UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 5);
+ UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, true);
+
+ NLastGetopt::Wrap(5, "\nx\na b c", "", &lastLineLen, &hasParagraphs);
+ UNIT_ASSERT_VALUES_EQUAL(lastLineLen, 5);
+ UNIT_ASSERT_VALUES_EQUAL(hasParagraphs, false);
+ }
+}
diff --git a/library/cpp/getopt/ut/ya.make b/library/cpp/getopt/ut/ya.make
index c2e928b6f0..8d00669efb 100644
--- a/library/cpp/getopt/ut/ya.make
+++ b/library/cpp/getopt/ut/ya.make
@@ -8,7 +8,7 @@ SRCS(
opt2_ut.cpp
opt_ut.cpp
posix_getopt_ut.cpp
- wrap.cpp
+ wrap.cpp
ygetopt_ut.cpp
)