diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/protobuf/util | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/util')
-rw-r--r-- | library/cpp/protobuf/util/is_equal.cpp | 14 | ||||
-rw-r--r-- | library/cpp/protobuf/util/is_equal.h | 4 | ||||
-rw-r--r-- | library/cpp/protobuf/util/is_equal_ut.cpp | 54 | ||||
-rw-r--r-- | library/cpp/protobuf/util/repeated_field_utils.h | 26 | ||||
-rw-r--r-- | library/cpp/protobuf/util/ut/sample_for_is_equal.proto | 16 | ||||
-rw-r--r-- | library/cpp/protobuf/util/ut/ya.make | 16 | ||||
-rw-r--r-- | library/cpp/protobuf/util/ya.make | 2 |
7 files changed, 66 insertions, 66 deletions
diff --git a/library/cpp/protobuf/util/is_equal.cpp b/library/cpp/protobuf/util/is_equal.cpp index 227408006e..9a0e94b57e 100644 --- a/library/cpp/protobuf/util/is_equal.cpp +++ b/library/cpp/protobuf/util/is_equal.cpp @@ -4,8 +4,8 @@ #include <google/protobuf/descriptor.h> #include <util/generic/yexception.h> -#include <util/string/cast.h> -#include <util/string/vector.h> +#include <util/string/cast.h> +#include <util/string/vector.h> namespace NProtoBuf { template <bool useDefault> @@ -19,7 +19,7 @@ namespace NProtoBuf { return value1 == value2; } }; - + template <bool useDefault> struct TCompareValue<FieldDescriptor::CPPTYPE_MESSAGE, useDefault> { static inline bool IsEqual(const Message* value1, const Message* value2, TVector<TString>* differentPath) { @@ -113,7 +113,7 @@ namespace NProtoBuf { const Descriptor* descr = m1.GetDescriptor(); if (descr != m2.GetDescriptor()) { return false; - } + } for (int i = 0; i < descr->field_count(); ++i) if (!IsEqualField<useDefault>(m1, m2, *descr->field(i), differentPath)) { return false; @@ -148,14 +148,14 @@ namespace NProtoBuf { const Descriptor* descr = m1.GetDescriptor(); if (descr != m2.GetDescriptor()) { return false; - } + } return IsEqualField<useDefault>(m1, m2, field, differentPath); } bool IsEqualField(const Message& m1, const Message& m2, const FieldDescriptor& field) { return IsEqualFieldImpl<false>(m1, m2, field, nullptr); - } - + } + bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field) { return IsEqualFieldImpl<true>(m1, m2, field, nullptr); } diff --git a/library/cpp/protobuf/util/is_equal.h b/library/cpp/protobuf/util/is_equal.h index 13c0aae63d..b351b0e730 100644 --- a/library/cpp/protobuf/util/is_equal.h +++ b/library/cpp/protobuf/util/is_equal.h @@ -8,7 +8,7 @@ namespace google { class FieldDescriptor; } } - + namespace NProtoBuf { using ::google::protobuf::FieldDescriptor; using ::google::protobuf::Message; @@ -23,7 +23,7 @@ namespace NProtoBuf { bool IsEqual(const Message& m1, const Message& m2, TString* differentPath); bool IsEqualField(const Message& m1, const Message& m2, const FieldDescriptor& field); - + // Non-strict version: optional field without explicit value is compared // using its default value. bool IsEqualDefault(const Message& m1, const Message& m2); diff --git a/library/cpp/protobuf/util/is_equal_ut.cpp b/library/cpp/protobuf/util/is_equal_ut.cpp index 3ca4c90dd5..73c6e41a82 100644 --- a/library/cpp/protobuf/util/is_equal_ut.cpp +++ b/library/cpp/protobuf/util/is_equal_ut.cpp @@ -1,8 +1,8 @@ -#include "is_equal.h" +#include "is_equal.h" #include <library/cpp/protobuf/util/ut/sample_for_is_equal.pb.h> - + #include <library/cpp/testing/unittest/registar.h> - + #include <google/protobuf/descriptor.h> Y_UNIT_TEST_SUITE(ProtobufIsEqual) { @@ -18,37 +18,37 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { } Y_UNIT_TEST(IsEqual1) { - TSampleForIsEqual a; - TSampleForIsEqual b; - - a.SetName("aaa"); - b.SetName("bbb"); - + TSampleForIsEqual a; + TSampleForIsEqual b; + + a.SetName("aaa"); + b.SetName("bbb"); + TString path; - - bool equal = NProtoBuf::IsEqual(a, b, &path); - UNIT_ASSERT(!equal); - UNIT_ASSERT_VALUES_EQUAL("Name", path); + + bool equal = NProtoBuf::IsEqual(a, b, &path); + UNIT_ASSERT(!equal); + UNIT_ASSERT_VALUES_EQUAL("Name", path); UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); - } - + } + Y_UNIT_TEST(IsEqual2) { - TSampleForIsEqual a; - TSampleForIsEqual b; - - a.MutableInner()->SetBrbrbr("aaa"); - b.MutableInner()->SetBrbrbr("bbb"); - + TSampleForIsEqual a; + TSampleForIsEqual b; + + a.MutableInner()->SetBrbrbr("aaa"); + b.MutableInner()->SetBrbrbr("bbb"); + TString path; - - bool equal = NProtoBuf::IsEqual(a, b, &path); - UNIT_ASSERT(!equal); - UNIT_ASSERT_VALUES_EQUAL("Inner/Brbrbr", path); + + bool equal = NProtoBuf::IsEqual(a, b, &path); + UNIT_ASSERT(!equal); + UNIT_ASSERT_VALUES_EQUAL("Inner/Brbrbr", path); bool equalField = NProtoBuf::IsEqualField(a, b, *InnerDescr); UNIT_ASSERT(!equalField); - } + } Y_UNIT_TEST(IsEqual3) { TSampleForIsEqual a; @@ -85,4 +85,4 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) { UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); UNIT_ASSERT(NProtoBuf::IsEqualFieldDefault(a, b, *NameDescr)); } -} +} diff --git a/library/cpp/protobuf/util/repeated_field_utils.h b/library/cpp/protobuf/util/repeated_field_utils.h index c07bd84647..9d53a797d8 100644 --- a/library/cpp/protobuf/util/repeated_field_utils.h +++ b/library/cpp/protobuf/util/repeated_field_utils.h @@ -1,20 +1,20 @@ -#pragma once - +#pragma once + #include <google/protobuf/repeated_field.h> #include <util/generic/vector.h> - -template <typename T> -void RemoveRepeatedPtrFieldElement(google::protobuf::RepeatedPtrField<T>* repeated, unsigned index) { - google::protobuf::RepeatedPtrField<T> r; + +template <typename T> +void RemoveRepeatedPtrFieldElement(google::protobuf::RepeatedPtrField<T>* repeated, unsigned index) { + google::protobuf::RepeatedPtrField<T> r; Y_ASSERT(index < (unsigned)repeated->size()); for (unsigned i = 0; i < (unsigned)repeated->size(); ++i) { - if (i == index) { - continue; - } - r.Add()->Swap(repeated->Mutable(i)); - } - r.Swap(repeated); -} + if (i == index) { + continue; + } + r.Add()->Swap(repeated->Mutable(i)); + } + r.Swap(repeated); +} namespace NProtoBuf { /// Move item to specified position diff --git a/library/cpp/protobuf/util/ut/sample_for_is_equal.proto b/library/cpp/protobuf/util/ut/sample_for_is_equal.proto index a91c16deaa..d2257d7f6b 100644 --- a/library/cpp/protobuf/util/ut/sample_for_is_equal.proto +++ b/library/cpp/protobuf/util/ut/sample_for_is_equal.proto @@ -1,8 +1,8 @@ -message TInner { - optional string Brbrbr = 3; -} - -message TSampleForIsEqual { - optional string Name = 1; - optional TInner Inner = 5; -} +message TInner { + optional string Brbrbr = 3; +} + +message TSampleForIsEqual { + optional string Name = 1; + optional TInner Inner = 5; +} diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make index 701ba9a8c8..be07c51347 100644 --- a/library/cpp/protobuf/util/ut/ya.make +++ b/library/cpp/protobuf/util/ut/ya.make @@ -1,10 +1,10 @@ -OWNER(nga) - +OWNER(nga) + UNITTEST_FOR(library/cpp/protobuf/util) - -SRCS( + +SRCS( extensions.proto - sample_for_is_equal.proto + sample_for_is_equal.proto sample_for_simple_reflection.proto common_ut.proto pb_io_ut.cpp @@ -14,6 +14,6 @@ SRCS( repeated_field_utils_ut.cpp walk_ut.cpp merge_ut.cpp -) - -END() +) + +END() diff --git a/library/cpp/protobuf/util/ya.make b/library/cpp/protobuf/util/ya.make index b62028af58..ed47ab6f2a 100644 --- a/library/cpp/protobuf/util/ya.make +++ b/library/cpp/protobuf/util/ya.make @@ -16,7 +16,7 @@ SRCS( path.cpp pb_io.cpp pb_utils.h - repeated_field_utils.h + repeated_field_utils.h simple_reflection.cpp walk.cpp ) |