Bigfoot / Clang Format Checks (push) Successful in 10s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 30s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 22s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 31s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 22s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 53s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 41s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 54s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 42s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 31s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 23s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 41s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 52s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 26s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 20s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 38s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 31s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 31s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 33s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 22s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 50s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 43s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 37s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 36s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 37s
103 lines
3.3 KiB
C++
103 lines
3.3 KiB
C++
/*********************************************************************
|
|
* \file Asset.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date August 2026
|
|
*********************************************************************/
|
|
#include <Engine/Asset/Asset.hpp>
|
|
|
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
class AssetFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
AssetA m_asset;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, Constructor_ShouldInitializeHeaderTypeIdAndTypeName)
|
|
{
|
|
EXPECT_EQ(m_asset.GetHeader().type_id, AssetA::GetTypeID());
|
|
EXPECT_EQ(m_asset.GetHeader().type_name, eastl::string {AssetA::GetTypeName()});
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, SetName_ShouldSetTheName)
|
|
{
|
|
m_asset.SetName("MyAsset");
|
|
|
|
EXPECT_STREQ(m_asset.GetHeader().name.c_str(), "MyAsset");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, SetVersion_ShouldSetTheVersion)
|
|
{
|
|
m_asset.SetVersion(5);
|
|
|
|
EXPECT_EQ(m_asset.GetHeader().version, 5);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, GetAsset_ShouldReturnAMutableReferenceToTheUnderlyingAsset)
|
|
{
|
|
m_asset.GetAsset().health = 10;
|
|
|
|
EXPECT_EQ(m_asset.GetAsset().health, 10);
|
|
EXPECT_EQ(std::as_const(m_asset).GetAsset().health, 10);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, GetTypeID_ShouldBeStableAcrossCalls)
|
|
{
|
|
EXPECT_EQ(AssetA::GetTypeID(), AssetA::GetTypeID());
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, GetTypeID_ShouldBeDifferentForDifferentAssetTypes)
|
|
{
|
|
EXPECT_NE(AssetA::GetTypeID(), AssetB::GetTypeID());
|
|
EXPECT_NE(AssetA::GetTypeID(), AssetC::GetTypeID());
|
|
EXPECT_NE(AssetB::GetTypeID(), AssetC::GetTypeID());
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, GetTypeName_ShouldReturnTheFlatbufferFullyQualifiedName)
|
|
{
|
|
EXPECT_EQ(AssetA::GetTypeName(), eastl::string_view {AssetA::FLAT_ASSET::GetFullyQualifiedName()});
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetFixture, PackThenUnpack_ShouldRoundTripTheHeaderAndTheAsset)
|
|
{
|
|
m_asset.SetName("MyAsset");
|
|
m_asset.SetVersion(3);
|
|
m_asset.GetAsset().health = 42;
|
|
m_asset.GetAsset().mana = 7;
|
|
|
|
AssetA unpacked;
|
|
unpacked.Unpack(m_asset.Pack());
|
|
|
|
EXPECT_EQ(unpacked.GetHeader().uuid, m_asset.GetHeader().uuid);
|
|
EXPECT_STREQ(unpacked.GetHeader().name.c_str(), m_asset.GetHeader().name.c_str());
|
|
EXPECT_EQ(unpacked.GetHeader().version, m_asset.GetHeader().version);
|
|
EXPECT_EQ(unpacked.GetHeader().type_id, m_asset.GetHeader().type_id);
|
|
EXPECT_STREQ(unpacked.GetHeader().type_name.c_str(), m_asset.GetHeader().type_name.c_str());
|
|
EXPECT_EQ(unpacked.GetAsset().health, m_asset.GetAsset().health);
|
|
EXPECT_EQ(unpacked.GetAsset().mana, m_asset.GetAsset().mana);
|
|
}
|
|
} // namespace Bigfoot
|