From e813513c43eebe2efb9f56aad685284d6df2538d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 25 Jan 2024 00:31:15 +0100 Subject: [PATCH] TESTS WIP --- nano/core_test/object_stream.cpp | 57 ++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/nano/core_test/object_stream.cpp b/nano/core_test/object_stream.cpp index 8cdf223470..877effa0ad 100644 --- a/nano/core_test/object_stream.cpp +++ b/nano/core_test/object_stream.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -313,24 +314,54 @@ TEST (object_stream, fmt_adapter) std::cout << std::endl; } -TEST (trace_logging, no_copy) +namespace +{ +struct no_copyable { - struct no_copyable + no_copyable () = default; + no_copyable (no_copyable const &) = delete; + no_copyable (no_copyable &&) = default; + no_copyable & operator= (no_copyable const &) = delete; + no_copyable & operator= (no_copyable &&) = default; + + friend std::ostream & operator<< (std::ostream & os, no_copyable const & nc) { - no_copyable () = default; - no_copyable (no_copyable const &) = delete; - no_copyable (no_copyable &&) = default; - no_copyable & operator= (no_copyable const &) = delete; - no_copyable & operator= (no_copyable &&) = default; - - void operator() (nano::object_stream & obs) const - { - obs.write ("test", "test"); - } - }; + os << "no_copyable"; + return os; + } +}; +} +TEST (trace_logging, no_copy) +{ no_copyable nc; nano::logger logger; logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "no_copyable", nc }); +} + +namespace +{ +struct no_moveable +{ + no_moveable () = default; + no_moveable (no_moveable const &) = delete; + no_moveable (no_moveable &&) = delete; + no_moveable & operator= (no_moveable const &) = delete; + no_moveable & operator= (no_moveable &&) = delete; + + friend std::ostream & operator<< (std::ostream & os, no_moveable const & nm) + { + os << "no_moveable"; + return os; + } +}; +} + +TEST (trace_logging, no_move) +{ + no_moveable nm; + + nano::logger logger; + logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "no_moveable", nm }); } \ No newline at end of file