aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authormikari <mikari@yandex-team.ru>2022-02-10 16:48:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:47 +0300
commit2e0ed5ad2d70bf924ccd3cbbfab508784ab36325 (patch)
treec407f44de8fd4579bf0ceffc822d243ff76cfd26 /library
parentab32245a89d56835833808c7e644b3da277d7085 (diff)
downloadydb-2e0ed5ad2d70bf924ccd3cbbfab508784ab36325.tar.gz
Restoring authorship annotation for <mikari@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
-rw-r--r--library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp114
-rw-r--r--library/cpp/containers/intrusive_rb_tree/fuzz/ya.make28
-rw-r--r--library/cpp/containers/intrusive_rb_tree/rb_tree.h50
-rw-r--r--library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp142
-rw-r--r--library/cpp/iterator/mapped.h60
-rw-r--r--library/cpp/iterator/ut/mapped_ut.cpp2
-rw-r--r--library/cpp/logger/global/global.cpp4
-rw-r--r--library/cpp/logger/global/global.h12
-rw-r--r--library/cpp/logger/log.cpp20
-rw-r--r--library/cpp/logger/log.h6
-rw-r--r--library/cpp/logger/thread.cpp20
-rw-r--r--library/cpp/logger/thread.h10
-rw-r--r--library/cpp/protobuf/json/json2proto.cpp12
-rw-r--r--library/cpp/protobuf/json/json2proto.h2
-rw-r--r--library/cpp/protobuf/json/ut/json2proto_ut.cpp6
-rw-r--r--library/cpp/yson/node/node.cpp478
-rw-r--r--library/cpp/yson/node/node.h294
-rw-r--r--library/cpp/yson/node/node_io.cpp8
-rw-r--r--library/cpp/yson/node/node_io.h2
-rw-r--r--library/cpp/yson/node/node_ut.cpp240
-rw-r--r--library/python/testing/import_test/import_test.py2
21 files changed, 756 insertions, 756 deletions
diff --git a/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp b/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp
index 92370760b5..8c386a59e5 100644
--- a/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp
+++ b/library/cpp/containers/intrusive_rb_tree/fuzz/rb_tree_fuzzing.cpp
@@ -1,65 +1,65 @@
#include <library/cpp/containers/intrusive_rb_tree/rb_tree.h>
-
-#include <util/generic/deque.h>
-#include <stdint.h>
-#include <stddef.h>
-
-struct TCmp {
- template <class T>
- static inline bool Compare(const T& l, const T& r) {
- return l.N < r.N;
- }
-
- template <class T>
+
+#include <util/generic/deque.h>
+#include <stdint.h>
+#include <stddef.h>
+
+struct TCmp {
+ template <class T>
+ static inline bool Compare(const T& l, const T& r) {
+ return l.N < r.N;
+ }
+
+ template <class T>
static inline bool Compare(const T& l, ui8 r) {
- return l.N < r;
- }
-
- template <class T>
+ return l.N < r;
+ }
+
+ template <class T>
static inline bool Compare(ui8 l, const T& r) {
- return l < r.N;
- }
-};
-
-class TNode: public TRbTreeItem<TNode, TCmp> {
-public:
+ return l < r.N;
+ }
+};
+
+class TNode: public TRbTreeItem<TNode, TCmp> {
+public:
inline TNode(ui8 n) noexcept
- : N(n)
- {
- }
-
+ : N(n)
+ {
+ }
+
ui8 N;
-};
-
-using TTree = TRbTree<TNode, TCmp>;
-
+};
+
+using TTree = TRbTree<TNode, TCmp>;
+
extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) {
TDeque<TNode> records;
const ui8 half = 128u;
- TTree tree;
- for (size_t i = 0; i < size; ++i) {
- if (data[i] / half == 0) {
- records.emplace_back(data[i] % half);
- tree.Insert(&records.back());
- } else {
- auto* ptr = tree.Find(data[i] % half);
- if (ptr != nullptr) {
- tree.Erase(ptr);
- }
- }
- auto check = [](const TNode& node) {
- size_t childrens = 1;
- if (node.Left_) {
- Y_ENSURE(static_cast<const TNode*>(node.Left_)->N <= node.N);
- childrens += node.Left_->Children_;
- }
- if (node.Right_) {
- Y_ENSURE(node.N <= static_cast<const TNode*>(node.Right_)->N);
- childrens += node.Right_->Children_;
- }
- Y_ENSURE(childrens == node.Children_);
- };
- tree.ForEach(check);
- }
- return 0;
-}
+ TTree tree;
+ for (size_t i = 0; i < size; ++i) {
+ if (data[i] / half == 0) {
+ records.emplace_back(data[i] % half);
+ tree.Insert(&records.back());
+ } else {
+ auto* ptr = tree.Find(data[i] % half);
+ if (ptr != nullptr) {
+ tree.Erase(ptr);
+ }
+ }
+ auto check = [](const TNode& node) {
+ size_t childrens = 1;
+ if (node.Left_) {
+ Y_ENSURE(static_cast<const TNode*>(node.Left_)->N <= node.N);
+ childrens += node.Left_->Children_;
+ }
+ if (node.Right_) {
+ Y_ENSURE(node.N <= static_cast<const TNode*>(node.Right_)->N);
+ childrens += node.Right_->Children_;
+ }
+ Y_ENSURE(childrens == node.Children_);
+ };
+ tree.ForEach(check);
+ }
+ return 0;
+}
diff --git a/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make b/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make
index 61be9919e6..90c55bc9b8 100644
--- a/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make
+++ b/library/cpp/containers/intrusive_rb_tree/fuzz/ya.make
@@ -1,20 +1,20 @@
-FUZZ()
-
+FUZZ()
+
OWNER(
g:util
mikari
)
+
+SIZE(LARGE)
-SIZE(LARGE)
-
-TAG(ya:fat)
-
-PEERDIR(
+TAG(ya:fat)
+
+PEERDIR(
library/cpp/containers/intrusive_rb_tree
-)
-
-SRCS(
- rb_tree_fuzzing.cpp
-)
-
-END()
+)
+
+SRCS(
+ rb_tree_fuzzing.cpp
+)
+
+END()
diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree.h b/library/cpp/containers/intrusive_rb_tree/rb_tree.h
index 0259452a14..4118d01a25 100644
--- a/library/cpp/containers/intrusive_rb_tree/rb_tree.h
+++ b/library/cpp/containers/intrusive_rb_tree/rb_tree.h
@@ -67,8 +67,8 @@ public:
static void Rebalance(TBasePtr x, TBasePtr& root);
static TBasePtr RebalanceForErase(TBasePtr z, TBasePtr& root, TBasePtr& leftmost, TBasePtr& rightmost);
- static void DecrementChildrenUntilRoot(TBasePtr x, TBasePtr root);
- static void RecalcChildren(TBasePtr x);
+ static void DecrementChildrenUntilRoot(TBasePtr x, TBasePtr root);
+ static void RecalcChildren(TBasePtr x);
static TBasePtr IncrementNode(TBasePtr);
static TBasePtr DecrementNode(TBasePtr);
@@ -610,21 +610,21 @@ void TRbGlobal<TDummy>::Rebalance(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) {
}
template <class TDummy>
-void TRbGlobal<TDummy>::RecalcChildren(TRbTreeNodeBase* x) {
- x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1;
-}
-
-template <class TDummy>
-void TRbGlobal<TDummy>::DecrementChildrenUntilRoot(TRbTreeNodeBase* x, TRbTreeNodeBase* root) {
- auto* ptr = x;
- --ptr->Children_;
- while (ptr != root) {
- ptr = ptr->Parent_;
- --ptr->Children_;
- }
-}
-
-template <class TDummy>
+void TRbGlobal<TDummy>::RecalcChildren(TRbTreeNodeBase* x) {
+ x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1;
+}
+
+template <class TDummy>
+void TRbGlobal<TDummy>::DecrementChildrenUntilRoot(TRbTreeNodeBase* x, TRbTreeNodeBase* root) {
+ auto* ptr = x;
+ --ptr->Children_;
+ while (ptr != root) {
+ ptr = ptr->Parent_;
+ --ptr->Children_;
+ }
+}
+
+template <class TDummy>
TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z,
TRbTreeNodeBase*& root,
TRbTreeNodeBase*& leftmost,
@@ -665,14 +665,14 @@ TRbTreeNodeBase* TRbGlobal<TDummy>::RebalanceForErase(TRbTreeNodeBase* z,
z->Parent_->Right_ = y;
y->Parent_ = z->Parent_;
DoSwap(y->Color_, z->Color_);
-
- RecalcChildren(y);
- if (x_parent != y) {
- --x_parent->Children_;
- }
- if (x_parent != root) {
- DecrementChildrenUntilRoot(x_parent->Parent_, root);
- }
+
+ RecalcChildren(y);
+ if (x_parent != y) {
+ --x_parent->Children_;
+ }
+ if (x_parent != root) {
+ DecrementChildrenUntilRoot(x_parent->Parent_, root);
+ }
y = z;
// y now points to node to be actually deleted
} else {
diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
index c34ed1fd9b..095cf76b47 100644
--- a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
+++ b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
@@ -43,8 +43,8 @@ class TRedBlackTreeTest: public TTestBase {
UNIT_TEST(TestFind)
UNIT_TEST(TestStress)
UNIT_TEST(TestGettingIndexWithDifferentValues)
- UNIT_TEST(TestCheckChildrenAfterErase)
- UNIT_TEST(TestGettingIndexWithDifferentValuesAfterErase)
+ UNIT_TEST(TestCheckChildrenAfterErase)
+ UNIT_TEST(TestGettingIndexWithDifferentValuesAfterErase)
UNIT_TEST(TestGettingIndexWithEqualValues)
UNIT_TEST(TestLessCountOnEmptyTree)
UNIT_TEST_SUITE_END();
@@ -104,77 +104,77 @@ private:
}
}
- inline void TestCheckChildrenAfterErase() {
+ inline void TestCheckChildrenAfterErase() {
TVector<TSimpleSharedPtr<TNode>> nodes;
- size_t N = 1000;
-
- for (size_t i = 0; i < N; ++i) {
- nodes.push_back(new TNode(int(i)));
- }
-
- TTree tree;
- Shuffle(nodes.begin(), nodes.end());
-
- for (size_t i = 0; i < N; ++i) {
- tree.Insert(nodes[i].Get());
- }
- auto checker = [](const TTree& tree) {
- for (auto node = tree.Begin(); node != tree.End(); ++node) {
- size_t childrens = 1;
- if (node->Left_) {
- childrens += node->Left_->Children_;
- }
- if (node->Right_) {
- childrens += node->Right_->Children_;
- }
- UNIT_ASSERT_VALUES_EQUAL(childrens, node->Children_);
- }
- };
-
- for (auto node : nodes) {
- tree.Erase(node.Get());
- checker(tree);
- }
- }
-
- inline void TestGettingIndexWithDifferentValuesAfterErase() {
+ size_t N = 1000;
+
+ for (size_t i = 0; i < N; ++i) {
+ nodes.push_back(new TNode(int(i)));
+ }
+
+ TTree tree;
+ Shuffle(nodes.begin(), nodes.end());
+
+ for (size_t i = 0; i < N; ++i) {
+ tree.Insert(nodes[i].Get());
+ }
+ auto checker = [](const TTree& tree) {
+ for (auto node = tree.Begin(); node != tree.End(); ++node) {
+ size_t childrens = 1;
+ if (node->Left_) {
+ childrens += node->Left_->Children_;
+ }
+ if (node->Right_) {
+ childrens += node->Right_->Children_;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(childrens, node->Children_);
+ }
+ };
+
+ for (auto node : nodes) {
+ tree.Erase(node.Get());
+ checker(tree);
+ }
+ }
+
+ inline void TestGettingIndexWithDifferentValuesAfterErase() {
TVector<TSimpleSharedPtr<TNode>> nodes;
- size_t N = 1000;
-
- for (size_t i = 0; i < N; ++i) {
- nodes.push_back(new TNode(int(i)));
- }
-
- TTree tree;
- Shuffle(nodes.begin(), nodes.end());
-
- for (size_t i = 0; i < N; ++i) {
- tree.Insert(nodes[i].Get());
- }
- {
- size_t index = 0;
- for (auto node = tree.Begin(); node != tree.End(); ++node, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(tree.GetIndex(&*node), index);
- UNIT_ASSERT_VALUES_EQUAL(tree.ByIndex(index)->N, node->N);
- UNIT_ASSERT_VALUES_EQUAL(node->N, index);
- }
- }
-
- for (size_t i = 1; i < N; i += 2) {
- auto* node = tree.Find(i);
- UNIT_ASSERT_VALUES_EQUAL(node->N, i);
- tree.Erase(node);
- }
- {
- size_t index = 0;
- for (auto node = tree.Begin(); node != tree.End(); ++node, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(tree.GetIndex(&*node), index);
- UNIT_ASSERT_VALUES_EQUAL(tree.ByIndex(index)->N, node->N);
- UNIT_ASSERT_VALUES_EQUAL(node->N, 2 * index);
- }
- }
- }
-
+ size_t N = 1000;
+
+ for (size_t i = 0; i < N; ++i) {
+ nodes.push_back(new TNode(int(i)));
+ }
+
+ TTree tree;
+ Shuffle(nodes.begin(), nodes.end());
+
+ for (size_t i = 0; i < N; ++i) {
+ tree.Insert(nodes[i].Get());
+ }
+ {
+ size_t index = 0;
+ for (auto node = tree.Begin(); node != tree.End(); ++node, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(tree.GetIndex(&*node), index);
+ UNIT_ASSERT_VALUES_EQUAL(tree.ByIndex(index)->N, node->N);
+ UNIT_ASSERT_VALUES_EQUAL(node->N, index);
+ }
+ }
+
+ for (size_t i = 1; i < N; i += 2) {
+ auto* node = tree.Find(i);
+ UNIT_ASSERT_VALUES_EQUAL(node->N, i);
+ tree.Erase(node);
+ }
+ {
+ size_t index = 0;
+ for (auto node = tree.Begin(); node != tree.End(); ++node, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(tree.GetIndex(&*node), index);
+ UNIT_ASSERT_VALUES_EQUAL(tree.ByIndex(index)->N, node->N);
+ UNIT_ASSERT_VALUES_EQUAL(node->N, 2 * index);
+ }
+ }
+ }
+
inline void TestGettingIndexWithEqualValues() {
TVector<TSimpleSharedPtr<TNode>> nodes;
size_t N = 1000;
diff --git a/library/cpp/iterator/mapped.h b/library/cpp/iterator/mapped.h
index 6c5e763184..1bc2663bb7 100644
--- a/library/cpp/iterator/mapped.h
+++ b/library/cpp/iterator/mapped.h
@@ -29,7 +29,7 @@ public:
using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(),
std::random_access_iterator_tag, std::input_iterator_tag>;
- TMappedIterator(TIterator it, TMapper mapper)
+ TMappedIterator(TIterator it, TMapper mapper)
: Iter(it)
, Mapper(std::move(mapper))
{
@@ -89,11 +89,11 @@ public:
private:
TIterator Iter;
- TMapper Mapper;
+ TMapper Mapper;
};
-template <class TContainer, class TMapper>
+template <class TContainer, class TMapper>
class TInputMappedRange {
protected:
using TContainerStorage = TAutoEmbedOrPtrPolicy<TContainer>;
@@ -101,27 +101,27 @@ protected:
using TMapperWrapper = std::reference_wrapper<std::remove_reference_t<TMapper>>;
using TInternalIterator = decltype(std::begin(std::declval<TContainer&>()));
using TIterator = TMappedIterator<TInternalIterator, TMapperWrapper>;
-public:
+public:
using iterator = TIterator;
using const_iterator = TIterator;
using value_type = typename TIterator::value_type;
using reference = typename TIterator::reference;
using const_reference = typename TIterator::reference;
-
+
TInputMappedRange(TContainer&& container, TMapper&& mapper)
: Container(std::forward<TContainer>(container))
, Mapper(std::forward<TMapper>(mapper))
- {
- }
-
+ {
+ }
+
TIterator begin() const {
return {std::begin(*Container.Ptr()), {*Mapper.Ptr()}};
- }
-
+ }
+
TIterator end() const {
return {std::end(*Container.Ptr()), {*Mapper.Ptr()}};
- }
-
+ }
+
bool empty() const {
return std::begin(*Container.Ptr()) == std::end(*Container.Ptr());
}
@@ -130,7 +130,7 @@ protected:
mutable TContainerStorage Container;
mutable TMapperStorage Mapper;
};
-
+
template <class TContainer, class TMapper>
class TRandomAccessMappedRange : public TInputMappedRange<TContainer, TMapper> {
@@ -150,36 +150,36 @@ public:
TRandomAccessMappedRange(TContainer&& container, TMapper&& mapper)
: TBase(std::forward<TContainer>(container), std::forward<TMapper>(mapper))
{
- }
-
+ }
+
using TBase::begin;
using TBase::end;
using TBase::empty;
- size_type size() const {
+ size_type size() const {
return std::end(*this->Container.Ptr()) - std::begin(*this->Container.Ptr());
- }
-
- const_reference operator[](size_t at) const {
+ }
+
+ const_reference operator[](size_t at) const {
Y_ASSERT(at < this->size());
-
+
return *(this->begin() + at);
- }
-
- reference operator[](size_t at) {
+ }
+
+ reference operator[](size_t at) {
Y_ASSERT(at < this->size());
-
+
return *(this->begin() + at);
- }
-};
-
+ }
+};
+
template <class TIterator, class TMapper>
-TMappedIterator<TIterator, TMapper> MakeMappedIterator(TIterator iter, TMapper mapper) {
- return {iter, mapper};
+TMappedIterator<TIterator, TMapper> MakeMappedIterator(TIterator iter, TMapper mapper) {
+ return {iter, mapper};
}
template <class TIterator, class TMapper>
-auto MakeMappedRange(TIterator begin, TIterator end, TMapper mapper) {
+auto MakeMappedRange(TIterator begin, TIterator end, TMapper mapper) {
return MakeIteratorRange(MakeMappedIterator(begin, mapper), MakeMappedIterator(end, mapper));
}
diff --git a/library/cpp/iterator/ut/mapped_ut.cpp b/library/cpp/iterator/ut/mapped_ut.cpp
index 440cd37945..b073361be2 100644
--- a/library/cpp/iterator/ut/mapped_ut.cpp
+++ b/library/cpp/iterator/ut/mapped_ut.cpp
@@ -55,7 +55,7 @@ TEST(TIterator, TOwningMappedMethodTest) {
for (int& y : range) {
y += 7;
}
-
+
EXPECT_EQ(*range.begin(), 10);
EXPECT_EQ(*(range.begin() + 1), 10);
}
diff --git a/library/cpp/logger/global/global.cpp b/library/cpp/logger/global/global.cpp
index 9fbd10f666..4998e24ee9 100644
--- a/library/cpp/logger/global/global.cpp
+++ b/library/cpp/logger/global/global.cpp
@@ -16,8 +16,8 @@ void DoInitGlobalLog(const TString& logType, const int logLevel, const bool rota
(ELogPriority)logLevel,
threaded)),
std::move(formatter));
-}
-
+}
+
void DoInitGlobalLog(THolder<TLogBackend> backend, THolder<ILoggerFormatter> formatter) {
DoInitGlobalLog(THolder(new TGlobalLog(std::move(backend))), std::move(formatter));
}
diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h
index cbe71b16ea..e020f68099 100644
--- a/library/cpp/logger/global/global.h
+++ b/library/cpp/logger/global/global.h
@@ -23,11 +23,11 @@ public:
: TLog(logType, priority)
{
}
-
+
TGlobalLog(THolder<TLogBackend> backend)
: TLog(std::move(backend))
- {
- }
+ {
+ }
};
template <>
@@ -39,11 +39,11 @@ public:
: TLog(logType, priority)
{
}
-
+
TNullLog(THolder<TLogBackend> backend)
: TLog(std::move(backend))
- {
- }
+ {
+ }
};
template <>
diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp
index e1d70cc3d2..01e299b3e4 100644
--- a/library/cpp/logger/log.cpp
+++ b/library/cpp/logger/log.cpp
@@ -3,7 +3,7 @@
#include "filter.h"
#include "null.h"
#include "stream.h"
-#include "thread.h"
+#include "thread.h"
#include <util/string/cast.h>
#include <util/stream/printf.h>
@@ -16,8 +16,8 @@ THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priorit
TLogBackendCreatorUninitialized creator;
creator.InitCustom(fname, priority, threaded);
return creator.CreateLogBackend();
-}
-
+}
+
THolder<TLogBackend> CreateFilteredOwningThreadedLogBackend(const TString& fname, ELogPriority priority, size_t queueLen) {
return MakeHolder<TFilteredLogBackend>(CreateOwningThreadedLogBackend(fname, queueLen), priority);
}
@@ -230,9 +230,9 @@ void TLog::Write(ELogPriority priority, const char* data, size_t len) const {
if (Formatter_) {
const auto formated = Formatter_(priority, TStringBuf{data, len});
Impl_->WriteData(priority, formated.data(), formated.size());
- } else {
- Impl_->WriteData(priority, data, len);
- }
+ } else {
+ Impl_->WriteData(priority, data, len);
+ }
}
void TLog::Write(ELogPriority priority, const TStringBuf data) const {
@@ -240,12 +240,12 @@ void TLog::Write(ELogPriority priority, const TStringBuf data) const {
}
void TLog::Write(const char* data, size_t len) const {
- Write(Impl_->DefaultPriority(), data, len);
+ Write(Impl_->DefaultPriority(), data, len);
}
-
-void TLog::SetFormatter(TLogFormatter formatter) noexcept {
+
+void TLog::SetFormatter(TLogFormatter formatter) noexcept {
Formatter_ = std::move(formatter);
-}
+}
size_t TLog::BackEndQueueSize() const {
return Impl_->BackEndQueueSize();
diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h
index 8be984ccc8..edb861c8f3 100644
--- a/library/cpp/logger/log.h
+++ b/library/cpp/logger/log.h
@@ -9,11 +9,11 @@
#include <util/generic/fwd.h>
#include <util/generic/ptr.h>
-#include <functional>
+#include <functional>
#include <cstdarg>
using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
-
+
// Logging facilities interface.
//
// ```cpp
@@ -109,7 +109,7 @@ private:
TIntrusivePtr<TImpl> Impl_;
TLogFormatter Formatter_;
};
-
+
THolder<TLogBackend> CreateLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, bool threaded = false);
THolder<TLogBackend> CreateFilteredOwningThreadedLogBackend(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY, size_t queueLen = 0);
THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString& fname, size_t queueLen = 0);
diff --git a/library/cpp/logger/thread.cpp b/library/cpp/logger/thread.cpp
index 0ccf9e374b..8ef91bf45e 100644
--- a/library/cpp/logger/thread.cpp
+++ b/library/cpp/logger/thread.cpp
@@ -144,22 +144,22 @@ void TThreadedLogBackend::ReopenLogNoFlush() {
void TThreadedLogBackend::WriteEmergencyData(const TLogRecord& rec) {
Impl_->WriteEmergencyData(rec);
}
-
+
size_t TThreadedLogBackend::QueueSize() const {
return Impl_->QueueSize();
}
-TOwningThreadedLogBackend::TOwningThreadedLogBackend(TLogBackend* slave)
+TOwningThreadedLogBackend::TOwningThreadedLogBackend(TLogBackend* slave)
: THolder<TLogBackend>(slave)
, TThreadedLogBackend(Get())
-{
-}
-
+{
+}
+
TOwningThreadedLogBackend::TOwningThreadedLogBackend(TLogBackend* slave, size_t queuelen, std::function<void()> queueOverflowCallback)
: THolder<TLogBackend>(slave)
, TThreadedLogBackend(Get(), queuelen, std::move(queueOverflowCallback))
-{
-}
-
-TOwningThreadedLogBackend::~TOwningThreadedLogBackend() {
-}
+{
+}
+
+TOwningThreadedLogBackend::~TOwningThreadedLogBackend() {
+}
diff --git a/library/cpp/logger/thread.h b/library/cpp/logger/thread.h
index 65f7a88e87..ce4d334e7c 100644
--- a/library/cpp/logger/thread.h
+++ b/library/cpp/logger/thread.h
@@ -25,10 +25,10 @@ private:
class TImpl;
THolder<TImpl> Impl_;
};
-
+
class TOwningThreadedLogBackend: private THolder<TLogBackend>, public TThreadedLogBackend {
-public:
- TOwningThreadedLogBackend(TLogBackend* slave);
+public:
+ TOwningThreadedLogBackend(TLogBackend* slave);
TOwningThreadedLogBackend(TLogBackend* slave, size_t queuelen, std::function<void()> queueOverflowCallback = {});
- ~TOwningThreadedLogBackend() override;
-};
+ ~TOwningThreadedLogBackend() override;
+};
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp
index 640c10f5a5..f3f642bf81 100644
--- a/library/cpp/protobuf/json/json2proto.cpp
+++ b/library/cpp/protobuf/json/json2proto.cpp
@@ -13,10 +13,10 @@
#define JSON_TO_FIELD(EProtoCppType, name, json, JsonCheckType, ProtoSet, JsonGet) \
case FieldDescriptor::EProtoCppType: { \
- if (config.CastRobust) { \
- reflection->ProtoSet(&proto, &field, json.JsonGet##Robust()); \
- break; \
- } \
+ if (config.CastRobust) { \
+ reflection->ProtoSet(&proto, &field, json.JsonGet##Robust()); \
+ break; \
+ } \
if (!json.JsonCheckType()) { \
if (config.CastFromString && json.IsString()) { \
if (config.DoNotCastEmptyStrings && json.GetString().empty()) { \
@@ -87,12 +87,12 @@ JsonString2Field(const NJson::TJsonValue& json,
const Reflection* reflection = proto.GetReflection();
Y_ASSERT(!!reflection);
- if (!json.IsString() && !config.CastRobust) {
+ if (!json.IsString() && !config.CastRobust) {
ythrow yexception() << "Invalid type of JSON field '" << field.name() << "': "
<< "IsString() failed while "
<< "CPPTYPE_STRING is expected.";
}
- TString value = json.GetStringRobust();
+ TString value = json.GetStringRobust();
for (size_t i = 0, endI = config.StringTransforms.size(); i < endI; ++i) {
Y_ASSERT(!!config.StringTransforms[i]);
if (!!config.StringTransforms[i]) {
diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h
index 4c33498dfa..a80cc0c378 100644
--- a/library/cpp/protobuf/json/json2proto.h
+++ b/library/cpp/protobuf/json/json2proto.h
@@ -82,7 +82,7 @@ namespace NProtobufJson {
NameGenerator = callback;
return *this;
}
-
+
TSelf& SetEnumValueMode(EnumValueMode enumValueMode) {
EnumValueMode = enumValueMode;
return *this;
diff --git a/library/cpp/protobuf/json/ut/json2proto_ut.cpp b/library/cpp/protobuf/json/ut/json2proto_ut.cpp
index 0dfe57bc7a..959631e7a5 100644
--- a/library/cpp/protobuf/json/ut/json2proto_ut.cpp
+++ b/library/cpp/protobuf/json/ut/json2proto_ut.cpp
@@ -659,11 +659,11 @@ Y_UNIT_TEST(TestCastRobust) {
json["Double"] = 8;
TFlatOptional proto;
UNIT_ASSERT_EXCEPTION_CONTAINS(Json2Proto(json, proto), yexception, "Invalid type");
-
+
TJson2ProtoConfig config;
config.SetCastRobust(true);
Json2Proto(json, proto, config);
-
+
TFlatOptional expected;
expected.SetI32(5);
expected.SetBool(true);
@@ -671,7 +671,7 @@ Y_UNIT_TEST(TestCastRobust) {
expected.SetDouble(8);
UNIT_ASSERT_PROTOS_EQUAL(proto, expected);
}
-
+
Y_UNIT_TEST(TestVectorizeScalars) {
NJson::TJsonValue json;
#define DEFINE_FIELD(name, value) \
diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp
index b39e070718..458b6438b6 100644
--- a/library/cpp/yson/node/node.cpp
+++ b/library/cpp/yson/node/node.cpp
@@ -438,24 +438,24 @@ TNode& TNode::operator[](size_t index)
return std::get<TListType>(Value_)[index];
}
-const TNode& TNode::At(size_t index) const {
- CheckType(List);
+const TNode& TNode::At(size_t index) const {
+ CheckType(List);
const auto& list = std::get<TListType>(Value_);
- if (index >= list.size()) {
+ if (index >= list.size()) {
ythrow TLookupError() << "List out-of-range: requested index=" << index << ", but size=" << list.size();
- }
- return list[index];
-}
-
-TNode& TNode::At(size_t index) {
- CheckType(List);
+ }
+ return list[index];
+}
+
+TNode& TNode::At(size_t index) {
+ CheckType(List);
auto& list = std::get<TListType>(Value_);
- if (index >= list.size()) {
+ if (index >= list.size()) {
ythrow TLookupError() << "List out-of-range: requested index=" << index << ", but size=" << list.size();
- }
- return list[index];
-}
-
+ }
+ return list[index];
+}
+
TNode& TNode::Add() &
{
AssureList();
@@ -551,233 +551,233 @@ const TNode& TNode::At(const TStringBuf key) const {
}
}
-TNode& TNode::At(const TStringBuf key) {
- CheckType(Map);
+TNode& TNode::At(const TStringBuf key) {
+ CheckType(Map);
auto& map = std::get<TMapType>(Value_);
- TMapType::iterator i = map.find(key);
- if (i == map.end()) {
+ TMapType::iterator i = map.find(key);
+ if (i == map.end()) {
ythrow TLookupError() << "Cannot find key " << key;
- } else {
- return i->second;
- }
-}
-
-const TString& TNode::ChildAsString(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsString();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-i64 TNode::ChildAsInt64(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsInt64();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-ui64 TNode::ChildAsUint64(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsUint64();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-double TNode::ChildAsDouble(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsDouble();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-bool TNode::ChildAsBool(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsBool();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-const TNode::TListType& TNode::ChildAsList(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsList();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-const TNode::TMapType& TNode::ChildAsMap(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.AsMap();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-TNode::TListType& TNode::ChildAsList(const TStringBuf key) {
- auto& node = At(key);
- try {
- return node.AsList();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-TNode::TMapType& TNode::ChildAsMap(const TStringBuf key) {
- auto& node = At(key);
- try {
- return node.AsMap();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-const TString& TNode::ChildAsString(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsString();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-i64 TNode::ChildAsInt64(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsInt64();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-ui64 TNode::ChildAsUint64(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsUint64();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-double TNode::ChildAsDouble(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsDouble();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-bool TNode::ChildAsBool(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsBool();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-const TNode::TListType& TNode::ChildAsList(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsList();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-const TNode::TMapType& TNode::ChildAsMap(size_t index) const {
- const auto& node = At(index);
- try {
- return node.AsMap();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-TNode::TListType& TNode::ChildAsList(size_t index) {
- auto& node = At(index);
- try {
- return node.AsList();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-TNode::TMapType& TNode::ChildAsMap(size_t index) {
- auto& node = At(index);
- try {
- return node.AsMap();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
+ } else {
+ return i->second;
+ }
+}
+
+const TString& TNode::ChildAsString(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsString();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+i64 TNode::ChildAsInt64(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsInt64();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+ui64 TNode::ChildAsUint64(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsUint64();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+double TNode::ChildAsDouble(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsDouble();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+bool TNode::ChildAsBool(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsBool();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+const TNode::TListType& TNode::ChildAsList(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsList();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+const TNode::TMapType& TNode::ChildAsMap(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.AsMap();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+TNode::TListType& TNode::ChildAsList(const TStringBuf key) {
+ auto& node = At(key);
+ try {
+ return node.AsList();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+TNode::TMapType& TNode::ChildAsMap(const TStringBuf key) {
+ auto& node = At(key);
+ try {
+ return node.AsMap();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+const TString& TNode::ChildAsString(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsString();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+i64 TNode::ChildAsInt64(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsInt64();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+ui64 TNode::ChildAsUint64(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsUint64();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+double TNode::ChildAsDouble(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsDouble();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+bool TNode::ChildAsBool(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsBool();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+const TNode::TListType& TNode::ChildAsList(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsList();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+const TNode::TMapType& TNode::ChildAsMap(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.AsMap();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+TNode::TListType& TNode::ChildAsList(size_t index) {
+ auto& node = At(index);
+ try {
+ return node.AsList();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+TNode::TMapType& TNode::ChildAsMap(size_t index) {
+ auto& node = At(index);
+ try {
+ return node.AsMap();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
bool TNode::HasAttributes() const
{
return Attributes_ && !Attributes_->Empty();
diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h
index 5f90f95df0..fe3eeceea8 100644
--- a/library/cpp/yson/node/node.h
+++ b/library/cpp/yson/node/node.h
@@ -7,11 +7,11 @@
#include <util/generic/vector.h>
#include <util/generic/yexception.h>
#include <util/generic/ylimits.h>
-#include <util/string/cast.h>
+#include <util/string/cast.h>
-#include <cmath>
+#include <cmath>
#include <variant>
-
+
class IInputStream;
class IOutputStream;
@@ -160,16 +160,16 @@ public:
TMapType& UncheckedAsMap() noexcept;
// integer types cast
- // makes overflow checks
+ // makes overflow checks
template<typename T>
- T IntCast() const;
-
+ T IntCast() const;
+
// integers <-> double <-> string
- // makes overflow checks
- template<typename T>
- T ConvertTo() const;
-
- template<typename T>
+ // makes overflow checks
+ template<typename T>
+ T ConvertTo() const;
+
+ template<typename T>
T& As();
template<typename T>
@@ -183,8 +183,8 @@ public:
const TNode& operator[](size_t index) const;
TNode& operator[](size_t index);
- const TNode& At(size_t index) const;
- TNode& At(size_t index);
+ const TNode& At(size_t index) const;
+ TNode& At(size_t index);
TNode& Add() &;
TNode Add() &&;
@@ -203,53 +203,53 @@ public:
const TNode& operator[](const TStringBuf key) const;
TNode& operator[](const TStringBuf key);
const TNode& At(const TStringBuf key) const;
- TNode& At(const TStringBuf key);
-
- // map getters
- // works the same way like simple getters
- const TString& ChildAsString(const TStringBuf key) const;
- i64 ChildAsInt64(const TStringBuf key) const;
- ui64 ChildAsUint64(const TStringBuf key) const;
- double ChildAsDouble(const TStringBuf key) const;
- bool ChildAsBool(const TStringBuf key) const;
- const TListType& ChildAsList(const TStringBuf key) const;
- const TMapType& ChildAsMap(const TStringBuf key) const;
- TListType& ChildAsList(const TStringBuf key);
- TMapType& ChildAsMap(const TStringBuf key);
-
- template<typename T>
- T ChildIntCast(const TStringBuf key) const;
-
- template<typename T>
- T ChildConvertTo(const TStringBuf key) const;
-
+ TNode& At(const TStringBuf key);
+
+ // map getters
+ // works the same way like simple getters
+ const TString& ChildAsString(const TStringBuf key) const;
+ i64 ChildAsInt64(const TStringBuf key) const;
+ ui64 ChildAsUint64(const TStringBuf key) const;
+ double ChildAsDouble(const TStringBuf key) const;
+ bool ChildAsBool(const TStringBuf key) const;
+ const TListType& ChildAsList(const TStringBuf key) const;
+ const TMapType& ChildAsMap(const TStringBuf key) const;
+ TListType& ChildAsList(const TStringBuf key);
+ TMapType& ChildAsMap(const TStringBuf key);
+
+ template<typename T>
+ T ChildIntCast(const TStringBuf key) const;
+
+ template<typename T>
+ T ChildConvertTo(const TStringBuf key) const;
+
template<typename T>
const T& ChildAs(const TStringBuf key) const;
template<typename T>
T& ChildAs(const TStringBuf key);
- // list getters
- // works the same way like simple getters
- const TString& ChildAsString(size_t index) const;
- i64 ChildAsInt64(size_t index) const;
- ui64 ChildAsUint64(size_t index) const;
- double ChildAsDouble(size_t index) const;
- bool ChildAsBool(size_t index) const;
- const TListType& ChildAsList(size_t index) const;
- const TMapType& ChildAsMap(size_t index) const;
- TListType& ChildAsList(size_t index);
- TMapType& ChildAsMap(size_t index);
-
- template<typename T>
- T ChildIntCast(size_t index) const;
-
- template<typename T>
- T ChildConvertTo(size_t index) const;
-
+ // list getters
+ // works the same way like simple getters
+ const TString& ChildAsString(size_t index) const;
+ i64 ChildAsInt64(size_t index) const;
+ ui64 ChildAsUint64(size_t index) const;
+ double ChildAsDouble(size_t index) const;
+ bool ChildAsBool(size_t index) const;
+ const TListType& ChildAsList(size_t index) const;
+ const TMapType& ChildAsMap(size_t index) const;
+ TListType& ChildAsList(size_t index);
+ TMapType& ChildAsMap(size_t index);
+
+ template<typename T>
+ T ChildIntCast(size_t index) const;
+
+ template<typename T>
+ T ChildConvertTo(size_t index) const;
+
template<typename T>
const T& ChildAs(size_t index) const;
-
+
template<typename T>
T& ChildAs(size_t index);
@@ -295,7 +295,7 @@ inline bool TNode::IsArithmetic() const {
}
template<typename T>
-inline T TNode::IntCast() const {
+inline T TNode::IntCast() const {
if constexpr (std::is_integral<T>::value) {
try {
switch (GetType()) {
@@ -305,17 +305,17 @@ inline T TNode::IntCast() const {
return SafeIntegerCast<T>(AsInt64());
default:
ythrow TTypeError() << "IntCast() called for type " << GetType();
- }
+ }
} catch(TBadCastException& exc) {
ythrow TTypeError() << "TBadCastException during IntCast(): " << exc.what();
}
} else {
static_assert(sizeof(T) != sizeof(T), "implemented only for std::is_integral types");
- }
-}
-
-template<typename T>
-inline T TNode::ConvertTo() const {
+ }
+}
+
+template<typename T>
+inline T TNode::ConvertTo() const {
if constexpr (std::is_integral<T>::value) {
switch (GetType()) {
case NYT::TNode::String:
@@ -339,125 +339,125 @@ inline T TNode::ConvertTo() const {
} else {
static_assert(sizeof(T) != sizeof(T), "should have template specialization");
}
-}
-
-template<>
-inline TString TNode::ConvertTo<TString>() const {
- switch (GetType()) {
+}
+
+template<>
+inline TString TNode::ConvertTo<TString>() const {
+ switch (GetType()) {
case NYT::TNode::String:
- return AsString();
+ return AsString();
case NYT::TNode::Int64:
- return ::ToString(AsInt64());
+ return ::ToString(AsInt64());
case NYT::TNode::Uint64:
- return ::ToString(AsUint64());
+ return ::ToString(AsUint64());
case NYT::TNode::Double:
- return ::ToString(AsDouble());
+ return ::ToString(AsDouble());
case NYT::TNode::Bool:
- return ::ToString(AsBool());
+ return ::ToString(AsBool());
case NYT::TNode::List:
case NYT::TNode::Map:
case NYT::TNode::Null:
case NYT::TNode::Undefined:
ythrow TTypeError() << "ConvertTo<TString>() called for type " << GetType();
- }
+ }
Y_UNREACHABLE();
-}
-
-template<>
-inline double TNode::ConvertTo<double>() const {
- switch (GetType()) {
+}
+
+template<>
+inline double TNode::ConvertTo<double>() const {
+ switch (GetType()) {
case NYT::TNode::String:
- return ::FromString(AsString());
+ return ::FromString(AsString());
case NYT::TNode::Int64:
- return AsInt64();
+ return AsInt64();
case NYT::TNode::Uint64:
- return AsUint64();
+ return AsUint64();
case NYT::TNode::Double:
- return AsDouble();
+ return AsDouble();
case NYT::TNode::Bool:
- return AsBool();
+ return AsBool();
case NYT::TNode::List:
case NYT::TNode::Map:
case NYT::TNode::Null:
case NYT::TNode::Undefined:
ythrow TTypeError() << "ConvertTo<double>() called for type " << GetType();
- }
-}
-
-template<>
-inline bool TNode::ConvertTo<bool>() const {
- switch (GetType()) {
+ }
+}
+
+template<>
+inline bool TNode::ConvertTo<bool>() const {
+ switch (GetType()) {
case NYT::TNode::String:
- return ::FromString(AsString());
+ return ::FromString(AsString());
case NYT::TNode::Int64:
- return AsInt64();
+ return AsInt64();
case NYT::TNode::Uint64:
- return AsUint64();
+ return AsUint64();
case NYT::TNode::Double:
- return AsDouble();
+ return AsDouble();
case NYT::TNode::Bool:
- return AsBool();
+ return AsBool();
case NYT::TNode::List:
case NYT::TNode::Map:
case NYT::TNode::Null:
case NYT::TNode::Undefined:
ythrow TTypeError() << "ConvertTo<bool>() called for type " << GetType();
- }
-}
-
-template<typename T>
-inline T TNode::ChildIntCast(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.IntCast<T>();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-template<typename T>
-inline T TNode::ChildIntCast(size_t index) const {
- const auto& node = At(index);
- try {
- return node.IntCast<T>();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-template<typename T>
-inline T TNode::ChildConvertTo(const TStringBuf key) const {
- const auto& node = At(key);
- try {
- return node.ConvertTo<T>();
- } catch (TTypeError& e) {
- e << ", during getting key=" << key;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
- }
-}
-
-template<typename T>
-inline T TNode::ChildConvertTo(size_t index) const {
- const auto& node = At(index);
- try {
- return node.ConvertTo<T>();
- } catch (TTypeError& e) {
- e << ", during getting index=" << index;
- throw e;
- } catch (...) {
- ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
- }
-}
-
-template<typename T>
+ }
+}
+
+template<typename T>
+inline T TNode::ChildIntCast(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.IntCast<T>();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+template<typename T>
+inline T TNode::ChildIntCast(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.IntCast<T>();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+template<typename T>
+inline T TNode::ChildConvertTo(const TStringBuf key) const {
+ const auto& node = At(key);
+ try {
+ return node.ConvertTo<T>();
+ } catch (TTypeError& e) {
+ e << ", during getting key=" << key;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting key=" << key;
+ }
+}
+
+template<typename T>
+inline T TNode::ChildConvertTo(size_t index) const {
+ const auto& node = At(index);
+ try {
+ return node.ConvertTo<T>();
+ } catch (TTypeError& e) {
+ e << ", during getting index=" << index;
+ throw e;
+ } catch (...) {
+ ythrow TTypeError() << CurrentExceptionMessage() << ", during getting index=" << index;
+ }
+}
+
+template<typename T>
inline const T& TNode::ChildAs(const TStringBuf key) const {
const auto& node = At(key);
try {
diff --git a/library/cpp/yson/node/node_io.cpp b/library/cpp/yson/node/node_io.cpp
index 294a7f7217..caaa3ac0ec 100644
--- a/library/cpp/yson/node/node_io.cpp
+++ b/library/cpp/yson/node/node_io.cpp
@@ -14,7 +14,7 @@
#include <util/stream/input.h>
#include <util/stream/output.h>
#include <util/stream/str.h>
-#include <util/stream/mem.h>
+#include <util/stream/mem.h>
namespace NYT {
@@ -84,7 +84,7 @@ static TNode CreateEmptyNodeByType(::NYson::EYsonType type)
TNode NodeFromYsonString(const TStringBuf input, ::NYson::EYsonType type)
{
- TMemoryInput stream(input);
+ TMemoryInput stream(input);
return NodeFromYsonStream(&stream, type);
}
@@ -126,9 +126,9 @@ void NodeToCanonicalYsonStream(const TNode& node, IOutputStream* output, NYson::
visitor.Visit(node);
}
-TNode NodeFromJsonString(const TStringBuf input)
+TNode NodeFromJsonString(const TStringBuf input)
{
- TMemoryInput stream(input);
+ TMemoryInput stream(input);
TNode result;
diff --git a/library/cpp/yson/node/node_io.h b/library/cpp/yson/node/node_io.h
index 2ad23b658f..c5d946fb8f 100644
--- a/library/cpp/yson/node/node_io.h
+++ b/library/cpp/yson/node/node_io.h
@@ -30,7 +30,7 @@ void NodeToYsonStream(const TNode& node, IOutputStream* output, ::NYson::EYsonFo
void NodeToCanonicalYsonStream(const TNode& node, IOutputStream* output, ::NYson::EYsonFormat format = ::NYson::EYsonFormat::Text);
// Parse TNode from string in JSON format
-TNode NodeFromJsonString(const TStringBuf input);
+TNode NodeFromJsonString(const TStringBuf input);
// Convert TJsonValue to TNode
TNode NodeFromJsonValue(const NJson::TJsonValue& input);
diff --git a/library/cpp/yson/node/node_ut.cpp b/library/cpp/yson/node/node_ut.cpp
index 448e99f575..6868953337 100644
--- a/library/cpp/yson/node/node_ut.cpp
+++ b/library/cpp/yson/node/node_ut.cpp
@@ -278,109 +278,109 @@ Y_UNIT_TEST_SUITE(YtNodeTest) {
UNIT_ASSERT_VALUES_EQUAL(node, nodeCopy);
}
-
+
Y_UNIT_TEST(TestIntCast) {
- TNode node = 1ull << 31;
- UNIT_ASSERT(node.IsUint64());
+ TNode node = 1ull << 31;
+ UNIT_ASSERT(node.IsUint64());
UNIT_ASSERT_EXCEPTION(node.IntCast<i32>(), TNode::TTypeError);
UNIT_ASSERT(node.IntCast<ui32>() == static_cast<ui32>(node.AsUint64()));
UNIT_ASSERT(node.IntCast<i64>() == static_cast<i64>(node.AsUint64()));
- UNIT_ASSERT(node.IntCast<ui64>() == node.AsUint64());
-
- node = 1ull << 63;
- UNIT_ASSERT(node.IsUint64());
- UNIT_ASSERT_EXCEPTION(node.IntCast<i64>(), TNode::TTypeError);
- UNIT_ASSERT(node.IntCast<ui64>() == node.AsUint64());
-
- node = 12345;
- UNIT_ASSERT(node.IsInt64());
+ UNIT_ASSERT(node.IntCast<ui64>() == node.AsUint64());
+
+ node = 1ull << 63;
+ UNIT_ASSERT(node.IsUint64());
+ UNIT_ASSERT_EXCEPTION(node.IntCast<i64>(), TNode::TTypeError);
+ UNIT_ASSERT(node.IntCast<ui64>() == node.AsUint64());
+
+ node = 12345;
+ UNIT_ASSERT(node.IsInt64());
UNIT_ASSERT_EXCEPTION(node.IntCast<i8>(), TNode::TTypeError);
UNIT_ASSERT_EXCEPTION(node.IntCast<ui8>(), TNode::TTypeError);
UNIT_ASSERT(node.IntCast<i16>() == static_cast<i16>(node.AsInt64()));
UNIT_ASSERT(node.IntCast<ui16>() == static_cast<ui16>(node.AsInt64()));
UNIT_ASSERT(node.IntCast<i32>() == static_cast<i32>(node.AsInt64()));
UNIT_ASSERT(node.IntCast<ui32>() == static_cast<ui32>(node.AsInt64()));
- UNIT_ASSERT(node.IntCast<i64>() == node.AsInt64());
- UNIT_ASSERT(node.IntCast<ui64>() == static_cast<ui64>(node.AsInt64()));
+ UNIT_ASSERT(node.IntCast<i64>() == node.AsInt64());
+ UNIT_ASSERT(node.IntCast<ui64>() == static_cast<ui64>(node.AsInt64()));
- node = -5;
- UNIT_ASSERT(node.IsInt64());
+ node = -5;
+ UNIT_ASSERT(node.IsInt64());
UNIT_ASSERT(node.IntCast<i8>() == static_cast<i8>(node.AsInt64()));
UNIT_ASSERT(node.IntCast<i16>() == static_cast<i16>(node.AsInt64()));
UNIT_ASSERT(node.IntCast<i32>() == static_cast<i32>(node.AsInt64()));
- UNIT_ASSERT(node.IntCast<i64>() == node.AsInt64());
+ UNIT_ASSERT(node.IntCast<i64>() == node.AsInt64());
UNIT_ASSERT_EXCEPTION(node.IntCast<ui8>(), TNode::TTypeError);
UNIT_ASSERT_EXCEPTION(node.IntCast<ui16>(), TNode::TTypeError);
UNIT_ASSERT_EXCEPTION(node.IntCast<ui32>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(node.IntCast<ui64>(), TNode::TTypeError);
- }
-
+ UNIT_ASSERT_EXCEPTION(node.IntCast<ui64>(), TNode::TTypeError);
+ }
+
Y_UNIT_TEST(TestConvertToString) {
- UNIT_ASSERT_VALUES_EQUAL(TNode(5).ConvertTo<TString>(), "5");
- UNIT_ASSERT_VALUES_EQUAL(TNode(123432423).ConvertTo<TString>(), "123432423");
- UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ll).ConvertTo<TString>(), "123456789012345678");
- UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ull).ConvertTo<TString>(), "123456789012345678");
- UNIT_ASSERT_VALUES_EQUAL(TNode(-123456789012345678ll).ConvertTo<TString>(), "-123456789012345678");
- UNIT_ASSERT_VALUES_EQUAL(TNode(true).ConvertTo<TString>(), "1");
- UNIT_ASSERT_VALUES_EQUAL(TNode(false).ConvertTo<TString>(), "0");
- UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<TString>(), "5.3");
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(TNode(5).ConvertTo<TString>(), "5");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(123432423).ConvertTo<TString>(), "123432423");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ll).ConvertTo<TString>(), "123456789012345678");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(123456789012345678ull).ConvertTo<TString>(), "123456789012345678");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(-123456789012345678ll).ConvertTo<TString>(), "-123456789012345678");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(true).ConvertTo<TString>(), "1");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(false).ConvertTo<TString>(), "0");
+ UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<TString>(), "5.3");
+ }
+
Y_UNIT_TEST(TestConvertFromString) {
- UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<ui64>(), 123456789012345678ull);
- UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<i64>(), 123456789012345678);
- UNIT_ASSERT_VALUES_EQUAL(TNode(ToString(1ull << 63)).ConvertTo<ui64>(), 1ull << 63);
- UNIT_ASSERT_EXCEPTION(TNode(ToString(1ull << 63)).ConvertTo<i64>(), TFromStringException);
- UNIT_ASSERT_VALUES_EQUAL(TNode("5.34").ConvertTo<double>(), 5.34);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<ui64>(), 123456789012345678ull);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("123456789012345678").ConvertTo<i64>(), 123456789012345678);
+ UNIT_ASSERT_VALUES_EQUAL(TNode(ToString(1ull << 63)).ConvertTo<ui64>(), 1ull << 63);
+ UNIT_ASSERT_EXCEPTION(TNode(ToString(1ull << 63)).ConvertTo<i64>(), TFromStringException);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("5.34").ConvertTo<double>(), 5.34);
+ }
+
Y_UNIT_TEST(TestConvertDoubleInt) {
UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i8>(), 5);
UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<ui8>(), 5);
UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<i64>(), 5);
- UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<ui64>(), 5);
+ UNIT_ASSERT_VALUES_EQUAL(TNode(5.3).ConvertTo<ui64>(), 5);
UNIT_ASSERT_VALUES_EQUAL(TNode(-5.3).ConvertTo<i8>(), -5);
- UNIT_ASSERT_VALUES_EQUAL(TNode(-5.3).ConvertTo<i64>(), -5);
+ UNIT_ASSERT_VALUES_EQUAL(TNode(-5.3).ConvertTo<i64>(), -5);
UNIT_ASSERT_EXCEPTION(TNode(-5.3).ConvertTo<ui8>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(TNode(-5.3).ConvertTo<ui64>(), TNode::TTypeError);
+ UNIT_ASSERT_EXCEPTION(TNode(-5.3).ConvertTo<ui64>(), TNode::TTypeError);
UNIT_ASSERT_VALUES_EQUAL(TNode(127.0).ConvertTo<i8>(), 127);
UNIT_ASSERT_EXCEPTION(TNode(128.0).ConvertTo<i8>(), TNode::TTypeError);
UNIT_ASSERT_VALUES_EQUAL(TNode(255.0).ConvertTo<ui8>(), 255);
UNIT_ASSERT_EXCEPTION(TNode(256.0).ConvertTo<ui8>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<i64>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<ui64>(), TNode::TTypeError);
- {
+ UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<i64>(), TNode::TTypeError);
+ UNIT_ASSERT_EXCEPTION(TNode(1e100).ConvertTo<ui64>(), TNode::TTypeError);
+ {
double v = 1ull << 63;
- TNode node = v;
- UNIT_ASSERT(node.IsDouble());
- UNIT_ASSERT_EXCEPTION(node.ConvertTo<i64>(), TNode::TTypeError);
- UNIT_ASSERT_VALUES_EQUAL(node.ConvertTo<ui64>(), static_cast<ui64>(v));
- }
- {
- double v = (double)(1ull << 63) + (1ull << 63);
- TNode node = v;
- UNIT_ASSERT(node.IsDouble());
- UNIT_ASSERT_EXCEPTION(node.ConvertTo<i64>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(node.ConvertTo<ui64>(), TNode::TTypeError);
- }
- UNIT_ASSERT_EXCEPTION(TNode(NAN).ConvertTo<ui64>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(TNode(NAN).ConvertTo<i64>(), TNode::TTypeError);
-
- UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<ui64>(), TNode::TTypeError);
- UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<i64>(), TNode::TTypeError);
- }
-
+ TNode node = v;
+ UNIT_ASSERT(node.IsDouble());
+ UNIT_ASSERT_EXCEPTION(node.ConvertTo<i64>(), TNode::TTypeError);
+ UNIT_ASSERT_VALUES_EQUAL(node.ConvertTo<ui64>(), static_cast<ui64>(v));
+ }
+ {
+ double v = (double)(1ull << 63) + (1ull << 63);
+ TNode node = v;
+ UNIT_ASSERT(node.IsDouble());
+ UNIT_ASSERT_EXCEPTION(node.ConvertTo<i64>(), TNode::TTypeError);
+ UNIT_ASSERT_EXCEPTION(node.ConvertTo<ui64>(), TNode::TTypeError);
+ }
+ UNIT_ASSERT_EXCEPTION(TNode(NAN).ConvertTo<ui64>(), TNode::TTypeError);
+ UNIT_ASSERT_EXCEPTION(TNode(NAN).ConvertTo<i64>(), TNode::TTypeError);
+
+ UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<ui64>(), TNode::TTypeError);
+ UNIT_ASSERT_EXCEPTION(TNode(INFINITY).ConvertTo<i64>(), TNode::TTypeError);
+ }
+
Y_UNIT_TEST(TestConvertToBool) {
- UNIT_ASSERT_VALUES_EQUAL(TNode("true").ConvertTo<bool>(), true);
- UNIT_ASSERT_VALUES_EQUAL(TNode("TRUE").ConvertTo<bool>(), true);
- UNIT_ASSERT_VALUES_EQUAL(TNode("false").ConvertTo<bool>(), false);
- UNIT_ASSERT_VALUES_EQUAL(TNode("FALSE").ConvertTo<bool>(), false);
- UNIT_ASSERT_VALUES_EQUAL(TNode(1).ConvertTo<bool>(), true);
- UNIT_ASSERT_VALUES_EQUAL(TNode(0).ConvertTo<bool>(), false);
- UNIT_ASSERT_EXCEPTION(TNode("random").ConvertTo<bool>(), TFromStringException);
- UNIT_ASSERT_EXCEPTION(TNode("").ConvertTo<bool>(), TFromStringException);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("true").ConvertTo<bool>(), true);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("TRUE").ConvertTo<bool>(), true);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("false").ConvertTo<bool>(), false);
+ UNIT_ASSERT_VALUES_EQUAL(TNode("FALSE").ConvertTo<bool>(), false);
+ UNIT_ASSERT_VALUES_EQUAL(TNode(1).ConvertTo<bool>(), true);
+ UNIT_ASSERT_VALUES_EQUAL(TNode(0).ConvertTo<bool>(), false);
+ UNIT_ASSERT_EXCEPTION(TNode("random").ConvertTo<bool>(), TFromStringException);
+ UNIT_ASSERT_EXCEPTION(TNode("").ConvertTo<bool>(), TFromStringException);
}
Y_UNIT_TEST(TestCanonicalSerialization) {
@@ -395,7 +395,7 @@ Y_UNIT_TEST_SUITE(YtNodeTest) {
"{\"i\"=\"i\";\"ii\"=\"ii\";\"jj\"=\"jj\"};"
"\"c\"=\"c\";\"ca\"=\"ca\"}");
}
-
+
Y_UNIT_TEST(OperatorEqualSubnode) {
TNode node;
node["a"]["b"] = "c";
@@ -406,79 +406,79 @@ Y_UNIT_TEST_SUITE(YtNodeTest) {
UNIT_ASSERT_VALUES_EQUAL(node.AsString(), "c");
}
- Y_UNIT_TEST(TestMapGetters) {
- auto node = TNode::CreateMap()
- ("string", "7")
- ("int64", 3)
- ("uint64", 5u)
- ("double", -3.5)
- ("list", TNode::CreateList().Add(5))
- ("map", TNode::CreateMap()("key", "value"));
+ Y_UNIT_TEST(TestMapGetters) {
+ auto node = TNode::CreateMap()
+ ("string", "7")
+ ("int64", 3)
+ ("uint64", 5u)
+ ("double", -3.5)
+ ("list", TNode::CreateList().Add(5))
+ ("map", TNode::CreateMap()("key", "value"));
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TString>("string"), "7");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsString("string"), "7");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<i64>("string"), 7);
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsString("string"), "7");
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<i64>("string"), 7);
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<i64>("int64"), 3);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsInt64("int64"), 3);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<ui64>("int64"), 3u);
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsInt64("int64"), 3);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<ui64>("int64"), 3u);
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<ui64>("uint64"), 5u);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsUint64("uint64"), 5u);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<i64>("uint64"), 5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>("uint64"), "5");
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsUint64("uint64"), 5u);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<i64>("uint64"), 5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>("uint64"), "5");
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<double>("double"), -3.5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsDouble("double"), -3.5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>("double"), "-3.5");
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsDouble("double"), -3.5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>("double"), "-3.5");
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TNode::TListType>("list")[0].AsInt64(), 5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsList("list")[0].AsInt64(), 5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsList("list")[0].AsInt64(), 5);
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TNode::TMapType>("map")["key"].AsString(), "value");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsMap("map")["key"].AsString(), "value");
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsMap("map")["key"].AsString(), "value");
// mutable accessor
auto& childString = node.ChildAs<TString>("string");
childString = "yaddayadda";
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TString>("string"), "yaddayadda");
- }
-
- Y_UNIT_TEST(TestListGetters) {
- auto node = TNode::CreateList()
- .Add("7")
- .Add(3)
- .Add(5u)
- .Add(-3.5)
- .Add(TNode::CreateList().Add(5))
- .Add(TNode::CreateMap()("key", "value"));
+ }
+
+ Y_UNIT_TEST(TestListGetters) {
+ auto node = TNode::CreateList()
+ .Add("7")
+ .Add(3)
+ .Add(5u)
+ .Add(-3.5)
+ .Add(TNode::CreateList().Add(5))
+ .Add(TNode::CreateMap()("key", "value"));
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TString>(0), "7");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsString(0), "7");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<i64>(0), 7);
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsString(0), "7");
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<i64>(0), 7);
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<i64>(1), 3);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsInt64(1), 3);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<ui64>(1), 3u);
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsInt64(1), 3);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<ui64>(1), 3u);
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<ui64>(2), 5u);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsUint64(2), 5u);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<i64>(2), 5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>(2), "5");
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsUint64(2), 5u);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildIntCast<i64>(2), 5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>(2), "5");
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<double>(3), -3.5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsDouble(3), -3.5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>(3), "-3.5");
-
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsDouble(3), -3.5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildConvertTo<TString>(3), "-3.5");
+
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TNode::TListType>(4)[0].AsInt64(), 5);
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsList(4)[0].AsInt64(), 5);
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsList(4)[0].AsInt64(), 5);
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TNode::TMapType>(5)["key"].AsString(), "value");
- UNIT_ASSERT_VALUES_EQUAL(node.ChildAsMap(5)["key"].AsString(), "value");
+ UNIT_ASSERT_VALUES_EQUAL(node.ChildAsMap(5)["key"].AsString(), "value");
// mutable accessor
auto& childString = node.ChildAs<TString>(0);
childString = "yaddayadda";
UNIT_ASSERT_VALUES_EQUAL(node.ChildAs<TString>(0), "yaddayadda");
- }
+ }
}
diff --git a/library/python/testing/import_test/import_test.py b/library/python/testing/import_test/import_test.py
index 3e3b7234ef..0eb13bc41c 100644
--- a/library/python/testing/import_test/import_test.py
+++ b/library/python/testing/import_test/import_test.py
@@ -90,7 +90,7 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):
for m, t in sorted(import_times.items(), key=lambda x: x[1], reverse=True)[:30]:
print(' ', '{:.3f}s'.format(t), m)
- if failed:
+ if failed:
raise ImportError('modules not imported:\n' + '\n'.join(failed))