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 | 82e516236e5bba43ff4dcd0e4ddf8fb30b3624d5 (patch) | |
tree | e6a11d2715ea09a3c45cf6b4bd80c1b908cc9dd1 | |
parent | bfa8c3e83c12beb065db3c294bcad58628069502 (diff) | |
download | ydb-82e516236e5bba43ff4dcd0e4ddf8fb30b3624d5.tar.gz |
Restoring authorship annotation for <smurylev@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/protobuf/json/config.h | 14 | ||||
-rw-r--r-- | library/cpp/protobuf/json/json_writer_output.cpp | 2 | ||||
-rw-r--r-- | library/cpp/protobuf/json/string_transform.cpp | 18 | ||||
-rw-r--r-- | library/cpp/protobuf/json/string_transform.h | 2 | ||||
-rw-r--r-- | library/cpp/protobuf/json/ut/string_transform_ut.cpp | 158 | ||||
-rw-r--r-- | library/cpp/protobuf/json/ut/ya.make | 2 | ||||
-rw-r--r-- | library/python/ya.make | 4 | ||||
-rw-r--r-- | util/charset/wide_ut.cpp | 50 | ||||
-rw-r--r-- | util/digest/fnv.pxd | 4 |
9 files changed, 127 insertions, 127 deletions
diff --git a/library/cpp/protobuf/json/config.h b/library/cpp/protobuf/json/config.h index dc84fb4d5d..fcfd500daa 100644 --- a/library/cpp/protobuf/json/config.h +++ b/library/cpp/protobuf/json/config.h @@ -86,8 +86,8 @@ namespace NProtobufJson { /// Custom enum values generator. TEnumValueGenerator EnumValueGenerator = {}; - bool WriteNanAsString = false; - + bool WriteNanAsString = false; + TSelf& SetFormatOutput(bool format) { FormatOutput = format; return *this; @@ -154,11 +154,11 @@ namespace NProtobufJson { EnumValueGenerator = callback; return *this; } - - TSelf& SetWriteNanAsString(bool value) { - WriteNanAsString = value; - return *this; - } + + TSelf& SetWriteNanAsString(bool value) { + WriteNanAsString = value; + return *this; + } }; } diff --git a/library/cpp/protobuf/json/json_writer_output.cpp b/library/cpp/protobuf/json/json_writer_output.cpp index 288f645bab..57c06ba736 100644 --- a/library/cpp/protobuf/json/json_writer_output.cpp +++ b/library/cpp/protobuf/json/json_writer_output.cpp @@ -7,7 +7,7 @@ namespace NProtobufJson { jsonConfig.SortKeys = false; jsonConfig.ValidateUtf8 = false; jsonConfig.DontEscapeStrings = false; - jsonConfig.WriteNanAsString = config.WriteNanAsString; + jsonConfig.WriteNanAsString = config.WriteNanAsString; for (size_t i = 0; i < config.StringTransforms.size(); ++i) { Y_ASSERT(config.StringTransforms[i]); diff --git a/library/cpp/protobuf/json/string_transform.cpp b/library/cpp/protobuf/json/string_transform.cpp index 7c42daa677..bccbf28c1b 100644 --- a/library/cpp/protobuf/json/string_transform.cpp +++ b/library/cpp/protobuf/json/string_transform.cpp @@ -31,10 +31,10 @@ namespace NProtobufJson { if (str.empty()) { return str; } - + TString result; result.reserve(str.size()); - + char prev = str[0]; bool doneOutput = true; for (const char* it = str.c_str() + 1; *it; ++it) { @@ -46,14 +46,14 @@ namespace NProtobufJson { } prev = *it; } - + if ((doneOutput && prev != '\\') || !doneOutput) { - result += prev; - } - + result += prev; + } + return result; - } - + } + void TBase64EncodeBytesTransform::TransformBytes(TString &str) const { str = Base64Encode(str); } @@ -61,4 +61,4 @@ namespace NProtobufJson { void TBase64DecodeBytesTransform::TransformBytes(TString &str) const { str = Base64Decode(str); } -} +} diff --git a/library/cpp/protobuf/json/string_transform.h b/library/cpp/protobuf/json/string_transform.h index e4b296bc01..c27cd31d55 100644 --- a/library/cpp/protobuf/json/string_transform.h +++ b/library/cpp/protobuf/json/string_transform.h @@ -82,7 +82,7 @@ namespace NProtobufJson { private: TString Unescape(const TString& str) const; }; - + class TBase64EncodeBytesTransform: public NProtobufJson::IStringTransform { public: int GetType() const override { diff --git a/library/cpp/protobuf/json/ut/string_transform_ut.cpp b/library/cpp/protobuf/json/ut/string_transform_ut.cpp index a31dabcb0f..5b3b23ebdd 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); + } +} diff --git a/library/cpp/protobuf/json/ut/ya.make b/library/cpp/protobuf/json/ut/ya.make index b60a6d3c17..0ce60288f0 100644 --- a/library/cpp/protobuf/json/ut/ya.make +++ b/library/cpp/protobuf/json/ut/ya.make @@ -8,7 +8,7 @@ SRCS( proto2json_ut.cpp inline_ut.proto inline_ut.cpp - string_transform_ut.cpp + string_transform_ut.cpp filter_ut.proto test.proto util_ut.cpp diff --git a/library/python/ya.make b/library/python/ya.make index 2e1eb6e0e1..f097054a17 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -75,8 +75,8 @@ RECURSE( find_root flask flask_passport - fnvhash - fnvhash/test + fnvhash + fnvhash/test framing framing/ut func diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index d8f3233e73..8924fcf615 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -177,7 +177,7 @@ private: UNIT_TEST(TestSubstrUTF8); UNIT_TEST(TestUnicodeCase); UNIT_TEST(TestUnicodeDetails); - UNIT_TEST(TestHexConversion); + UNIT_TEST(TestHexConversion); UNIT_TEST_SUITE_END(); public: @@ -196,34 +196,34 @@ public: void TestSubstrUTF8(); void TestUnicodeCase(); void TestUnicodeDetails(); - void TestHexConversion(); + void TestHexConversion(); }; UNIT_TEST_SUITE_REGISTRATION(TConversionTest); -void TConversionTest::TestHexConversion() { - for (char ch = '0'; ch <= '9'; ++ch) { - UNIT_ASSERT(isxdigit(ch)); - UNIT_ASSERT(IsHexdigit(ch)); - } - - for (char ch = 'a'; ch <= 'f'; ++ch) { - UNIT_ASSERT(isxdigit(ch)); - UNIT_ASSERT(IsHexdigit(ch)); - } - - for (char ch = 'A'; ch <= 'F'; ++ch) { - UNIT_ASSERT(isxdigit(ch)); - UNIT_ASSERT(IsHexdigit(ch)); - } - - for (wchar16 i = std::numeric_limits<wchar16>::min(); i < std::numeric_limits<wchar16>::max(); ++i) { - if (IsHexdigit(i)) { - UNIT_ASSERT(isxdigit(char(i))); - } - } -} - +void TConversionTest::TestHexConversion() { + for (char ch = '0'; ch <= '9'; ++ch) { + UNIT_ASSERT(isxdigit(ch)); + UNIT_ASSERT(IsHexdigit(ch)); + } + + for (char ch = 'a'; ch <= 'f'; ++ch) { + UNIT_ASSERT(isxdigit(ch)); + UNIT_ASSERT(IsHexdigit(ch)); + } + + for (char ch = 'A'; ch <= 'F'; ++ch) { + UNIT_ASSERT(isxdigit(ch)); + UNIT_ASSERT(IsHexdigit(ch)); + } + + for (wchar16 i = std::numeric_limits<wchar16>::min(); i < std::numeric_limits<wchar16>::max(); ++i) { + if (IsHexdigit(i)) { + UNIT_ASSERT(isxdigit(char(i))); + } + } +} + void TConversionTest::TestReadUTF8Char() { wchar32 e; // expected unicode char wchar32 c; diff --git a/util/digest/fnv.pxd b/util/digest/fnv.pxd index 92396cf4d3..7b099ab266 100644 --- a/util/digest/fnv.pxd +++ b/util/digest/fnv.pxd @@ -1,2 +1,2 @@ -cdef extern from "util/digest/fnv.h": - T FnvHash[T](const char* buf, size_t len) nogil +cdef extern from "util/digest/fnv.h": + T FnvHash[T](const char* buf, size_t len) nogil |