diff options
author | amatanhead <amatanhead@yandex-team.ru> | 2022-02-10 16:50:04 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:04 +0300 |
commit | b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/getopt/ut/wrap.cpp | |
parent | 8879605a63ac17539be5b3bd41b529791f4d4b02 (diff) | |
download | ydb-b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9.tar.gz |
Restoring authorship annotation for <amatanhead@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/getopt/ut/wrap.cpp')
-rw-r--r-- | library/cpp/getopt/ut/wrap.cpp | 188 |
1 files changed, 94 insertions, 94 deletions
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); + } +} |