Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 8m15s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m28s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m22s
Bigfoot / Clang Format Checks (push) Successful in 8s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m25s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m1s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m44s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m30s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m52s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m24s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m17s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m35s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m49s
94 lines
3.4 KiB
C++
94 lines
3.4 KiB
C++
/*********************************************************************
|
|
* \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 AssetLibraryFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
AssetContainer<AssetA> m_containerA;
|
|
AssetContainer<AssetB> m_containerB;
|
|
AssetContainer<AssetC> m_containerC;
|
|
|
|
AssetLibrary m_library;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnTrueOnSuccess)
|
|
{
|
|
EXPECT_TRUE(m_library.Insert(&m_containerA));
|
|
EXPECT_TRUE(m_library.Insert(&m_containerB));
|
|
EXPECT_TRUE(m_library.Insert(&m_containerC));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnFalseOnDuplicate)
|
|
{
|
|
std::ignore = m_library.Insert(&m_containerA);
|
|
EXPECT_FALSE(m_library.Insert(&m_containerA));
|
|
|
|
AssetContainer<AssetA> m_containerAA;
|
|
EXPECT_FALSE(m_library.Insert(&m_containerAA));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnTheAssetContainerIfAvailable)
|
|
{
|
|
std::ignore = m_library.Insert(&m_containerA);
|
|
std::ignore = m_library.Insert(&m_containerB);
|
|
std::ignore = m_library.Insert(&m_containerC);
|
|
|
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
|
|
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnNullptrIfTheContainerDoesNotExist)
|
|
{
|
|
std::ignore = m_library.Insert(&m_containerB);
|
|
|
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, SetActiveAssetLibrary_ShouldSetTheActiveAssetLibraryToTheGivenLibrary)
|
|
{
|
|
SetActiveAssetLibrary(&m_library);
|
|
EXPECT_EQ(g_activeAssetLibrary, &m_library);
|
|
SetActiveAssetLibrary(&g_assetLibrary);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(AssetLibraryFixture, ScopedActiveAssetLibrary_ShouldChangeTheActiveAssetLibraryInAScopedWay)
|
|
{
|
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
|
{
|
|
ScopedActiveAssetLibrary activeAssetLibraryScoped {&m_library};
|
|
EXPECT_EQ(g_activeAssetLibrary, &m_library);
|
|
}
|
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
|
}
|
|
} // namespace Bigfoot
|