Move all pretty printers to pretty_printers.hpp
Next step is to get rid of std extensions.
Change-Id: Ib24c66521e6e7899cf2dae159d01e11f13622631
diff --git a/tests/data_query.cpp b/tests/data_query.cpp
index 5bc3222..5adc661 100644
--- a/tests/data_query.cpp
+++ b/tests/data_query.cpp
@@ -17,26 +17,10 @@
#error "Unknown backend"
#endif
#include "data_query.hpp"
+#include "pretty_printers.hpp"
#include "sysrepo_subscription.hpp"
#include "utils.hpp"
-namespace std {
-std::ostream& operator<<(std::ostream& s, const std::vector<ListInstance> set)
-{
- s << std::endl << "{" << std::endl;
- std::transform(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", \n"), [](const auto& map) {
- std::ostringstream ss;
- ss << " {" << std::endl << " ";
- std::transform(map.begin(), map.end(), std::experimental::make_ostream_joiner(ss, ", \n "), [](const auto& keyValue){
- return "{" + keyValue.first + "{" + boost::core::demangle(keyValue.second.type().name()) + "}" + ", " + leafDataToString(keyValue.second) + "}";
- });
- ss << std::endl << " }";
- return ss.str();
- });
- s << std::endl << "}" << std::endl;
- return s;
-}
-}
TEST_CASE("data query")
{
diff --git a/tests/keyvalue_completion.cpp b/tests/keyvalue_completion.cpp
index 61e90cd..b725dff2 100644
--- a/tests/keyvalue_completion.cpp
+++ b/tests/keyvalue_completion.cpp
@@ -11,17 +11,9 @@
#include "ast_commands.hpp"
#include "datastoreaccess_mock.hpp"
#include "parser.hpp"
+#include "pretty_printers.hpp"
#include "static_schema.hpp"
-namespace std {
-std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
-{
- s << std::endl << "{";
- std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
- s << "}" << std::endl;
- return s;
-}
-}
TEST_CASE("keyvalue_completion")
{
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index ca5c8d6..76e26d3 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -11,14 +11,10 @@
#include "ast_commands.hpp"
#include "leaf_data_helpers.hpp"
#include "parser.hpp"
+#include "pretty_printers.hpp"
#include "static_schema.hpp"
#include "utils.hpp"
-std::ostream& operator<<(std::ostream& s, const set_ cmd)
-{
- return s << "Command SET {path: " << pathToSchemaString(cmd.m_path, Prefixes::Always) << ", type " << boost::core::demangle(cmd.m_data.type().name()) << ", data: " << leafDataToString(cmd.m_data) << "}";
-}
-
TEST_CASE("leaf editing")
{
auto schema = std::make_shared<StaticSchema>();
diff --git a/tests/pretty_printers.hpp b/tests/pretty_printers.hpp
index 69c06f5..5b747a1 100644
--- a/tests/pretty_printers.hpp
+++ b/tests/pretty_printers.hpp
@@ -6,6 +6,7 @@
*/
#include <experimental/iterator>
+#include <sstream>
#include "parser.hpp"
#include "utils.hpp"
namespace std {
@@ -107,6 +108,29 @@
return s;
}
+std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
+{
+ s << std::endl << "{";
+ std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
+ s << "}" << std::endl;
+ return s;
+}
+
+std::ostream& operator<<(std::ostream& s, const std::vector<ListInstance> set)
+{
+ s << std::endl << "{" << std::endl;
+ std::transform(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", \n"), [](const auto& map) {
+ std::ostringstream ss;
+ ss << " {" << std::endl << " ";
+ std::transform(map.begin(), map.end(), std::experimental::make_ostream_joiner(ss, ", \n "), [](const auto& keyValue){
+ return "{" + keyValue.first + "{" + boost::core::demangle(keyValue.second.type().name()) + "}" + ", " + leafDataToString(keyValue.second) + "}";
+ });
+ ss << std::endl << " }";
+ return ss.str();
+ });
+ s << std::endl << "}" << std::endl;
+ return s;
+}
}
std::ostream& operator<<(std::ostream& s, const boost::variant<dataPath_, schemaPath_, module_>& path)
@@ -170,3 +194,8 @@
s << "\n}\n";
return s;
}
+
+std::ostream& operator<<(std::ostream& s, const set_ cmd)
+{
+ return s << "Command SET {path: " << pathToSchemaString(cmd.m_path, Prefixes::Always) << ", type " << boost::core::demangle(cmd.m_data.type().name()) << ", data: " << leafDataToString(cmd.m_data) << "}";
+}
diff --git a/tests/yang.cpp b/tests/yang.cpp
index dd7a031..f50d76e 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -424,16 +424,6 @@
}
})";
-namespace std {
-std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
-{
- s << std::endl << "{";
- std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
- s << "}" << std::endl;
- return s;
-}
-}
-
TEST_CASE("yangschema")
{
using namespace std::string_literals;