From f2e2ff464d311b7a6a3ee2e070012dc432dc54e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 26 Jan 2024 00:08:55 +0100 Subject: [PATCH] PARSE TESTS WIP --- nano/core_test/CMakeLists.txt | 2 +- nano/core_test/logger.cpp | 16 ----------- nano/core_test/logging.cpp | 50 +++++++++++++++++++++++++++++++++++ nano/lib/logging_enums.hpp | 2 -- 4 files changed, 51 insertions(+), 19 deletions(-) delete mode 100644 nano/core_test/logger.cpp create mode 100644 nano/core_test/logging.cpp diff --git a/nano/core_test/CMakeLists.txt b/nano/core_test/CMakeLists.txt index 623e6f2601..d5fa7563b5 100644 --- a/nano/core_test/CMakeLists.txt +++ b/nano/core_test/CMakeLists.txt @@ -26,7 +26,7 @@ add_executable( ipc.cpp ledger.cpp locks.cpp - logger.cpp + logging.cpp message.cpp message_deserializer.cpp memory_pool.cpp diff --git a/nano/core_test/logger.cpp b/nano/core_test/logger.cpp deleted file mode 100644 index a282736058..0000000000 --- a/nano/core_test/logger.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -#include -#include - -#include - -#include -#include -#include - -using namespace std::chrono_literals; - -TEST (logger, basic) -{ - // TODO -} diff --git a/nano/core_test/logging.cpp b/nano/core_test/logging.cpp new file mode 100644 index 0000000000..9c1cea1192 --- /dev/null +++ b/nano/core_test/logging.cpp @@ -0,0 +1,50 @@ +#include +#include + +#include + +using namespace std::chrono_literals; + +TEST (log_parse, parse_level) +{ + ASSERT_EQ (nano::log::parse_level ("error"), nano::log::level::error); + ASSERT_EQ (nano::log::parse_level ("off"), nano::log::level::off); + ASSERT_THROW (nano::log::parse_level ("invalid"), std::invalid_argument); + ASSERT_THROW (nano::log::parse_level (""), std::invalid_argument); + ASSERT_THROW (nano::log::parse_level ("_error"), std::invalid_argument); +} + +TEST (log_parse, parse_type) +{ + ASSERT_EQ (nano::log::parse_type ("node"), nano::log::type::node); + ASSERT_THROW (nano::log::parse_type ("invalid"), std::invalid_argument); + ASSERT_THROW (nano::log::parse_type (""), std::invalid_argument); + ASSERT_THROW (nano::log::parse_type ("_node"), std::invalid_argument); +} + +TEST (log_parse, parse_detail) +{ + ASSERT_EQ (nano::log::parse_detail ("all"), nano::log::detail::all); + ASSERT_EQ (nano::log::parse_detail ("process_confirmed"), nano::log::detail::process_confirmed); + ASSERT_THROW (nano::log::parse_detail ("invalid"), std::invalid_argument); + ASSERT_THROW (nano::log::parse_detail (""), std::invalid_argument); + ASSERT_THROW (nano::log::parse_detail ("_all"), std::invalid_argument); +} + +TEST (log_parse, parse_logger_id) +{ + ASSERT_EQ (nano::log_config::parse_logger_id ("node"), std::make_pair (nano::log::type::node, nano::log::detail::all)); + ASSERT_EQ (nano::log_config::parse_logger_id ("node::all"), std::make_pair (nano::log::type::node, nano::log::detail::all)); + ASSERT_EQ (nano::log_config::parse_logger_id ("node::process_confirmed"), std::make_pair (nano::log::type::node, nano::log::detail::process_confirmed)); + ASSERT_THROW (nano::log_config::parse_logger_id ("node::invalid"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("node::"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("node::_all"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("node::_process_confirmed"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("invalid"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("invalid."), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("invalid._all"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("invalid._process_confirmed"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("::"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id ("::all"), std::invalid_argument); + ASSERT_THROW (nano::log_config::parse_logger_id (""), std::invalid_argument); +} \ No newline at end of file diff --git a/nano/lib/logging_enums.hpp b/nano/lib/logging_enums.hpp index af2ebfda84..95b27f2bd3 100644 --- a/nano/lib/logging_enums.hpp +++ b/nano/lib/logging_enums.hpp @@ -21,8 +21,6 @@ enum class level enum class type { - all = 0, // reserved - generic, init, config,