From aae4fa238fba26bd00124b7afa697366a5fffbf0 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 6 May 2023 12:53:25 +0300 Subject: [PATCH] Add << operators for vectors & sets in tests --- tools/test/include/psemek/test/test.hpp | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/test/include/psemek/test/test.hpp b/tools/test/include/psemek/test/test.hpp index 9ce12894..5d439d4f 100644 --- a/tools/test/include/psemek/test/test.hpp +++ b/tools/test/include/psemek/test/test.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,38 @@ std::ostream & operator << (std::ostream & s, std::tuple const & t) return s; } +template +std::ostream & operator << (std::ostream & s, std::vector const & v) +{ + s << "["; + bool first = true; + for (auto const & x : v) + { + if (!first) + s << ", "; + first = false; + s << x; + } + s << "]"; + return s; +} + +template +std::ostream & operator << (std::ostream & s, std::set const & v) +{ + s << "{"; + bool first = true; + for (auto const & x : v) + { + if (!first) + s << ", "; + first = false; + s << x; + } + s << "}"; + return s; +} + namespace psemek::util {