diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/yson_pull/ut/cescape_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yson_pull/ut/cescape_ut.cpp')
-rw-r--r-- | library/cpp/yson_pull/ut/cescape_ut.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/library/cpp/yson_pull/ut/cescape_ut.cpp b/library/cpp/yson_pull/ut/cescape_ut.cpp index a1bb07d2fe..6628ba1d15 100644 --- a/library/cpp/yson_pull/ut/cescape_ut.cpp +++ b/library/cpp/yson_pull/ut/cescape_ut.cpp @@ -6,66 +6,66 @@ using namespace NYsonPull::NDetail; namespace { void test_roundtrip(const TVector<ui8>& str) { - TStringBuf str_buf( - reinterpret_cast<const char*>(str.data()), - str.size()); - auto tmp = NCEscape::encode(str_buf); - auto dest = NCEscape::decode(tmp); - UNIT_ASSERT_VALUES_EQUAL_C( - str_buf, TStringBuf(dest), - "A[" << str.size() << "]: " << str_buf << '\n' - << "B[" << tmp.size() << "]: " << tmp << '\n' - << "C[" << dest.size() << "]: " << dest); - } + TStringBuf str_buf( + reinterpret_cast<const char*>(str.data()), + str.size()); + auto tmp = NCEscape::encode(str_buf); + auto dest = NCEscape::decode(tmp); + UNIT_ASSERT_VALUES_EQUAL_C( + str_buf, TStringBuf(dest), + "A[" << str.size() << "]: " << str_buf << '\n' + << "B[" << tmp.size() << "]: " << tmp << '\n' + << "C[" << dest.size() << "]: " << dest); + } - template <size_t N> + template <size_t N> void test_exhaustive(TVector<ui8>& str) { - for (int i = 0; i < 256; ++i) { - str[str.size() - N] = static_cast<char>(i); - test_exhaustive<N - 1>(str); - } - } + for (int i = 0; i < 256; ++i) { + str[str.size() - N] = static_cast<char>(i); + test_exhaustive<N - 1>(str); + } + } - template <> + template <> void test_exhaustive<0>(TVector<ui8>& str) { - test_roundtrip(str); + test_roundtrip(str); } - template <size_t N> - void test_exhaustive() { + template <size_t N> + void test_exhaustive() { TVector<ui8> str(N, ' '); - test_exhaustive<N>(str); - } + test_exhaustive<N>(str); + } } // anonymous namespace Y_UNIT_TEST_SUITE(CEscape) { Y_UNIT_TEST(ExhaustiveOneChar) { - test_exhaustive<1>(); - } + test_exhaustive<1>(); + } Y_UNIT_TEST(ExhaustiveTwoChars) { - test_exhaustive<2>(); - } + test_exhaustive<2>(); + } Y_UNIT_TEST(ExhaustiveThreeChars) { - test_exhaustive<3>(); - } + test_exhaustive<3>(); + } Y_UNIT_TEST(SpecialEscapeEncode) { - //UNIT_ASSERT_VALUES_EQUAL(R"(\b)", NCEscape::encode("\b")); - //UNIT_ASSERT_VALUES_EQUAL(R"(\f)", NCEscape::encode("\f")); - UNIT_ASSERT_VALUES_EQUAL(R"(\n)", NCEscape::encode("\n")); - UNIT_ASSERT_VALUES_EQUAL(R"(\r)", NCEscape::encode("\r")); - UNIT_ASSERT_VALUES_EQUAL(R"(\t)", NCEscape::encode("\t")); - } + //UNIT_ASSERT_VALUES_EQUAL(R"(\b)", NCEscape::encode("\b")); + //UNIT_ASSERT_VALUES_EQUAL(R"(\f)", NCEscape::encode("\f")); + UNIT_ASSERT_VALUES_EQUAL(R"(\n)", NCEscape::encode("\n")); + UNIT_ASSERT_VALUES_EQUAL(R"(\r)", NCEscape::encode("\r")); + UNIT_ASSERT_VALUES_EQUAL(R"(\t)", NCEscape::encode("\t")); + } Y_UNIT_TEST(SpecialEscapeDecode) { - UNIT_ASSERT_VALUES_EQUAL("\b", NCEscape::decode(R"(\b)")); - UNIT_ASSERT_VALUES_EQUAL("\f", NCEscape::decode(R"(\f)")); - UNIT_ASSERT_VALUES_EQUAL("\n", NCEscape::decode(R"(\n)")); - UNIT_ASSERT_VALUES_EQUAL("\r", NCEscape::decode(R"(\r)")); - UNIT_ASSERT_VALUES_EQUAL("\t", NCEscape::decode(R"(\t)")); - } + UNIT_ASSERT_VALUES_EQUAL("\b", NCEscape::decode(R"(\b)")); + UNIT_ASSERT_VALUES_EQUAL("\f", NCEscape::decode(R"(\f)")); + UNIT_ASSERT_VALUES_EQUAL("\n", NCEscape::decode(R"(\n)")); + UNIT_ASSERT_VALUES_EQUAL("\r", NCEscape::decode(R"(\r)")); + UNIT_ASSERT_VALUES_EQUAL("\t", NCEscape::decode(R"(\t)")); + } } // Y_UNIT_TEST_SUITE(CEscape) |