aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2023-08-28 22:21:54 +0300
committerermolovd <ermolovd@yandex-team.com>2023-08-28 22:44:55 +0300
commit83bf33d776ac03c37162fa324f659ce191776308 (patch)
tree16966b29a44f381f6826db46853ebd322079df9c /library/cpp
parent01a8c93d0ab16426d212c53c52909af403b1c744 (diff)
downloadydb-83bf33d776ac03c37162fa324f659ce191776308.tar.gz
Pretty printing for TNode
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/yson/node/node.cpp14
-rw-r--r--library/cpp/yson/node/node.h3
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();
}