Compare commits
9 Commits
00b86fbd00
...
BigFile
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f02f47ee4 | |||
| 8685f3d1dd | |||
| 3fe5c31fc0 | |||
| 8996adec61 | |||
| 2003121d07 | |||
| 902ef87e1d | |||
| 9bea52973b | |||
| a343d65598 | |||
| bb279bb212 |
@@ -227,12 +227,11 @@ void Iterate(benchmark::State& state)
|
||||
state.SetItemsProcessed(state.iterations() * count);
|
||||
}
|
||||
|
||||
// Register all four benchmarks for one container adapter under a readable name.
|
||||
#define BIGFOOT_REGISTER_BENCHMARKS(ADAPTOR, NAME) \
|
||||
BENCHMARK_TEMPLATE(Insert, ADAPTOR)->Name(NAME "/Insert")->Range(8, 8 << 20); \
|
||||
BENCHMARK_TEMPLATE(Remove, ADAPTOR)->Name(NAME "/Remove")->Range(8, 8 << 20); \
|
||||
BENCHMARK_TEMPLATE(Get, ADAPTOR)->Name(NAME "/Get")->Range(8, 8 << 20); \
|
||||
BENCHMARK_TEMPLATE(Iterate, ADAPTOR)->Name(NAME "/Iterate")->Range(8, 8 << 20)
|
||||
BENCHMARK_TEMPLATE(Insert, ADAPTOR)->Name(NAME "/Insert")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
|
||||
BENCHMARK_TEMPLATE(Remove, ADAPTOR)->Name(NAME "/Remove")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
|
||||
BENCHMARK_TEMPLATE(Get, ADAPTOR)->Name(NAME "/Get")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
|
||||
BENCHMARK_TEMPLATE(Iterate, ADAPTOR)->Name(NAME "/Iterate")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304);
|
||||
|
||||
using UnorderedDenseMapHarness = HashMapHarnessAdaptor<ankerl::unordered_dense::map<std::uint64_t, MyComplexStruct>>;
|
||||
using UnorderedDenseSegementedMapHarness =
|
||||
@@ -247,4 +246,5 @@ BIGFOOT_REGISTER_BENCHMARKS(UnorderedMapHarness, "std::unordered_map");
|
||||
BIGFOOT_REGISTER_BENCHMARKS(MapHarness, "std::map");
|
||||
|
||||
#undef BIGFOOT_REGISTER_BENCHMARKS
|
||||
#undef BIGFOOT_CACHE_TIER_ARGS
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -29,9 +29,7 @@ class Asset
|
||||
.name = eastl::string {},
|
||||
.type_id = GetTypeID(),
|
||||
.type_name = eastl::string {GetTypeName()},
|
||||
.version = 0}),
|
||||
m_hardRefCount(0),
|
||||
m_softRefCount(0)
|
||||
.version = 0})
|
||||
{
|
||||
}
|
||||
|
||||
@@ -127,9 +125,6 @@ class Asset
|
||||
private:
|
||||
::Flat::Bigfoot::AssetHeaderT m_header;
|
||||
typename FLAT_ASSET::NativeTableType m_asset;
|
||||
|
||||
std::uint32_t m_hardRefCount;
|
||||
std::uint32_t m_softRefCount;
|
||||
};
|
||||
} // namespace Bigfoot
|
||||
|
||||
|
||||
@@ -34,17 +34,33 @@ class UUID
|
||||
UUID(const UUID& p_uuid) = default;
|
||||
UUID(UUID&& p_uuid) noexcept = default;
|
||||
|
||||
/**
|
||||
* Gets the raw bytes of a UUID
|
||||
*
|
||||
* \return A view to the raw bytes
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::span<const std::byte, UUID_BYTE_SIZE> ToBytes() const;
|
||||
|
||||
/**
|
||||
* Gets the string representation of a UUID
|
||||
*
|
||||
* \return A string representing the UUID
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::string ToString() const;
|
||||
|
||||
~UUID() = default;
|
||||
|
||||
operator std::span<const std::byte, UUID_BYTE_SIZE>() const;
|
||||
operator std::string() const;
|
||||
operator bool() const;
|
||||
|
||||
UUID& operator=(const UUID& p_uuid) = default;
|
||||
UUID& operator=(UUID&& p_uuid) noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
auto operator<=>(const UUID& p_uuid) const = default;
|
||||
bool operator==(const UUID& p_uuid) const;
|
||||
[[nodiscard]]
|
||||
bool operator<(const UUID& p_uuid) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -109,7 +125,7 @@ struct std::formatter<Bigfoot::UUID, char>
|
||||
template<typename FormatContext>
|
||||
auto format(const Bigfoot::UUID& p_uuid, FormatContext& ctx) const
|
||||
{
|
||||
return std::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
|
||||
return std::format_to(ctx.out(), "{}", p_uuid.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -128,7 +144,7 @@ struct fmtquill::formatter<Bigfoot::UUID>
|
||||
|
||||
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
||||
{
|
||||
return fmtquill::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
|
||||
return fmtquill::format_to(ctx.out(), "{}", p_uuid.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,14 +43,14 @@ UUID::UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::operator std::span<const std::byte, UUID::UUID_BYTE_SIZE>() const
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> UUID::ToBytes() const
|
||||
{
|
||||
return m_uuid.as_bytes();
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::operator std::string() const
|
||||
std::string UUID::ToString() const
|
||||
{
|
||||
return uuids::to_string(m_uuid);
|
||||
}
|
||||
@@ -62,6 +62,18 @@ UUID::operator bool() const
|
||||
return *this != NULL_UUID;
|
||||
}
|
||||
|
||||
bool UUID::operator==(const UUID& p_uuid) const
|
||||
{
|
||||
return m_uuid == p_uuid.m_uuid;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
bool UUID::operator<(const UUID& p_uuid) const
|
||||
{
|
||||
return m_uuid < p_uuid.m_uuid;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::mt19937 UUID::GetRandomGenerator()
|
||||
@@ -87,7 +99,7 @@ namespace flatbuffers
|
||||
{
|
||||
Flat::Bigfoot::UUID Pack(const Bigfoot::UUID& p_uuid)
|
||||
{
|
||||
const std::span<const std::byte, Bigfoot::UUID::UUID_BYTE_SIZE> bytes = p_uuid;
|
||||
const std::span<const std::byte, Bigfoot::UUID::UUID_BYTE_SIZE> bytes = p_uuid.ToBytes();
|
||||
return Flat::Bigfoot::UUID {
|
||||
std::span<const std::uint8_t, Bigfoot::UUID::UUID_BYTE_SIZE> {reinterpret_cast<const std::uint8_t*>(bytes.data()),
|
||||
bytes.size()}};
|
||||
|
||||
@@ -145,8 +145,8 @@ class SlotMap
|
||||
[[nodiscard]]
|
||||
bool Has(const SlotKey p_slotKey) const
|
||||
{
|
||||
return p_slotKey.Valid() &&
|
||||
(p_slotKey.GetIndex() < m_slots.size() && p_slotKey.GetVersion() == m_slots[p_slotKey.GetIndex()].GetVersion());
|
||||
return p_slotKey.Valid() && (p_slotKey.GetIndex() < m_slots.size() &&
|
||||
p_slotKey.GetVersion() == m_slots[p_slotKey.GetIndex()].GetVersion());
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
|
||||
@@ -49,6 +49,13 @@ class Log
|
||||
[[nodiscard]]
|
||||
quill::Logger* RegisterLogger(const LoggerInfo& p_loggerInfo);
|
||||
|
||||
/**
|
||||
* Unregister a logger.
|
||||
*
|
||||
* \param p_loggerInfo The logger to unregister
|
||||
*/
|
||||
void UnregisterLogger(const LoggerInfo& p_loggerInfo);
|
||||
|
||||
/**
|
||||
* Register a logger.
|
||||
*
|
||||
|
||||
@@ -86,13 +86,24 @@ class Version
|
||||
return static_cast<std::uint8_t>(m_combined & mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw Version
|
||||
*
|
||||
* \return the raw version
|
||||
*/
|
||||
[[nodiscard]]
|
||||
constexpr operator std::uint32_t() const
|
||||
constexpr std::uint32_t Raw() const
|
||||
{
|
||||
return m_combined;
|
||||
}
|
||||
|
||||
operator std::string() const;
|
||||
/**
|
||||
* Gets the string representation of the Version
|
||||
*
|
||||
* \return The string
|
||||
*/
|
||||
[[nodiscard]]
|
||||
std::string ToString() const;
|
||||
|
||||
constexpr Version& operator=(const Version& p_version) = default;
|
||||
constexpr Version& operator=(Version&& p_version) = default;
|
||||
@@ -123,7 +134,7 @@ struct std::formatter<Bigfoot::Version>
|
||||
template<typename FormatContext>
|
||||
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
|
||||
{
|
||||
return std::format_to(p_context.out(), "{}", static_cast<std::string>(p_version));
|
||||
return std::format_to(p_context.out(), "{}", p_version.ToString());
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,16 @@ quill::Logger* Log::RegisterLogger(const LoggerInfo& p_loggerInfo)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
void Log::UnregisterLogger(const LoggerInfo& p_loggerInfo)
|
||||
{
|
||||
if (quill::Logger* logger = quill::Frontend::get_logger(p_loggerInfo.m_name))
|
||||
{
|
||||
quill::Frontend::remove_logger_blocking(logger);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
quill::Logger* Log::GetLogger(const LoggerInfo& p_loggerInfo)
|
||||
{
|
||||
return quill::Frontend::get_logger(p_loggerInfo.m_name);
|
||||
@@ -92,12 +102,10 @@ void Log::Flush()
|
||||
Log::~Log()
|
||||
{
|
||||
Flush();
|
||||
|
||||
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
|
||||
{
|
||||
quill::Frontend::remove_logger(logger);
|
||||
quill::Frontend::remove_logger_blocking(logger);
|
||||
}
|
||||
|
||||
quill::Backend::stop();
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
Version::operator std::string() const
|
||||
std::string Version::ToString() const
|
||||
{
|
||||
return std::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
||||
}
|
||||
|
||||
@@ -53,37 +53,37 @@ TEST_F(BigFileFixture, BigFileManipulation)
|
||||
BigFile::Request assetHeaderRequest {
|
||||
m_bigFile,
|
||||
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
|
||||
assetHeaderRequest.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
|
||||
assetHeaderRequest.Bind(1, uuid.ToBytes());
|
||||
assetHeaderRequest.Bind(2, "Test");
|
||||
assetHeaderRequest.Bind(3, typeIDRef);
|
||||
assetHeaderRequest.Bind(4, "TypeTest");
|
||||
|
||||
BigFile::Request assetRequest {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
|
||||
assetRequest.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
|
||||
assetRequest.Bind(1, uuid.ToBytes());
|
||||
assetRequest.Bind(2, blob);
|
||||
|
||||
BigFile::Request assetHeaderRequest2 {
|
||||
m_bigFile,
|
||||
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
|
||||
assetHeaderRequest2.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid2));
|
||||
assetHeaderRequest2.Bind(1, uuid2.ToBytes());
|
||||
assetHeaderRequest2.Bind(2, "Test2");
|
||||
assetHeaderRequest2.Bind(3, typeIDRef);
|
||||
assetHeaderRequest2.Bind(4, "TypeTest");
|
||||
|
||||
BigFile::Request assetRequest2 {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
|
||||
assetRequest2.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid2));
|
||||
assetRequest2.Bind(1, uuid2.ToBytes());
|
||||
assetRequest2.Bind(2, blob3);
|
||||
|
||||
BigFile::Request assetHeaderRequest3 {
|
||||
m_bigFile,
|
||||
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
|
||||
assetHeaderRequest3.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid3));
|
||||
assetHeaderRequest3.Bind(1, uuid3.ToBytes());
|
||||
assetHeaderRequest3.Bind(2, "Test3");
|
||||
assetHeaderRequest3.Bind(3, typeIDRef);
|
||||
assetHeaderRequest3.Bind(4, "TypeTest");
|
||||
|
||||
BigFile::Request assetRequest3 {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
|
||||
assetRequest3.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid3));
|
||||
assetRequest3.Bind(1, uuid3.ToBytes());
|
||||
assetRequest3.Bind(2, blob4);
|
||||
|
||||
m_bigFile.BeginTransaction();
|
||||
@@ -108,7 +108,7 @@ TEST_F(BigFileFixture, BigFileManipulation)
|
||||
{
|
||||
BigFile::Request updateAsset {m_bigFile, "UPDATE Asset SET Asset = ? WHERE UUID = ?"};
|
||||
updateAsset.Bind(1, blob2);
|
||||
updateAsset.Bind(2, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
|
||||
updateAsset.Bind(2, uuid.ToBytes());
|
||||
|
||||
m_bigFile.BeginTransaction();
|
||||
std::uint32_t updateAssetChangedCount = updateAsset.Execute();
|
||||
@@ -120,7 +120,7 @@ TEST_F(BigFileFixture, BigFileManipulation)
|
||||
BigFile::Request request {
|
||||
m_bigFile,
|
||||
"SELECT Name, TypeID, TypeName, CreateTime, ModificationTime FROM AssetHeader WHERE UUID = ?"};
|
||||
request.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
|
||||
request.Bind(1, uuid.ToBytes());
|
||||
|
||||
const bool get = request.Step();
|
||||
EXPECT_TRUE(get);
|
||||
|
||||
19
Bigfoot/Tests/Engine/EngineTests/main.cpp
Normal file
19
Bigfoot/Tests/Engine/EngineTests/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*********************************************************************
|
||||
* \file main.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date May 2026
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
19
Bigfoot/Tests/System/SystemTests/main.cpp
Normal file
19
Bigfoot/Tests/System/SystemTests/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*********************************************************************
|
||||
* \file main.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date May 2026
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -43,13 +43,13 @@ class UUIDFixture: public ::testing::Test
|
||||
|
||||
TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
|
||||
{
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_a;
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_a.ToBytes();
|
||||
EXPECT_EQ(m_a, UUID {raw});
|
||||
|
||||
raw = m_b;
|
||||
raw = m_b.ToBytes();
|
||||
EXPECT_EQ(m_b, UUID {raw});
|
||||
|
||||
raw = m_d;
|
||||
raw = m_d.ToBytes();
|
||||
EXPECT_EQ(m_d, UUID {raw});
|
||||
}
|
||||
|
||||
@@ -57,21 +57,21 @@ TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
|
||||
|
||||
TEST_F(UUIDFixture, ValidIDFromStringShouldBeEqualToString)
|
||||
{
|
||||
EXPECT_EQ(static_cast<std::string>(m_b), "47183823-2574-4bfd-b411-99ed177d3e43");
|
||||
EXPECT_EQ(m_b.ToString(), "47183823-2574-4bfd-b411-99ed177d3e43");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(UUIDFixture, InvalidIDFromStringShouldNotBeEqualToString)
|
||||
{
|
||||
EXPECT_NE(static_cast<std::string>(m_c), "4bfd-b411-99ed177d3e43");
|
||||
EXPECT_NE(m_c.ToString(), "4bfd-b411-99ed177d3e43");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(UUIDFixture, NullIDStringShouldBeEqualToNullIDString)
|
||||
{
|
||||
EXPECT_EQ(static_cast<std::string>(UUID::NULL_UUID), "00000000-0000-0000-0000-000000000000");
|
||||
EXPECT_EQ(UUID::NULL_UUID.ToString(), "00000000-0000-0000-0000-000000000000");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -168,9 +168,9 @@ TEST_F(UUIDFixture, GeneratingFiveMillionUniqueID)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(UUIDFixture, Raw_ShouldGiveBackTheRawDataOfTheID)
|
||||
TEST_F(UUIDFixture, ToBytes_ShouldGiveBackTheRawDataOfTheID)
|
||||
{
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> d = m_d;
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> d = m_d.ToBytes();
|
||||
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_raw;
|
||||
|
||||
for (std::uint32_t i = 0; i < UUID::UUID_BYTE_SIZE; ++i)
|
||||
|
||||
@@ -3,3 +3,5 @@ project(${PackageName}Tests)
|
||||
|
||||
bigfoot_create_package_tests(
|
||||
"")
|
||||
|
||||
bigfoot_create_logger()
|
||||
@@ -0,0 +1,21 @@
|
||||
// AUTO-GENERATED DO NOT TOUCH
|
||||
|
||||
/*********************************************************************
|
||||
* \file UtilsTestsLogger.generated.hpp
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||
#define BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
inline Log::LoggerInfo UTILSTESTS_LOGGER {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,6 +6,10 @@
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/Log.hpp>
|
||||
|
||||
#include <Utils/Singleton.hpp>
|
||||
|
||||
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -37,46 +41,57 @@ class LogFixture: public ::testing::Test
|
||||
|
||||
return Flat::LogLevel::Trace;
|
||||
}
|
||||
|
||||
Log m_log;
|
||||
Log::LoggerInfo m_logger {"LOGGER", Flat::LogLevel::Trace};
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
|
||||
{
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_logger);
|
||||
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||
EXPECT_TRUE(logger);
|
||||
EXPECT_EQ(logger, m_log.GetLogger(m_logger));
|
||||
EXPECT_EQ(logger->get_logger_name(), m_logger.m_name);
|
||||
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), m_logger.m_level);
|
||||
EXPECT_EQ(logger, Singleton<Log>::GetInstance().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, UnregisterLogger_ShouldUnregisterTheLogger)
|
||||
{
|
||||
std::ignore = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||
Singleton<Log>::GetInstance().UnregisterLogger(UTILSTESTS_LOGGER);
|
||||
|
||||
EXPECT_EQ(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER), nullptr);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
||||
{
|
||||
EXPECT_FALSE(m_log.GetLogger(m_logger));
|
||||
EXPECT_FALSE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
|
||||
TEST_F(LogFixture, GetLoger_ShouldReturnTheLoggerIfItExists)
|
||||
{
|
||||
[[maybe_unused]]
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_logger);
|
||||
EXPECT_TRUE(m_log.GetLogger(m_logger));
|
||||
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||
EXPECT_TRUE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
|
||||
{
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_logger);
|
||||
const Flat::LogLevel previous = UTILSTESTS_LOGGER.m_level;
|
||||
|
||||
m_log.ChangeLoggerLogLevel(m_logger, Flat::LogLevel::Critical);
|
||||
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||
|
||||
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
|
||||
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), Flat::LogLevel::Critical);
|
||||
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, previous);
|
||||
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), previous);
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -15,50 +17,48 @@ namespace Bigfoot
|
||||
class LogMacrosFixture: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
Singleton<Log>::Lifetime m_singletonLifetime;
|
||||
Log::LoggerInfo m_logger {"LOGGER", Flat::LogLevel::Trace};
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogDebug)
|
||||
{
|
||||
BIGFOOT_LOG_DEBUG(m_logger, "Hello");
|
||||
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogTrace)
|
||||
{
|
||||
BIGFOOT_LOG_TRACE(m_logger, "Hello");
|
||||
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogInfo)
|
||||
{
|
||||
BIGFOOT_LOG_INFO(m_logger, "Hello");
|
||||
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogWarn)
|
||||
{
|
||||
BIGFOOT_LOG_WARN(m_logger, "Hello");
|
||||
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogError)
|
||||
{
|
||||
BIGFOOT_LOG_ERROR(m_logger, "Hello");
|
||||
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogFatal)
|
||||
{
|
||||
BIGFOOT_LOG_FATAL(m_logger, "Hello");
|
||||
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello");
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
|
||||
19
Bigfoot/Tests/Utils/UtilsTests/main.cpp
Normal file
19
Bigfoot/Tests/Utils/UtilsTests/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*********************************************************************
|
||||
* \file main.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date May 2026
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -19,18 +19,18 @@ class VersionFixture: public ::testing::Test
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(VersionFixture, string)
|
||||
TEST_F(VersionFixture, ToString)
|
||||
{
|
||||
EXPECT_STREQ(static_cast<std::string>(m_detailed).data(), "1.2.3");
|
||||
EXPECT_STREQ(static_cast<std::string>(m_combined).data(), "1.2.3");
|
||||
EXPECT_STREQ(m_detailed.ToString().data(), "1.2.3");
|
||||
EXPECT_STREQ(m_combined.ToString().data(), "1.2.3");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(VersionFixture, uint32_t)
|
||||
TEST_F(VersionFixture, Raw)
|
||||
{
|
||||
EXPECT_EQ(static_cast<std::uint32_t>(m_detailed), (1 << 16) | (2 << 8) | 3);
|
||||
EXPECT_EQ(static_cast<std::uint32_t>(m_combined), (1 << 16) | (2 << 8) | 3);
|
||||
EXPECT_EQ(m_detailed.Raw(), (1 << 16) | (2 << 8) | 3);
|
||||
EXPECT_EQ(m_combined.Raw(), (1 << 16) | (2 << 8) | 3);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user