ermolovd 1 год назад
Родитель
Сommit
83bf33d776
2 измененных файлов с 17 добавлено и 0 удалено
  1. 14 0
      library/cpp/yson/node/node.cpp
  2. 3 0
      library/cpp/yson/node/node.h

+ 14 - 0
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

+ 3 - 0
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();
 }