Skip to content

Commit

Permalink
TESTS WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 24, 2024
1 parent 59ce1b4 commit e813513
Showing 1 changed file with 44 additions and 13 deletions.
57 changes: 44 additions & 13 deletions nano/core_test/object_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <chrono>
#include <cstdint>
#include <limits>
#include <ostream>
#include <thread>

#include <fmt/printf.h>
Expand Down Expand Up @@ -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 });
}

0 comments on commit e813513

Please sign in to comment.