Files
Bigfoot/Bigfoot/Tests/Utils/Log/Log.cpp
Romain BOULLARD b867701d2a
All checks were successful
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m26s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m20s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m42s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m45s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m48s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m56s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m2s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m51s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m29s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m31s
Bigfoot / Clang Format Checks (push) Successful in 10s
SlotMaps
2026-05-14 01:54:38 +02:00

139 lines
4.0 KiB
C++

/*********************************************************************
* \file Log.cpp
*
* \author Romain BOULLARD
* \date December 2022
*********************************************************************/
#include <Utils/Log/Log.hpp>
#include <Utils/Singleton.hpp>
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <gtest/gtest.h>
namespace Bigfoot
{
class LogFixture: public ::testing::Test
{
protected:
void SetUp() override
{
UTILSTESTS_LOGGER = {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
}
static constexpr Flat::LogLevel QuillLogLevelToLogLevel(const quill::LogLevel p_level)
{
switch (p_level)
{
case quill::LogLevel::Debug:
return Flat::LogLevel::Debug;
case quill::LogLevel::TraceL3:
return Flat::LogLevel::Trace;
case quill::LogLevel::Info:
return Flat::LogLevel::Info;
case quill::LogLevel::Warning:
return Flat::LogLevel::Warn;
case quill::LogLevel::Error:
return Flat::LogLevel::Error;
case quill::LogLevel::Critical:
return Flat::LogLevel::Critical;
default:
break;
}
return Flat::LogLevel::Trace;
}
Log m_log;
};
/****************************************************************************************/
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
{
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
EXPECT_TRUE(logger);
EXPECT_EQ(logger, m_log.GetLogger(UTILSTESTS_LOGGER));
EXPECT_EQ(logger->get_logger_name(), UTILSTESTS_LOGGER.m_name);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), UTILSTESTS_LOGGER.m_level);
}
/****************************************************************************************/
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
{
EXPECT_FALSE(m_log.GetLogger(UTILSTESTS_LOGGER));
}
/****************************************************************************************/
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
{
[[maybe_unused]]
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
EXPECT_TRUE(m_log.GetLogger(UTILSTESTS_LOGGER));
}
/****************************************************************************************/
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
{
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
m_log.ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), Flat::LogLevel::Critical);
}
/****************************************************************************************/
TEST_F(LogFixture, LogDebug)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogTrace)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogInfo)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogWarn)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogError)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogFatal)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello");
}
} // namespace Bigfoot
#endif