basic testing for reference
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m52s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m46s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m18s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 7m17s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m25s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 8m7s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m31s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m24s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m18s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m30s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m6s
Bigfoot / Clang Format Checks (push) Failing after 8s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m52s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m46s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m18s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 7m17s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m25s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 8m7s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m31s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m24s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m18s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m30s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m6s
Bigfoot / Clang Format Checks (push) Failing after 8s
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
/*********************************************************************
|
||||
* \file AssetLibrary.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date July 2026
|
||||
*********************************************************************/
|
||||
#include <Engine/Asset/AssetLibrary.hpp>
|
||||
|
||||
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
class HardReferenceFixture: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
SetActiveAssetLibrary(&m_library);
|
||||
|
||||
std::ignore = m_library.Insert(&m_containerA);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
SetActiveAssetLibrary(&g_assetLibrary);
|
||||
}
|
||||
|
||||
AssetContainer<AssetA> m_containerA;
|
||||
|
||||
AssetLibrary m_library;
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(HardReferenceFixture, GetUUID_ShouldReturnTheUUID)
|
||||
{
|
||||
UUID uuid;
|
||||
HardReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(HardReferenceFixture, Get_ShouldReturnTheAsset)
|
||||
{
|
||||
const auto key = m_containerA.Insert();
|
||||
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||
|
||||
HardReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.Get(), m_containerA.Get(key));
|
||||
EXPECT_EQ(std::as_const(hardRef).Get(), std::as_const(m_containerA).Get(key));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(HardReferenceFixture, Get_ShouldReturnNullptrIfTheAssetDoesNotExist)
|
||||
{
|
||||
UUID uuid;
|
||||
HardReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
class SoftReferenceFixture: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
SetActiveAssetLibrary(&m_library);
|
||||
|
||||
std::ignore = m_library.Insert(&m_containerA);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
SetActiveAssetLibrary(&g_assetLibrary);
|
||||
}
|
||||
|
||||
AssetContainer<AssetA> m_containerA;
|
||||
|
||||
AssetLibrary m_library;
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SoftReferenceFixture, GetUUID_ShouldReturnTheUUID)
|
||||
{
|
||||
UUID uuid;
|
||||
SoftReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SoftReferenceFixture, Get_ShouldReturnTheAsset)
|
||||
{
|
||||
const auto key = m_containerA.Insert();
|
||||
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||
|
||||
SoftReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.Get(), m_containerA.Get(key));
|
||||
EXPECT_EQ(std::as_const(hardRef).Get(), std::as_const(m_containerA).Get(key));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(SoftReferenceFixture, Get_ShouldReturnNullptrIfTheAssetDoesNotExist)
|
||||
{
|
||||
UUID uuid;
|
||||
SoftReference<AssetA> hardRef {uuid};
|
||||
|
||||
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
Reference in New Issue
Block a user