Compare commits
3 Commits
e3c55cc359
...
00b86fbd00
| Author | SHA1 | Date | |
|---|---|---|---|
| 00b86fbd00 | |||
| 87d59a00c1 | |||
| 2c83dcc0bc |
@@ -13,11 +13,11 @@ namespace Bigfoot
|
||||
BigFile::BigFile(const File& p_file)
|
||||
{
|
||||
[[maybe_unused]]
|
||||
const int result = sqlite3_open_v2(p_file.Absolute().Path().data(), &m_db, SQLITE_OPEN_READWRITE, nullptr);
|
||||
const int result = sqlite3_open_v2(p_file.ToAbsolute().GetPath().data(), &m_db, SQLITE_OPEN_READWRITE, nullptr);
|
||||
CRITICAL_ASSERT(EngineAssertHandler,
|
||||
result == SQLITE_OK,
|
||||
"Failed to open BigFile {} DB: {}",
|
||||
p_file.Absolute().Path(),
|
||||
p_file.ToAbsolute().GetPath(),
|
||||
sqlite3_errmsg(m_db));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,19 @@ class Asset
|
||||
public:
|
||||
using FLAT_ASSET = typename ASSET::FLAT;
|
||||
|
||||
Asset()
|
||||
Asset():
|
||||
m_header(::Flat::Bigfoot::AssetHeaderT {.uuid = UUID {},
|
||||
.name = eastl::string {},
|
||||
.type_id = GetTypeID(),
|
||||
.type_name = eastl::string {GetTypeName()},
|
||||
.version = 0}),
|
||||
m_hardRefCount(0),
|
||||
m_softRefCount(0)
|
||||
{
|
||||
m_header.type_id = GetTypeID();
|
||||
m_header.type_name = GetTypeName();
|
||||
}
|
||||
|
||||
explicit Asset(const eastl::span<const std::byte> p_flatbuffer)
|
||||
explicit Asset(const eastl::span<const std::byte> p_flatbuffer):
|
||||
Asset()
|
||||
{
|
||||
#ifdef BIGFOOT_NOT_OPTIMIZED
|
||||
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(p_flatbuffer.data()), p_flatbuffer.size()};
|
||||
@@ -121,6 +127,9 @@ 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
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
|
||||
#define BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
|
||||
#include <Engine/Asset/Asset.hpp>
|
||||
#include <Engine/EngineAssertHandler.hpp>
|
||||
|
||||
#include <System/UUID/UUID.hpp>
|
||||
#include <Utils/Containers/SlotMap.hpp>
|
||||
|
||||
#include <ankerl/unordered_dense.h>
|
||||
|
||||
@@ -20,86 +21,82 @@ template<class ASSET>
|
||||
class AssetContainer
|
||||
{
|
||||
public:
|
||||
AssetContainer()
|
||||
AssetContainer() = default;
|
||||
|
||||
AssetContainer(const AssetContainer& p_container) = default;
|
||||
AssetContainer(AssetContainer&& p_container) = default;
|
||||
|
||||
~AssetContainer() = default;
|
||||
|
||||
template<class... ARGS>
|
||||
[[nodiscard]]
|
||||
typename SlotMap<ASSET>::SlotKey Insert(ARGS&&... p_args)
|
||||
{
|
||||
CRITICAL_ASSERT(EngineAssertHandler, !ms_instance, "Asset container already exists!");
|
||||
ms_instance = this;
|
||||
const typename SlotMap<ASSET>::SlotKey slotKey = m_assets.Insert(std::forward<ARGS>(p_args)...);
|
||||
m_uuidToSlotKey.insert({m_assets.Get(slotKey)->GetHeader().uuid, slotKey});
|
||||
|
||||
return slotKey;
|
||||
}
|
||||
|
||||
AssetContainer(const AssetContainer&) = delete;
|
||||
AssetContainer& operator=(const AssetContainer&) = delete;
|
||||
|
||||
~AssetContainer()
|
||||
[[nodiscard]]
|
||||
ASSET* Get(const typename SlotMap<ASSET>::SlotKey p_key)
|
||||
{
|
||||
ms_instance = nullptr;
|
||||
return m_assets.Get(p_key);
|
||||
}
|
||||
|
||||
struct Entry
|
||||
[[nodiscard]]
|
||||
const ASSET* Get(const typename SlotMap<ASSET>::SlotKey p_key) const
|
||||
{
|
||||
std::uint32_t m_hardRefCount = 0;
|
||||
std::uint32_t m_softRefCount = 0;
|
||||
};
|
||||
|
||||
void IncrementHardRefCount(const UUID& p_uuid)
|
||||
{
|
||||
++m_entries[p_uuid].m_hardRefCount;
|
||||
return m_assets.Get(p_key);
|
||||
}
|
||||
|
||||
void DecrementHardRefCount(const UUID& p_uuid)
|
||||
[[nodiscard]]
|
||||
typename SlotMap<ASSET>::SlotKey GetSlotKey(const UUID& p_uuid) const
|
||||
{
|
||||
if (const auto entry = m_entries.find(p_uuid); entry != m_entries.end())
|
||||
if (const auto it = m_uuidToSlotKey.find(p_uuid); it != m_uuidToSlotKey.end())
|
||||
{
|
||||
CRITICAL_ASSERT(
|
||||
EngineAssertHandler,
|
||||
entry->second.m_hardRefCount > 0,
|
||||
"Double release detected! Decrementing a hard reference to an asset that already does not have any "
|
||||
"more hardrefs");
|
||||
--entry->second.m_hardRefCount;
|
||||
return it->second;
|
||||
}
|
||||
return typename SlotMap<ASSET>::SlotKey {};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool Has(const typename SlotMap<ASSET>::SlotKey p_key) const
|
||||
{
|
||||
return m_assets.Has(p_key);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool Has(const UUID& p_uuid) const
|
||||
{
|
||||
return m_uuidToSlotKey.contains(p_uuid);
|
||||
}
|
||||
|
||||
void Remove(const typename SlotMap<ASSET>::SlotKey p_key)
|
||||
{
|
||||
if (const ASSET* asset = Get(p_key))
|
||||
{
|
||||
const UUID uuid = asset->GetHeader().uuid;
|
||||
m_assets.Remove(p_key);
|
||||
m_uuidToSlotKey.erase(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
void IncrementSoftRefCount(const UUID& p_uuid)
|
||||
void Remove(const UUID& p_uuid)
|
||||
{
|
||||
++m_entries[p_uuid].m_softRefCount;
|
||||
}
|
||||
|
||||
void DecrementSoftRefCount(const UUID& p_uuid)
|
||||
{
|
||||
if (const auto entry = m_entries.find(p_uuid); entry != m_entries.end())
|
||||
if (const auto it = m_uuidToSlotKey.find(p_uuid); it != m_uuidToSlotKey.end())
|
||||
{
|
||||
CRITICAL_ASSERT(
|
||||
EngineAssertHandler,
|
||||
entry->second.m_softRefCount > 0,
|
||||
"Double release detected! Decrementing a soft reference to an asset that already does not have any "
|
||||
"more softrefs");
|
||||
--entry->second.m_softRefCount;
|
||||
Remove(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t HardRefCount(const UUID& p_uuid) const
|
||||
{
|
||||
const auto entry = m_entries.find(p_uuid);
|
||||
return entry != m_entries.end() ? entry->second.m_hardRefCount : 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t SoftRefCount(const UUID& p_uuid) const
|
||||
{
|
||||
const auto entry = m_entries.find(p_uuid);
|
||||
return entry != m_entries.end() ? entry->second.m_softRefCount : 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static AssetContainer& Get()
|
||||
{
|
||||
return *ms_instance;
|
||||
}
|
||||
AssetContainer& operator=(const AssetContainer& p_container) = default;
|
||||
AssetContainer& operator=(AssetContainer&& p_container) = default;
|
||||
|
||||
private:
|
||||
ankerl::unordered_dense::segmented_map<UUID, Entry> m_entries;
|
||||
ankerl::unordered_dense::segmented_map<UUID, typename SlotMap<ASSET>::SlotKey> m_uuidToSlotKey;
|
||||
|
||||
inline static constinit AssetContainer* ms_instance = nullptr;
|
||||
SlotMap<ASSET> m_assets;
|
||||
};
|
||||
} // namespace Bigfoot
|
||||
|
||||
|
||||
@@ -24,19 +24,11 @@
|
||||
Bigfoot::HardReference<AssetType> UnPackHardReference##AssetName(const Flat::Bigfoot::HardReference& p_hardRef); \
|
||||
}
|
||||
|
||||
#define ASSET_CONTAINER(AssetName, AssetType) \
|
||||
namespace Bigfoot \
|
||||
{ \
|
||||
inline AssetContainer<AssetType> g_##AssetName##Container; \
|
||||
}
|
||||
|
||||
#define ASSET_REF_DECL(AssetName, AssetType) \
|
||||
ASSET_SOFT_REF_DECL(AssetName, AssetType) \
|
||||
ASSET_HARD_REF_DECL(AssetName, AssetType)
|
||||
|
||||
#define ASSET_DECL(AssetName, AssetType) \
|
||||
ASSET_REF_DECL(AssetName, AssetType) \
|
||||
ASSET_CONTAINER(AssetName, AssetType)
|
||||
#define ASSET_DECL(AssetName, AssetType) ASSET_REF_DECL(AssetName, AssetType)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class HardReference
|
||||
{
|
||||
if (m_uuid)
|
||||
{
|
||||
AssetContainer<ASSET>::Get().IncrementHardRefCount(m_uuid);
|
||||
// AssetContainer<ASSET>::Get().IncrementHardRefCount(m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class HardReference
|
||||
{
|
||||
if (m_uuid)
|
||||
{
|
||||
AssetContainer<ASSET>::Get().DecrementHardRefCount(m_uuid);
|
||||
// AssetContainer<ASSET>::Get().DecrementHardRefCount(m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ class SoftReference
|
||||
{
|
||||
if (m_uuid)
|
||||
{
|
||||
AssetContainer<ASSET>::Get().IncrementSoftRefCount(m_uuid);
|
||||
// AssetContainer<ASSET>::Get().IncrementSoftRefCount(m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class SoftReference
|
||||
{
|
||||
if (m_uuid)
|
||||
{
|
||||
AssetContainer<ASSET>::Get().DecrementSoftRefCount(m_uuid);
|
||||
// AssetContainer<ASSET>::Get().DecrementSoftRefCount(m_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
#include <Utils/Assert.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
#include <EASTL/utility.h>
|
||||
|
||||
#include <format>
|
||||
#include <source_location>
|
||||
#include <string_view>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
||||
#define BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
|
||||
@@ -37,21 +37,21 @@ bool File::Exists() const
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
eastl::string_view File::Path() const
|
||||
eastl::string_view File::GetPath() const
|
||||
{
|
||||
return m_pathString;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
File File::Absolute() const
|
||||
File File::ToAbsolute() const
|
||||
{
|
||||
return File {std::filesystem::absolute(m_path)};
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
File File::Relative() const
|
||||
File File::ToRelative() const
|
||||
{
|
||||
return File {std::filesystem::relative(m_path)};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class File
|
||||
* \return The path
|
||||
*/
|
||||
[[nodiscard]]
|
||||
eastl::string_view Path() const;
|
||||
eastl::string_view GetPath() const;
|
||||
|
||||
/**
|
||||
* Get the same file, relative to the current executable
|
||||
@@ -65,7 +65,7 @@ class File
|
||||
* \return The relative file
|
||||
*/
|
||||
[[nodiscard]]
|
||||
File Relative() const;
|
||||
File ToRelative() const;
|
||||
|
||||
/**
|
||||
* Get the same file, with an absolute path
|
||||
@@ -73,7 +73,7 @@ class File
|
||||
* \return The absolute file
|
||||
*/
|
||||
[[nodiscard]]
|
||||
File Absolute() const;
|
||||
File ToAbsolute() const;
|
||||
|
||||
~File() = default;
|
||||
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
#include <Utils/Assert.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
#include <EASTL/utility.h>
|
||||
|
||||
#include <format>
|
||||
#include <source_location>
|
||||
#include <string_view>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
||||
#define BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
|
||||
@@ -21,28 +21,28 @@ class Time
|
||||
Time(Time&& p_time) = default;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Year() const;
|
||||
std::uint32_t GetYear() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Month() const;
|
||||
std::uint32_t GetMonth() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Day() const;
|
||||
std::uint32_t GetDay() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Hour() const;
|
||||
std::uint32_t GetHour() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Minute() const;
|
||||
std::uint32_t GetMinute() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Second() const;
|
||||
std::uint32_t GetSecond() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Microsecond() const;
|
||||
std::uint32_t GetMicrosecond() const;
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint64_t Epoch() const;
|
||||
std::uint64_t GetEpoch() const;
|
||||
|
||||
~Time() = default;
|
||||
|
||||
|
||||
@@ -44,11 +44,7 @@ class UUID
|
||||
UUID& operator=(UUID&& p_uuid) noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
bool operator==(const UUID& p_uuid) const = default;
|
||||
[[nodiscard]]
|
||||
bool operator!=(const UUID& p_uuid) const = default;
|
||||
[[nodiscard]]
|
||||
bool operator<(const UUID& p_uuid) const;
|
||||
auto operator<=>(const UUID& p_uuid) const = default;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -55,56 +55,56 @@ Time::Time(const std::uint64_t p_epoch):
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Year() const
|
||||
std::uint32_t Time::GetYear() const
|
||||
{
|
||||
return m_timeInfo.tm_year + 1900;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Month() const
|
||||
std::uint32_t Time::GetMonth() const
|
||||
{
|
||||
return m_timeInfo.tm_mon + 1;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Day() const
|
||||
std::uint32_t Time::GetDay() const
|
||||
{
|
||||
return m_timeInfo.tm_mday;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Hour() const
|
||||
std::uint32_t Time::GetHour() const
|
||||
{
|
||||
return m_timeInfo.tm_hour;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Minute() const
|
||||
std::uint32_t Time::GetMinute() const
|
||||
{
|
||||
return m_timeInfo.tm_min;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Second() const
|
||||
std::uint32_t Time::GetSecond() const
|
||||
{
|
||||
return m_timeInfo.tm_sec;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint32_t Time::Microsecond() const
|
||||
std::uint32_t Time::GetMicrosecond() const
|
||||
{
|
||||
return static_cast<std::uint32_t>(m_microseconds.count());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::uint64_t Time::Epoch() const
|
||||
std::uint64_t Time::GetEpoch() const
|
||||
{
|
||||
return m_epoch;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace flatbuffers
|
||||
{
|
||||
Flat::Bigfoot::Time Pack(const Bigfoot::Time& p_time)
|
||||
{
|
||||
return Flat::Bigfoot::Time {p_time.Epoch()};
|
||||
return Flat::Bigfoot::Time {p_time.GetEpoch()};
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
@@ -64,13 +64,6 @@ UUID::operator bool() const
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
bool UUID::operator<(const UUID& p_uuid) const
|
||||
{
|
||||
return m_uuid < p_uuid.m_uuid;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::mt19937 UUID::GetRandomGenerator()
|
||||
{
|
||||
std::random_device randomDevice;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILS_ASSERT_HPP
|
||||
#define BIGFOOT_UTILS_ASSERT_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
HANDLER::Handle(location, p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||
if (Bigfoot::Singleton<Bigfoot::Log>::HasInstance()) \
|
||||
{ \
|
||||
Bigfoot::Singleton<Bigfoot::Log>::Instance().Flush(); \
|
||||
Bigfoot::Singleton<Bigfoot::Log>::GetInstance().Flush(); \
|
||||
} \
|
||||
BREAK; \
|
||||
std::abort(); \
|
||||
|
||||
@@ -61,15 +61,15 @@ class SlotMap
|
||||
|
||||
constexpr bool Valid() const
|
||||
{
|
||||
return Version() != INVALID_VERSION;
|
||||
return GetVersion() != INVALID_VERSION;
|
||||
}
|
||||
|
||||
constexpr VersionType Version() const
|
||||
constexpr VersionType GetVersion() const
|
||||
{
|
||||
return static_cast<VersionType>(m_key >> INDEX_BIT_COUNT);
|
||||
}
|
||||
|
||||
constexpr IndexType Index() const
|
||||
constexpr IndexType GetIndex() const
|
||||
{
|
||||
return static_cast<IndexType>(m_key & INDEX_MASK);
|
||||
}
|
||||
@@ -107,12 +107,12 @@ class SlotMap
|
||||
{
|
||||
const typename SlotKey::IndexType slotIndex = m_freeSlotHead;
|
||||
|
||||
m_freeSlotHead = m_slots[slotIndex].Index();
|
||||
m_freeSlotHead = m_slots[slotIndex].GetIndex();
|
||||
|
||||
m_slots[slotIndex] = SlotKey {m_slots[slotIndex].Version(), dataIndex};
|
||||
m_slots[slotIndex] = SlotKey {m_slots[slotIndex].GetVersion(), dataIndex};
|
||||
m_dataToSlots.push_back(slotIndex);
|
||||
|
||||
return SlotKey {m_slots[slotIndex].Version(), slotIndex};
|
||||
return SlotKey {m_slots[slotIndex].GetVersion(), slotIndex};
|
||||
}
|
||||
|
||||
const typename SlotKey::IndexType slotIndex = static_cast<SlotKey::IndexType>(m_slots.size());
|
||||
@@ -129,36 +129,36 @@ class SlotMap
|
||||
return;
|
||||
}
|
||||
|
||||
const typename SlotKey::IndexType dataIndex = m_slots[p_slotKey.Index()].Index();
|
||||
const typename SlotKey::IndexType dataIndex = m_slots[p_slotKey.GetIndex()].GetIndex();
|
||||
|
||||
m_data.erase_unsorted(m_data.begin() + dataIndex);
|
||||
m_dataToSlots.erase_unsorted(m_dataToSlots.begin() + dataIndex);
|
||||
|
||||
if (dataIndex < m_data.size())
|
||||
{
|
||||
m_slots[m_dataToSlots[dataIndex]] = SlotKey {m_slots[m_dataToSlots[dataIndex]].Version(), dataIndex};
|
||||
m_slots[m_dataToSlots[dataIndex]] = SlotKey {m_slots[m_dataToSlots[dataIndex]].GetVersion(), dataIndex};
|
||||
}
|
||||
|
||||
RecycleSlot(p_slotKey.Version() + 1, p_slotKey.Index());
|
||||
RecycleSlot(p_slotKey.GetVersion() + 1, p_slotKey.GetIndex());
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool Has(const SlotKey p_slotKey) const
|
||||
{
|
||||
return p_slotKey.Valid() &&
|
||||
(p_slotKey.Index() < m_slots.size() && p_slotKey.Version() == m_slots[p_slotKey.Index()].Version());
|
||||
(p_slotKey.GetIndex() < m_slots.size() && p_slotKey.GetVersion() == m_slots[p_slotKey.GetIndex()].GetVersion());
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
TYPE* Get(const SlotKey p_slotKey)
|
||||
{
|
||||
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.Index()].Index()] : nullptr;
|
||||
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.GetIndex()].GetIndex()] : nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
const TYPE* Get(const SlotKey p_slotKey) const
|
||||
{
|
||||
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.Index()].Index()] : nullptr;
|
||||
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.GetIndex()].GetIndex()] : nullptr;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
@@ -173,7 +173,7 @@ class SlotMap
|
||||
{
|
||||
for (const typename eastl::vector<TYPE>::size_type slotIndex: m_dataToSlots)
|
||||
{
|
||||
RecycleSlot(m_slots[slotIndex].Version() + 1, static_cast<SlotKey::IndexType>(slotIndex));
|
||||
RecycleSlot(m_slots[slotIndex].GetVersion() + 1, static_cast<SlotKey::IndexType>(slotIndex));
|
||||
}
|
||||
|
||||
m_data.clear();
|
||||
@@ -181,13 +181,13 @@ class SlotMap
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
eastl::vector<TYPE>::size_type Size() const
|
||||
eastl::vector<TYPE>::size_type GetSize() const
|
||||
{
|
||||
return m_data.size();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
eastl::vector<TYPE>::size_type Capacity() const
|
||||
eastl::vector<TYPE>::size_type GetCapacity() const
|
||||
{
|
||||
return m_data.capacity();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
#include <Utils/Log/Log_generated.hpp>
|
||||
#include <Utils/Singleton.hpp>
|
||||
|
||||
#include <EASTL/array.h>
|
||||
|
||||
@@ -92,96 +91,5 @@ class Log
|
||||
eastl::array<std::shared_ptr<quill::Sink>, 1> m_sinks;
|
||||
};
|
||||
} // namespace Bigfoot
|
||||
|
||||
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_DEBUG(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_INFO(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_WARNING(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_ERROR(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
104
Bigfoot/Sources/Utils/Include/Utils/Log/LogMacros.hpp
Normal file
104
Bigfoot/Sources/Utils/Include/Utils/Log/LogMacros.hpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*********************************************************************
|
||||
* \file LogMacros.hpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date May 2026
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILS_LOG_LOGMACROS_HPP
|
||||
#define BIGFOOT_UTILS_LOG_LOGMACROS_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Singleton.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_DEBUG(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_INFO(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_WARNING(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_ERROR(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
|
||||
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
||||
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
|
||||
@@ -6,12 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
|
||||
#define BIGFOOT_UTILS_SINGLETON_HPP
|
||||
|
||||
#include <EASTL/array.h>
|
||||
#include <EASTL/bit.h>
|
||||
#include <EASTL/optional.h>
|
||||
#include <EASTL/type_traits.h>
|
||||
#include <EASTL/utility.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
@@ -31,7 +26,7 @@ class Singleton
|
||||
*
|
||||
* \return The instance
|
||||
*/
|
||||
static constexpr TYPE& Instance()
|
||||
static constexpr TYPE& GetInstance()
|
||||
{
|
||||
return ms_instance.value();
|
||||
}
|
||||
@@ -69,7 +64,7 @@ class Singleton
|
||||
}
|
||||
|
||||
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
|
||||
Lifetime& operator=(Lifetime&& p_lifetime) = delete;
|
||||
Lifetime& operator=(Lifetime&& p_lifetime) noexcept = delete;
|
||||
};
|
||||
|
||||
Singleton& operator=(const Singleton& p_singleton) = delete;
|
||||
|
||||
@@ -7,15 +7,12 @@
|
||||
#ifndef BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
|
||||
#define BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
|
||||
#include <Utils/Assert.hpp>
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/UtilsLogger_generated.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
#include <EASTL/utility.h>
|
||||
|
||||
#include <format>
|
||||
#include <source_location>
|
||||
#include <string_view>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILSLOGGER_GENERATED_HPP
|
||||
#define BIGFOOT_UTILSLOGGER_GENERATED_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class Version
|
||||
* \return The major part of the version.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
constexpr std::uint8_t Major() const
|
||||
constexpr std::uint8_t GetMajor() const
|
||||
{
|
||||
constexpr std::uint32_t mask = 0b00000000111111110000000000000000;
|
||||
|
||||
@@ -66,7 +66,7 @@ class Version
|
||||
* \return The minor part of the version.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
constexpr std::uint8_t Minor() const
|
||||
constexpr std::uint8_t GetMinor() const
|
||||
{
|
||||
constexpr std::uint32_t mask = 0b00000000000000001111111100000000;
|
||||
|
||||
@@ -79,7 +79,7 @@ class Version
|
||||
* \return The patch part of the version.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
constexpr std::uint8_t Patch() const
|
||||
constexpr std::uint8_t GetPatch() const
|
||||
{
|
||||
constexpr std::uint32_t mask = 0b00000000000000000000000011111111;
|
||||
|
||||
@@ -95,38 +95,10 @@ class Version
|
||||
operator std::string() const;
|
||||
|
||||
constexpr Version& operator=(const Version& p_version) = default;
|
||||
|
||||
constexpr Version& operator=(Version&& p_version) = default;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator>(const Version& p_version) const
|
||||
{
|
||||
return m_combined > p_version.m_combined;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator<(const Version& p_version) const
|
||||
{
|
||||
return m_combined < p_version.m_combined;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator>=(const Version& p_version) const
|
||||
{
|
||||
return m_combined >= p_version.m_combined;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator<=(const Version& p_version) const
|
||||
{
|
||||
return m_combined <= p_version.m_combined;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator==(const Version& p_version) const = default;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool operator!=(const Version& p_version) const = default;
|
||||
constexpr auto operator<=>(const Version& p_version) const = default;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace Bigfoot
|
||||
{
|
||||
Version::operator std::string() const
|
||||
{
|
||||
return std::format("{}.{}.{}", Major(), Minor(), Patch());
|
||||
return std::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -6,12 +6,6 @@
|
||||
*********************************************************************/
|
||||
#include <Engine/Asset/Asset.hpp>
|
||||
|
||||
#include <Engine/EngineLogger_generated.hpp>
|
||||
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Singleton.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <EngineTests/Asset/AssetA.hpp>
|
||||
#include <EngineTests/Asset/AssetB.hpp>
|
||||
#include <EngineTests/Asset/AssetC.hpp>
|
||||
@@ -23,12 +17,6 @@ namespace Bigfoot
|
||||
class AssetFixture: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(std::ignore = Singleton<Log>::Instance().RegisterLogger(ENGINE_LOGGER);)
|
||||
}
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
73
Bigfoot/Tests/Engine/Asset/AssetContainer.cpp
Normal file
73
Bigfoot/Tests/Engine/Asset/AssetContainer.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*********************************************************************
|
||||
* \file BigFile.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date December 2025
|
||||
*********************************************************************/
|
||||
#include <Engine/Asset/AssetContainer.hpp>
|
||||
|
||||
#include <EngineTests/Asset/AssetA.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
class AssetContainerFixture: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
AssetContainer<AssetA> m_container;
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetContainerFixture, Insert)
|
||||
{
|
||||
std::ignore = m_container.Insert();
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetContainerFixture, Get)
|
||||
{
|
||||
const auto key = m_container.Insert();
|
||||
|
||||
const auto& constContainer = m_container;
|
||||
|
||||
const auto validateKey = [&](auto& p_assetContainer)
|
||||
{
|
||||
const auto asset = p_assetContainer.Get(key);
|
||||
EXPECT_NE(asset, nullptr);
|
||||
};
|
||||
validateKey(m_container);
|
||||
validateKey(constContainer);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetContainerFixture, GetSlotKey)
|
||||
{
|
||||
const auto key = m_container.Insert();
|
||||
const auto asset = m_container.Get(key);
|
||||
EXPECT_EQ(m_container.GetSlotKey(asset->GetHeader().uuid), key);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetContainerFixture, Has)
|
||||
{
|
||||
const auto key = m_container.Insert();
|
||||
EXPECT_TRUE(m_container.Has(key));
|
||||
EXPECT_TRUE(m_container.Has(m_container.Get(key)->GetHeader().uuid));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetContainerFixture, Remove)
|
||||
{
|
||||
const auto key1 = m_container.Insert();
|
||||
m_container.Remove(key1);
|
||||
|
||||
const auto key2 = m_container.Insert();
|
||||
m_container.Remove(m_container.Get(key2)->GetHeader().uuid);
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
@@ -6,15 +6,9 @@
|
||||
*********************************************************************/
|
||||
#include <Engine/BigFile/BigFile.hpp>
|
||||
|
||||
#include <Engine/EngineLogger_generated.hpp>
|
||||
|
||||
#include <System/Time/Time.hpp>
|
||||
#include <System/UUID/UUID.hpp>
|
||||
|
||||
#include <Utils/Log/Log.hpp>
|
||||
#include <Utils/Singleton.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <EngineTests/BigFileInfo_generated.hpp>
|
||||
|
||||
#include <ankerl/unordered_dense.h>
|
||||
@@ -35,12 +29,8 @@ class BigFileFixture: public ::testing::Test
|
||||
deleteHeader.Execute();
|
||||
deleteAsset.Execute();
|
||||
m_bigFile.CommitTransaction();
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(std::ignore = Singleton<Log>::Instance().RegisterLogger(ENGINE_LOGGER);)
|
||||
}
|
||||
|
||||
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
|
||||
|
||||
BigFile m_bigFile {File {BIGFILE_ENGINETESTS_LOCATION}};
|
||||
};
|
||||
|
||||
@@ -145,13 +135,13 @@ TEST_F(BigFileFixture, BigFileManipulation)
|
||||
const Time createTime = static_cast<std::uint64_t>(request.Get(3));
|
||||
const Time modificationTime = static_cast<std::uint64_t>(request.Get(4));
|
||||
|
||||
EXPECT_GT(createTime.Epoch(), 0);
|
||||
EXPECT_GT(modificationTime.Epoch(), 0);
|
||||
EXPECT_GT(createTime.GetEpoch(), 0);
|
||||
EXPECT_GT(modificationTime.GetEpoch(), 0);
|
||||
|
||||
EXPECT_GE(createTime, modificationTime);
|
||||
|
||||
EXPECT_GT(createTime.Year(), 2025);
|
||||
EXPECT_GT(modificationTime.Year(), 2025);
|
||||
EXPECT_GT(createTime.GetYear(), 2025);
|
||||
EXPECT_GT(modificationTime.GetYear(), 2025);
|
||||
}
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -28,14 +28,14 @@ TEST_F(FileFixture, IsRelative_ShouldReturnTrueOnRelativeFile)
|
||||
|
||||
TEST_F(FileFixture, IsRelative_ShouldReturnFalseOnAbsoluteFile)
|
||||
{
|
||||
EXPECT_FALSE(m_file.Absolute().IsRelative());
|
||||
EXPECT_FALSE(m_file.ToAbsolute().IsRelative());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
|
||||
{
|
||||
EXPECT_TRUE(m_file.Absolute().IsAbsolute());
|
||||
EXPECT_TRUE(m_file.ToAbsolute().IsAbsolute());
|
||||
}
|
||||
|
||||
TEST_F(FileFixture, IsAbsolute_ShouldReturnFalseOnRelativeFile)
|
||||
@@ -59,22 +59,22 @@ TEST_F(FileFixture, Exists_ShouldReturnFalseOnNonExistingFile)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(FileFixture, Path_ShouldReturnThePath)
|
||||
TEST_F(FileFixture, GetPath_ShouldReturnThePath)
|
||||
{
|
||||
EXPECT_STREQ(m_file.Path().data(), "Fixture/file");
|
||||
EXPECT_STREQ(m_file.GetPath().data(), "Fixture/file");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(FileFixture, Absolute_ShouldReturnTheAbsolutePath)
|
||||
TEST_F(FileFixture, ToAbsolute_ShouldReturnTheAbsolutePath)
|
||||
{
|
||||
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.Absolute().Path().data());
|
||||
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.ToAbsolute().GetPath().data());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(FileFixture, Relative_ShouldReturnTheRelativePath)
|
||||
TEST_F(FileFixture, ToRelative_ShouldReturnTheRelativePath)
|
||||
{
|
||||
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.Relative().Path().data());
|
||||
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.ToRelative().GetPath().data());
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -18,50 +18,50 @@ class TimeFixture: public ::testing::Test
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Year_ShouldReturnTheYear)
|
||||
TEST_F(TimeFixture, GetYear_ShouldReturnTheYear)
|
||||
{
|
||||
EXPECT_EQ(m_time.Year(), 2026);
|
||||
EXPECT_EQ(m_time.GetYear(), 2026);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Month_ShouldReturnTheMonth)
|
||||
TEST_F(TimeFixture, GetMonth_ShouldReturnTheMonth)
|
||||
{
|
||||
EXPECT_EQ(m_time.Month(), 1);
|
||||
EXPECT_EQ(m_time.GetMonth(), 1);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Day_ShouldReturnTheDay)
|
||||
TEST_F(TimeFixture, GetDay_ShouldReturnTheDay)
|
||||
{
|
||||
EXPECT_EQ(m_time.Day(), 5);
|
||||
EXPECT_EQ(m_time.GetDay(), 5);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Hour_ShouldReturnTheHour)
|
||||
TEST_F(TimeFixture, GetHour_ShouldReturnTheHour)
|
||||
{
|
||||
EXPECT_EQ(m_time.Hour(), 20);
|
||||
EXPECT_EQ(m_time.GetHour(), 20);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Minute_ShouldReturnTheMinute)
|
||||
TEST_F(TimeFixture, GetMinute_ShouldReturnTheMinute)
|
||||
{
|
||||
EXPECT_EQ(m_time.Minute(), 9);
|
||||
EXPECT_EQ(m_time.GetMinute(), 9);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Second_ShouldReturnTheSecond)
|
||||
TEST_F(TimeFixture, GetSecond_ShouldReturnTheSecond)
|
||||
{
|
||||
EXPECT_EQ(m_time.Second(), 6);
|
||||
EXPECT_EQ(m_time.GetSecond(), 6);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(TimeFixture, Microsecond_ShouldReturnTheMicrosecond)
|
||||
TEST_F(TimeFixture, GetMicrosecond_ShouldReturnTheMicrosecond)
|
||||
{
|
||||
EXPECT_EQ(m_time.Microsecond(), 680'609);
|
||||
EXPECT_EQ(m_time.GetMicrosecond(), 680'609);
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -2,6 +2,4 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(${PackageName}Tests)
|
||||
|
||||
bigfoot_create_package_tests(
|
||||
"")
|
||||
|
||||
bigfoot_create_logger()
|
||||
"")
|
||||
@@ -60,8 +60,8 @@ TYPED_TEST(SlotKeyFixture, DefaultSlotKeyIsInvalid)
|
||||
|
||||
constexpr typename TestFixture::SlotKey slotKey {};
|
||||
EXPECT_FALSE(slotKey.Valid());
|
||||
EXPECT_EQ(slotKey.Version(), version);
|
||||
EXPECT_EQ(slotKey.Index(), index);
|
||||
EXPECT_EQ(slotKey.GetVersion(), version);
|
||||
EXPECT_EQ(slotKey.GetIndex(), index);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -88,24 +88,24 @@ TYPED_TEST(SlotKeyFixture, Valid_ShouldReturnFalseIfTheSlotKeyIsValid)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TYPED_TEST(SlotKeyFixture, Version_ShouldReturnTheVersion)
|
||||
TYPED_TEST(SlotKeyFixture, GetVersion_ShouldReturnTheVersion)
|
||||
{
|
||||
constexpr typename TestFixture::SlotMapIndex index = 0;
|
||||
constexpr typename TestFixture::SlotMapVersion version = 42;
|
||||
|
||||
constexpr typename TestFixture::SlotKey slotKey {version, index};
|
||||
EXPECT_EQ(slotKey.Version(), version);
|
||||
EXPECT_EQ(slotKey.GetVersion(), version);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TYPED_TEST(SlotKeyFixture, Index_ShouldReturnTheIndex)
|
||||
TYPED_TEST(SlotKeyFixture, GetIndex_ShouldReturnTheIndex)
|
||||
{
|
||||
constexpr typename TestFixture::SlotMapIndex index = 42;
|
||||
constexpr typename TestFixture::SlotMapVersion version = 0;
|
||||
|
||||
constexpr typename TestFixture::SlotKey slotKey {version, index};
|
||||
EXPECT_EQ(slotKey.Index(), index);
|
||||
EXPECT_EQ(slotKey.GetIndex(), index);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -140,8 +140,8 @@ TYPED_TEST(SlotMapFixture, Insert_ShouldRecycleASlotKeyAfterARemove)
|
||||
this->m_slotMap.Remove(slotKey);
|
||||
|
||||
const auto secondSlotKey = this->m_slotMap.Insert(69);
|
||||
EXPECT_NE(secondSlotKey.Version(), slotKey.Version());
|
||||
EXPECT_EQ(secondSlotKey.Index(), slotKey.Index());
|
||||
EXPECT_NE(secondSlotKey.GetVersion(), slotKey.GetVersion());
|
||||
EXPECT_EQ(secondSlotKey.GetIndex(), slotKey.GetIndex());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -190,19 +190,19 @@ TYPED_TEST(SlotMapFixture, Remove_ShouldNotRecycleASlotWhenVersionWasExhausted)
|
||||
{
|
||||
this->m_slotMap.Remove(key);
|
||||
const auto newKey = this->m_slotMap.Insert(1);
|
||||
EXPECT_EQ(newKey.Index(), key.Index());
|
||||
EXPECT_EQ(newKey.GetIndex(), key.GetIndex());
|
||||
key = newKey;
|
||||
}
|
||||
|
||||
// Slot is at MAX_VERSION — one more remove should overflow and permanently deactivate it
|
||||
EXPECT_EQ(key.Version(), std::numeric_limits<typename TestFixture::SlotMapVersion>::max());
|
||||
EXPECT_EQ(key.GetVersion(), std::numeric_limits<typename TestFixture::SlotMapVersion>::max());
|
||||
this->m_slotMap.Remove(key);
|
||||
|
||||
EXPECT_FALSE(this->m_slotMap.Has(key));
|
||||
|
||||
// Dead slot must not be recycled; a new insert must allocate a fresh slot index
|
||||
const auto newKey = this->m_slotMap.Insert(2);
|
||||
EXPECT_NE(newKey.Index(), key.Index());
|
||||
EXPECT_NE(newKey.GetIndex(), key.GetIndex());
|
||||
|
||||
// Ensure an invalid key does not return an exhausted slot
|
||||
EXPECT_EQ(this->m_slotMap.Get(typename TestFixture::SlotKey {}), nullptr);
|
||||
@@ -313,35 +313,35 @@ TYPED_TEST(SlotMapFixture, Clear_ResetsTheSlotMapAndButGuaranteesNotCollisionWit
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TYPED_TEST(SlotMapFixture, Size_ReturnTheSizeOfTheSlotMap)
|
||||
TYPED_TEST(SlotMapFixture, GetSize_ReturnTheSizeOfTheSlotMap)
|
||||
{
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 0);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
|
||||
|
||||
std::ignore = this->m_slotMap.Insert(42);
|
||||
const auto slotKey2 = this->m_slotMap.Insert(69);
|
||||
std::ignore = this->m_slotMap.Insert(28);
|
||||
std::ignore = this->m_slotMap.Insert(0);
|
||||
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 4);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 4);
|
||||
|
||||
this->m_slotMap.Remove(slotKey2);
|
||||
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 3);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 3);
|
||||
|
||||
this->m_slotMap.Clear();
|
||||
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 0);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
|
||||
|
||||
std::ignore = this->m_slotMap.Insert(42);
|
||||
std::ignore = this->m_slotMap.Insert(69);
|
||||
std::ignore = this->m_slotMap.Insert(28);
|
||||
std::ignore = this->m_slotMap.Insert(0);
|
||||
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 4);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 4);
|
||||
|
||||
this->m_slotMap.Reset();
|
||||
|
||||
EXPECT_EQ(this->m_slotMap.Size(), 0);
|
||||
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// AUTO-GENERATED DO NOT TOUCH
|
||||
|
||||
/*********************************************************************
|
||||
* \file UtilsTestsLogger.generated.hpp
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||
#define BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||
#include <Utils/Log/Log.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
inline Log::LoggerInfo UTILSTESTS_LOGGER {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,10 +6,6 @@
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/Log.hpp>
|
||||
|
||||
#include <Utils/Singleton.hpp>
|
||||
|
||||
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -19,11 +15,6 @@ 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)
|
||||
@@ -48,24 +39,25 @@ class LogFixture: public ::testing::Test
|
||||
}
|
||||
|
||||
Log m_log;
|
||||
Log::LoggerInfo m_logger {"LOGGER", Flat::LogLevel::Trace};
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
|
||||
{
|
||||
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_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);
|
||||
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);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
||||
{
|
||||
EXPECT_FALSE(m_log.GetLogger(UTILSTESTS_LOGGER));
|
||||
EXPECT_FALSE(m_log.GetLogger(m_logger));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -73,66 +65,18 @@ TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
||||
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
|
||||
{
|
||||
[[maybe_unused]]
|
||||
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
|
||||
EXPECT_TRUE(m_log.GetLogger(UTILSTESTS_LOGGER));
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_logger);
|
||||
EXPECT_TRUE(m_log.GetLogger(m_logger));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
|
||||
{
|
||||
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
|
||||
const quill::Logger* logger = m_log.RegisterLogger(m_logger);
|
||||
|
||||
m_log.ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
|
||||
m_log.ChangeLoggerLogLevel(m_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
|
||||
|
||||
64
Bigfoot/Tests/Utils/Log/LogMacros.cpp
Normal file
64
Bigfoot/Tests/Utils/Log/LogMacros.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*********************************************************************
|
||||
* \file LogMacros.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date May 2026
|
||||
*********************************************************************/
|
||||
#include <Utils/Log/LogMacros.hpp>
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogTrace)
|
||||
{
|
||||
BIGFOOT_LOG_TRACE(m_logger, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogInfo)
|
||||
{
|
||||
BIGFOOT_LOG_INFO(m_logger, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogWarn)
|
||||
{
|
||||
BIGFOOT_LOG_WARN(m_logger, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogError)
|
||||
{
|
||||
BIGFOOT_LOG_ERROR(m_logger, "Hello");
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(LogMacrosFixture, LogFatal)
|
||||
{
|
||||
BIGFOOT_LOG_FATAL(m_logger, "Hello");
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
@@ -42,7 +42,7 @@ class SingletonTest
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t Data() const
|
||||
std::uint32_t GetData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
@@ -84,19 +84,19 @@ TEST_F(SingletonFixture, ConstructorAndDestructorShouldBeCalled)
|
||||
{
|
||||
::testing::InSequence seq;
|
||||
|
||||
EXPECT_CALL(*m_mock, Construct());
|
||||
EXPECT_CALL(*m_mock, Destruct());
|
||||
EXPECT_CALL(*m_mock, Construct()).Times(1);
|
||||
EXPECT_CALL(*m_mock, Destruct()).Times(1);
|
||||
|
||||
Singleton<SingletonTest>::Lifetime singleton {42};
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SingletonFixture, Instance_ShouldReturnTheInstance)
|
||||
TEST_F(SingletonFixture, GetInstance_ShouldReturnTheInstance)
|
||||
{
|
||||
Singleton<SingletonTest>::Lifetime singleton {42};
|
||||
|
||||
EXPECT_EQ(Singleton<SingletonTest>::Instance().Data(), 42);
|
||||
EXPECT_EQ(Singleton<SingletonTest>::GetInstance().GetData(), 42);
|
||||
}
|
||||
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -35,26 +35,26 @@ TEST_F(VersionFixture, uint32_t)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(VersionFixture, Major_ShouldBeEqualToTheMajorPartOfTheVersion)
|
||||
TEST_F(VersionFixture, GetMajor_ShouldBeEqualToTheMajorPartOfTheVersion)
|
||||
{
|
||||
EXPECT_EQ(m_detailed.Major(), 1);
|
||||
EXPECT_EQ(m_combined.Major(), 1);
|
||||
EXPECT_EQ(m_detailed.GetMajor(), 1);
|
||||
EXPECT_EQ(m_combined.GetMajor(), 1);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(VersionFixture, Minor_ShouldBeEqualToTheMinorPartOfTheVersion)
|
||||
TEST_F(VersionFixture, GetMinor_ShouldBeEqualToTheMinorPartOfTheVersion)
|
||||
{
|
||||
EXPECT_EQ(m_detailed.Minor(), 2);
|
||||
EXPECT_EQ(m_combined.Minor(), 2);
|
||||
EXPECT_EQ(m_detailed.GetMinor(), 2);
|
||||
EXPECT_EQ(m_combined.GetMinor(), 2);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(VersionFixture, Patch_ShouldBeEqualToThePatchPartOfTheVersion)
|
||||
TEST_F(VersionFixture, GetPatch_ShouldBeEqualToThePatchPartOfTheVersion)
|
||||
{
|
||||
EXPECT_EQ(m_detailed.Patch(), 3);
|
||||
EXPECT_EQ(m_combined.Patch(), 3);
|
||||
EXPECT_EQ(m_detailed.GetPatch(), 3);
|
||||
EXPECT_EQ(m_combined.GetPatch(), 3);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user