Skip to content

Commit

Permalink
LOGGING TESTS WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 26, 2024
1 parent 24e42c7 commit 5f07530
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
54 changes: 54 additions & 0 deletions nano/core_test/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,62 @@

#include <gtest/gtest.h>

#include <ostream>

using namespace std::chrono_literals;

namespace
{
struct non_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)
{
os << "non_copyable";
return os;
}
};
}

TEST (tracing, no_copy)
{
non_copyable nc;

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

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;

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

TEST (tracing, no_move)
{
non_moveable nm;

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

TEST (log_parse, parse_level)
{
ASSERT_EQ (nano::log::parse_level ("error"), nano::log::level::error);
Expand Down
22 changes: 0 additions & 22 deletions nano/core_test/object_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,25 +312,3 @@ TEST (object_stream, fmt_adapter)
// Spacing
std::cout << std::endl;
}

TEST (trace_logging, no_copy)
{
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;

void operator() (nano::object_stream & obs) const
{
obs.write ("test", "test");
}
};

no_copyable nc;

nano::logger logger;
logger.trace (nano::log::type::all, nano::log::detail::all, nano::log::arg{ "no_copyable", nc });
}
3 changes: 3 additions & 0 deletions nano/lib/logging_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum class type
all = 0, // reserved

generic,
test,
init,
config,
logging,
Expand Down Expand Up @@ -90,6 +91,8 @@ enum class detail
{
all = 0, // reserved

test,

// node
process_confirmed,

Expand Down

0 comments on commit 5f07530

Please sign in to comment.