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 dce2456 commit 5b3ee40
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 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 non_copyable
{
struct no_copyable
non_copyable () = default;
non_copyable (non_copyable const &) = delete;
non_copyable (non_copyable &&) = default;
non_copyable & operator= (non_copyable const &) = delete;
non_copyable & operator= (non_copyable &&) = default;

friend std::ostream & operator<< (std::ostream & os, non_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;
os << "non_copyable";
return os;
}
};
}

TEST (trace_logging, no_copy)
{
non_copyable nc;

nano::logger logger;
logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "non_copyable", nc });
}

void operator() (nano::object_stream & obs) const
{
obs.write ("test", "test");
}
};
namespace
{
struct non_moveable
{
non_moveable () = default;
non_moveable (non_moveable const &) = delete;
non_moveable (non_moveable &&) = delete;
non_moveable & operator= (non_moveable const &) = delete;
non_moveable & operator= (non_moveable &&) = delete;

no_copyable nc;
friend std::ostream & operator<< (std::ostream & os, non_moveable const & nm)
{
os << "non_moveable";
return os;
}
};
}

TEST (trace_logging, no_move)
{
non_moveable nm;

nano::logger logger;
logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "no_copyable", nc });
logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "non_moveable", nm });
}

0 comments on commit 5b3ee40

Please sign in to comment.