aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/util
diff options
context:
space:
mode:
authorEgor Kochetov <gluk47@gmail.com>2022-02-10 16:50:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:36 +0300
commit40896b241c91572ea1369526ee1e6ae0ba340f34 (patch)
treecb6d8f482e66c136ec128a42417cd5f858520d12 /library/cpp/protobuf/util
parent3889d4c01a589a555fbc33d66279be23e267ab3b (diff)
downloadydb-40896b241c91572ea1369526ee1e6ae0ba340f34.tar.gz
Restoring authorship annotation for Egor Kochetov <gluk47@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/protobuf/util')
-rw-r--r--library/cpp/protobuf/util/iterators.h104
-rw-r--r--library/cpp/protobuf/util/iterators_ut.cpp94
-rw-r--r--library/cpp/protobuf/util/ut/ya.make2
-rw-r--r--library/cpp/protobuf/util/ya.make2
4 files changed, 101 insertions, 101 deletions
diff --git a/library/cpp/protobuf/util/iterators.h b/library/cpp/protobuf/util/iterators.h
index 6d53ac71b1..7830127d3f 100644
--- a/library/cpp/protobuf/util/iterators.h
+++ b/library/cpp/protobuf/util/iterators.h
@@ -1,53 +1,53 @@
-#pragma once
-
+#pragma once
+
#include <google/protobuf/descriptor.h>
-
-namespace NProtoBuf {
- class TFieldsIterator {
- public:
- explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0)
- : Descriptor(descriptor)
- , Position(position)
- { }
-
- TFieldsIterator& operator++() {
- ++Position;
- return *this;
- }
-
- TFieldsIterator& operator++(int) {
- auto& ret = *this;
- ++*this;
- return ret;
- }
-
- const NProtoBuf::FieldDescriptor* operator*() const {
- return Descriptor->field(Position);
- }
-
- bool operator== (const TFieldsIterator& other) const {
- return Position == other.Position && Descriptor == other.Descriptor;
- }
-
- bool operator!= (const TFieldsIterator& other) const {
- return !(*this == other);
- }
-
- private:
- const NProtoBuf::Descriptor* Descriptor = nullptr;
- int Position = 0;
- };
-}
-
-// Namespaces required by `range-based for` ADL:
-namespace google {
- namespace protobuf {
- NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) {
- return NProtoBuf::TFieldsIterator(&descriptor);
- }
-
- NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) {
- return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count());
- }
- }
-}
+
+namespace NProtoBuf {
+ class TFieldsIterator {
+ public:
+ explicit TFieldsIterator(const NProtoBuf::Descriptor* descriptor, int position = 0)
+ : Descriptor(descriptor)
+ , Position(position)
+ { }
+
+ TFieldsIterator& operator++() {
+ ++Position;
+ return *this;
+ }
+
+ TFieldsIterator& operator++(int) {
+ auto& ret = *this;
+ ++*this;
+ return ret;
+ }
+
+ const NProtoBuf::FieldDescriptor* operator*() const {
+ return Descriptor->field(Position);
+ }
+
+ bool operator== (const TFieldsIterator& other) const {
+ return Position == other.Position && Descriptor == other.Descriptor;
+ }
+
+ bool operator!= (const TFieldsIterator& other) const {
+ return !(*this == other);
+ }
+
+ private:
+ const NProtoBuf::Descriptor* Descriptor = nullptr;
+ int Position = 0;
+ };
+}
+
+// Namespaces required by `range-based for` ADL:
+namespace google {
+ namespace protobuf {
+ NProtoBuf::TFieldsIterator begin(const NProtoBuf::Descriptor& descriptor) {
+ return NProtoBuf::TFieldsIterator(&descriptor);
+ }
+
+ NProtoBuf::TFieldsIterator end(const NProtoBuf::Descriptor& descriptor) {
+ return NProtoBuf::TFieldsIterator(&descriptor, descriptor.field_count());
+ }
+ }
+}
diff --git a/library/cpp/protobuf/util/iterators_ut.cpp b/library/cpp/protobuf/util/iterators_ut.cpp
index 9ebcff2963..0350fa425c 100644
--- a/library/cpp/protobuf/util/iterators_ut.cpp
+++ b/library/cpp/protobuf/util/iterators_ut.cpp
@@ -1,52 +1,52 @@
-#include "iterators.h"
-#include "simple_reflection.h"
+#include "iterators.h"
+#include "simple_reflection.h"
#include <library/cpp/protobuf/util/ut/common_ut.pb.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/algorithm.h>
-
-using NProtoBuf::TFieldsIterator;
-using NProtoBuf::TConstField;
-
+
+#include <util/generic/algorithm.h>
+
+using NProtoBuf::TFieldsIterator;
+using NProtoBuf::TConstField;
+
Y_UNIT_TEST_SUITE(Iterators) {
Y_UNIT_TEST(Count) {
- const NProtobufUtilUt::TWalkTest proto;
- const NProtoBuf::Descriptor* d = proto.GetDescriptor();
- TFieldsIterator dbegin(d), dend(d, d->field_count());
- size_t steps = 0;
-
- UNIT_ASSERT_EQUAL(dbegin, begin(*d));
- UNIT_ASSERT_EQUAL(dend, end(*d));
-
- for (; dbegin != dend; ++dbegin)
- ++steps;
- UNIT_ASSERT_VALUES_EQUAL(steps, d->field_count());
- }
-
- Y_UNIT_TEST(RangeFor) {
- size_t steps = 0, values = 0;
- NProtobufUtilUt::TWalkTest proto;
- proto.SetOptStr("yandex");
- for (const auto& field : *proto.GetDescriptor()) {
- values += TConstField(proto, field).HasValue();
- ++steps;
- }
- UNIT_ASSERT_VALUES_EQUAL(steps, proto.GetDescriptor()->field_count());
- UNIT_ASSERT_VALUES_EQUAL(values, 1);
- }
-
+ const NProtobufUtilUt::TWalkTest proto;
+ const NProtoBuf::Descriptor* d = proto.GetDescriptor();
+ TFieldsIterator dbegin(d), dend(d, d->field_count());
+ size_t steps = 0;
+
+ UNIT_ASSERT_EQUAL(dbegin, begin(*d));
+ UNIT_ASSERT_EQUAL(dend, end(*d));
+
+ for (; dbegin != dend; ++dbegin)
+ ++steps;
+ UNIT_ASSERT_VALUES_EQUAL(steps, d->field_count());
+ }
+
+ Y_UNIT_TEST(RangeFor) {
+ size_t steps = 0, values = 0;
+ NProtobufUtilUt::TWalkTest proto;
+ proto.SetOptStr("yandex");
+ for (const auto& field : *proto.GetDescriptor()) {
+ values += TConstField(proto, field).HasValue();
+ ++steps;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(steps, proto.GetDescriptor()->field_count());
+ UNIT_ASSERT_VALUES_EQUAL(values, 1);
+ }
+
Y_UNIT_TEST(AnyOf) {
- NProtobufUtilUt::TWalkTest proto;
- const NProtoBuf::Descriptor* d = proto.GetDescriptor();
- TFieldsIterator begin(d), end(d, d->field_count());
- UNIT_ASSERT(!AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
- return TConstField(proto, f).HasValue();
- }));
-
- proto.SetOptStr("yandex");
- UNIT_ASSERT(AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
- return TConstField(proto, f).HasValue();
- }));
- }
-}
+ NProtobufUtilUt::TWalkTest proto;
+ const NProtoBuf::Descriptor* d = proto.GetDescriptor();
+ TFieldsIterator begin(d), end(d, d->field_count());
+ UNIT_ASSERT(!AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
+ return TConstField(proto, f).HasValue();
+ }));
+
+ proto.SetOptStr("yandex");
+ UNIT_ASSERT(AnyOf(begin, end, [&proto](const NProtoBuf::FieldDescriptor* f){
+ return TConstField(proto, f).HasValue();
+ }));
+ }
+}
diff --git a/library/cpp/protobuf/util/ut/ya.make b/library/cpp/protobuf/util/ut/ya.make
index 701ba9a8c8..bc1bacc52f 100644
--- a/library/cpp/protobuf/util/ut/ya.make
+++ b/library/cpp/protobuf/util/ut/ya.make
@@ -9,7 +9,7 @@ SRCS(
common_ut.proto
pb_io_ut.cpp
is_equal_ut.cpp
- iterators_ut.cpp
+ iterators_ut.cpp
simple_reflection_ut.cpp
repeated_field_utils_ut.cpp
walk_ut.cpp
diff --git a/library/cpp/protobuf/util/ya.make b/library/cpp/protobuf/util/ya.make
index b62028af58..a5bf4383a7 100644
--- a/library/cpp/protobuf/util/ya.make
+++ b/library/cpp/protobuf/util/ya.make
@@ -11,7 +11,7 @@ PEERDIR(
SRCS(
is_equal.cpp
- iterators.h
+ iterators.h
merge.cpp
path.cpp
pb_io.cpp