diff options
author | smurylev <smurylev@yandex-team.ru> | 2022-02-10 16:50:34 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:34 +0300 |
commit | 90e044f3970467c14a384a4d261a5d55f4b29a66 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/protobuf/json/ut/string_transform_ut.cpp | |
parent | 82e516236e5bba43ff4dcd0e4ddf8fb30b3624d5 (diff) | |
download | ydb-90e044f3970467c14a384a4d261a5d55f4b29a66.tar.gz |
Restoring authorship annotation for <smurylev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/protobuf/json/ut/string_transform_ut.cpp')
-rw-r--r-- | library/cpp/protobuf/json/ut/string_transform_ut.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/library/cpp/protobuf/json/ut/string_transform_ut.cpp b/library/cpp/protobuf/json/ut/string_transform_ut.cpp index 5b3b23ebdd..a31dabcb0f 100644 --- a/library/cpp/protobuf/json/ut/string_transform_ut.cpp +++ b/library/cpp/protobuf/json/ut/string_transform_ut.cpp @@ -1,106 +1,106 @@ -#include "json.h" - +#include "json.h" + #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/protobuf/json/proto2json.h> - + Y_UNIT_TEST_SUITE(TDoubleEscapeTransform) { Y_UNIT_TEST(TestEmptyString) { - const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); + const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; - s = ""; - transform.Transform(s); - UNIT_ASSERT_EQUAL(s, ""); - } - + s = ""; + transform.Transform(s); + UNIT_ASSERT_EQUAL(s, ""); + } + Y_UNIT_TEST(TestAlphabeticString) { - const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); + const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; - s = "abacaba"; - transform.Transform(s); - UNIT_ASSERT_EQUAL(s, "abacaba"); - } - + s = "abacaba"; + transform.Transform(s); + UNIT_ASSERT_EQUAL(s, "abacaba"); + } + Y_UNIT_TEST(TestRussianSymbols) { - const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); + const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; - s = "тест"; - transform.Transform(s); - UNIT_ASSERT_EQUAL(s, "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"); - } - + s = "тест"; + transform.Transform(s); + UNIT_ASSERT_EQUAL(s, "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"); + } + Y_UNIT_TEST(TestEscapeSpecialSymbols) { - const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); + const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleEscapeTransform(); TString s; - s = "aba\\ca\"ba"; - transform.Transform(s); - Cerr << "###" << s << Endl; - UNIT_ASSERT_EQUAL(s, "aba\\\\\\\\ca\\\\\\\"ba"); - } -} - + s = "aba\\ca\"ba"; + transform.Transform(s); + Cerr << "###" << s << Endl; + UNIT_ASSERT_EQUAL(s, "aba\\\\\\\\ca\\\\\\\"ba"); + } +} + Y_UNIT_TEST_SUITE(TDoubleUnescapeTransform) { Y_UNIT_TEST(TestEmptyString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; - s = ""; - transform.Transform(s); - UNIT_ASSERT_EQUAL("", s); - } - + s = ""; + transform.Transform(s); + UNIT_ASSERT_EQUAL("", s); + } + Y_UNIT_TEST(TestAlphabeticString) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; - s = "abacaba"; - transform.Transform(s); - Cerr << "###" << s << Endl; - UNIT_ASSERT_EQUAL("abacaba", s); - } - + s = "abacaba"; + transform.Transform(s); + Cerr << "###" << s << Endl; + UNIT_ASSERT_EQUAL("abacaba", s); + } + Y_UNIT_TEST(TestRussianSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; - s = "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("тест", s); - } - + s = "\\\\321\\\\202\\\\320\\\\265\\\\321\\\\201\\\\321\\\\202"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("тест", s); + } + Y_UNIT_TEST(TestEscapeSpecialSymbols) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; - s = "aba\\\\\\\\ca\\\\\\\"ba"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("aba\\ca\"ba", s); - } - + s = "aba\\\\\\\\ca\\\\\\\"ba"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("aba\\ca\"ba", s); + } + Y_UNIT_TEST(TestEscapeSpecialSymbolsDifficultCases) { const NProtobufJson::IStringTransform& transform = NProtobufJson::TDoubleUnescapeTransform(); TString s; - s = "\\\\\\\\\\\\\\\\"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\\\\", s); - - s = "\\\\\\\\\\\\\\\""; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\\\"", s); - - s = "\\\\\\\"\\\\\\\\"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\"\\", s); - - s = "\\\\\\\"\\\\\\\""; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\"\"", s); - - s = "\\\\\\\\\\\\\\\\\\\\\\\\"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\\\\\\", s); - - s = "\\\\\\\\\\\\\\\\\\\\\\\\abacaba\\\\"; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\\\\\\abacaba", s); - - s = "\\\\\\\\\\\\\\\\\\\\\\\\abacaba\\\""; - transform.Transform(s); - UNIT_ASSERT_EQUAL("\\\\\\abacaba\"", s); - } -} + s = "\\\\\\\\\\\\\\\\"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\\\\", s); + + s = "\\\\\\\\\\\\\\\""; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\\\"", s); + + s = "\\\\\\\"\\\\\\\\"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\"\\", s); + + s = "\\\\\\\"\\\\\\\""; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\"\"", s); + + s = "\\\\\\\\\\\\\\\\\\\\\\\\"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\\\\\\", s); + + s = "\\\\\\\\\\\\\\\\\\\\\\\\abacaba\\\\"; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\\\\\\abacaba", s); + + s = "\\\\\\\\\\\\\\\\\\\\\\\\abacaba\\\""; + transform.Transform(s); + UNIT_ASSERT_EQUAL("\\\\\\abacaba\"", s); + } +} |