diff options
author | ermolovd <ermolovd@yandex-team.com> | 2023-08-28 22:21:54 +0300 |
---|---|---|
committer | ermolovd <ermolovd@yandex-team.com> | 2023-08-28 22:44:55 +0300 |
commit | 83bf33d776ac03c37162fa324f659ce191776308 (patch) | |
tree | 16966b29a44f381f6826db46853ebd322079df9c /library/cpp | |
parent | 01a8c93d0ab16426d212c53c52909af403b1c744 (diff) | |
download | ydb-83bf33d776ac03c37162fa324f659ce191776308.tar.gz |
Pretty printing for TNode
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/yson/node/node.cpp | 14 | ||||
-rw-r--r-- | library/cpp/yson/node/node.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/library/cpp/yson/node/node.cpp b/library/cpp/yson/node/node.cpp index b39e0707187..3733c3cae2d 100644 --- a/library/cpp/yson/node/node.cpp +++ b/library/cpp/yson/node/node.cpp @@ -5,6 +5,9 @@ #include <library/cpp/yson/writer.h> #include <util/generic/overloaded.h> +#include <util/string/escape.h> + +#include <iostream> namespace NYT { @@ -910,6 +913,17 @@ bool GetBool(const TNode& node) } } +void PrintTo(const TNode& node, std::ostream* out) +{ + if (node.IsUndefined()) { + (*out) << "NYT::TNode::Undefined"; + } else { + (*out) << "NYT::TNode(" + << NodeToCanonicalYsonString(node) + << ")"; + } +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT diff --git a/library/cpp/yson/node/node.h b/library/cpp/yson/node/node.h index 5f90f95df07..05459ed4724 100644 --- a/library/cpp/yson/node/node.h +++ b/library/cpp/yson/node/node.h @@ -290,6 +290,9 @@ bool operator!=(const TNode& lhs, const TNode& rhs); bool GetBool(const TNode& node); +/// Debug printer for gtest +void PrintTo(const TNode& node, std::ostream* out); + inline bool TNode::IsArithmetic() const { return IsInt64() || IsUint64() || IsDouble() || IsBool(); } |