Cleaner separation
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m50s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m7s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m27s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m22s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m40s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m41s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m40s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m38s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m44s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m45s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m16s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m20s
Bigfoot / Clang Format Checks (push) Failing after 11s

This commit is contained in:
2026-05-02 18:50:07 +02:00
parent c925cba3a1
commit b9b837137b
23 changed files with 189 additions and 133 deletions

View File

@@ -0,0 +1,107 @@
/*********************************************************************
* \file BigFile.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <Engine/Asset/Asset.hpp>
#include <Engine/EngineLogger_generated.hpp>
#include <System/Log/Log.hpp>
#include <Utils/Singleton.hpp>
#include <Utils/TargetMacros.h>
#include <EngineTests/Asset/AssetA.hpp>
#include <flatbuffers/reflection.h>
#include <gtest/gtest.h>
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;)
};
/****************************************************************************************/
TEST_F(AssetFixture, Asset)
{
constexpr eastl::string_view name = "Hello";
constexpr std::uint32_t version = 42;
constexpr std::uint32_t health = 100;
constexpr std::uint32_t mana = 50;
AssetA assetA;
assetA.SetName(name);
assetA.SetVersion(version);
assetA.GetAsset().health = health;
assetA.GetAsset().mana = mana;
const eastl::vector<std::byte> test = assetA.Pack();
AssetA assetB {test};
EXPECT_EQ(assetA.GetHeader().uuid, assetB.GetHeader().uuid);
EXPECT_EQ(assetA.GetHeader().type_id, AssetA::GetTypeID());
EXPECT_EQ(assetA.GetHeader().type_id, assetB.GetHeader().type_id);
EXPECT_EQ(assetA.GetHeader().type_name, AssetA::GetTypeName());
EXPECT_EQ(assetA.GetHeader().type_name, assetB.GetHeader().type_name);
EXPECT_EQ(assetA.GetHeader().name, name);
EXPECT_EQ(assetA.GetHeader().name, assetB.GetHeader().name);
EXPECT_EQ(assetA.GetHeader().version, version);
EXPECT_EQ(assetA.GetHeader().version, assetB.GetHeader().version);
EXPECT_EQ(assetA.GetHeader().dependencies, assetB.GetHeader().dependencies);
EXPECT_EQ(assetA.GetAsset().health, health);
EXPECT_EQ(assetA.GetAsset().health, assetB.GetAsset().health);
EXPECT_EQ(assetA.GetAsset().mana, mana);
EXPECT_EQ(assetA.GetAsset().mana, assetB.GetAsset().mana);
}
/****************************************************************************************/
TEST_F(AssetFixture, Reflection)
{
[[maybe_unused]]
const reflection::Schema* reflection = reflection::GetSchema(AssetA::ReflectionInfo().data());
for (const auto test: *reflection->root_table()->fields())
{
eastl::string typeName;
if (test->type()->base_type() == reflection::BaseType::Obj)
{
const reflection::Object* obj = reflection->objects()->Get(test->type()->index());
typeName = obj->name()->c_str();
}
else if (test->type()->base_type() == reflection::BaseType::Vector &&
test->type()->element() == reflection::BaseType::Obj)
{
const reflection::Object* obj = reflection->objects()->Get(test->type()->index());
typeName = eastl::string("[") + obj->name()->c_str() + "]";
}
else
{
typeName = reflection::EnumNameBaseType(test->type()->base_type());
}
BIGFOOT_LOG_INFO(ENGINE_LOGGER, "{} {}", typeName, test->name()->c_str());
}
}
} // namespace Bigfoot

View File

@@ -15,7 +15,6 @@
#include <Utils/Singleton.hpp>
#include <Utils/TargetMacros.h>
#include <EngineTests/BigFile/Asset/AssetA.hpp>
#include <EngineTests/BigFileInfo_generated.hpp>
#include <ankerl/unordered_dense.h>
@@ -50,20 +49,7 @@ class BigFileFixture: public ::testing::Test
/****************************************************************************************/
TEST_F(BigFileFixture, Asset)
{
AssetA assetA;
assetA.SetName("Hello");
assetA.SetVersion(42);
const eastl::vector<std::byte> test = assetA.Pack();
AssetA assetB {test};
}
/****************************************************************************************/
TEST_F(BigFileFixture, Lol)
TEST_F(BigFileFixture, BigFileManipulation)
{
UUID uuid;
UUID uuid2;
@@ -245,54 +231,4 @@ TEST_F(BigFileFixture, Lol)
EXPECT_FALSE(get);
}
}
/*TEST_F(BigFileFixture, Reflection)
{
[[maybe_unused]]
const reflection::Schema* reflection = reflection::GetSchema(AssetA::ReflectionInfo().data());
auto IsRef = [](const reflection::Object* obj) -> bool
{
if (!obj->attributes())
{
return false;
}
for (const auto attr: *obj->attributes())
{
if (std::strcmp(attr->key()->c_str(), "isRef") == 0)
{
return true;
}
}
return false;
};
for (const auto test: *reflection->root_table()->fields())
{
[[maybe_unused]]
std::string typeName;
[[maybe_unused]]
bool isRef = false;
if (test->type()->base_type() == reflection::BaseType::Obj)
{
const reflection::Object* obj = reflection->objects()->Get(test->type()->index());
typeName = obj->name()->c_str();
isRef = IsRef(obj);
}
else if (test->type()->base_type() == reflection::BaseType::Vector &&
test->type()->element() == reflection::BaseType::Obj)
{
const reflection::Object* obj = reflection->objects()->Get(test->type()->index());
typeName = std::string("[") + obj->name()->c_str() + "]";
isRef = IsRef(obj);
}
else
{
typeName = reflection::EnumNameBaseType(test->type()->base_type());
}
BIGFOOT_LOG_INFO(ENGINE_LOGGER, "{} {} {}", typeName, test->name()->c_str(), isRef ? "(isRef)" : "");
}
}*/
} // namespace Bigfoot

View File

@@ -6,9 +6,10 @@
*********************************************************************/
#ifndef BIGFOOT_ENGINE_ASSETA_HPP
#define BIGFOOT_ENGINE_ASSETA_HPP
#include <Engine/BigFile/Asset/Asset.hpp>
#include <Engine/Asset/Asset.hpp>
#include <EngineTests/BigFile/Asset/AssetA_generated.hpp>
#include <EngineTests/Asset/AssetA.bfbs_generated.hpp>
#include <EngineTests/Asset/AssetA_generated.hpp>
namespace Bigfoot
{
@@ -31,6 +32,11 @@ class AssetA: public Asset<Flat::AssetA>
AssetA& operator=(const AssetA& p_asset) = default;
[[nodiscard]]
AssetA& operator=(AssetA&& p_asset) = default;
static constexpr eastl::span<const std::byte> ReflectionInfo()
{
return g_AssetA_bfbs;
}
};
} // namespace Bigfoot