ContainerHandle test
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m13s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m34s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m33s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 5m55s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 5m54s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m2s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m9s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m13s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Failing after 5m49s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Failing after 5m52s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Failing after 6m34s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Failing after 6m34s
Bigfoot / Clang Format Checks (push) Failing after 0s

This commit is contained in:
2026-08-17 18:32:02 +02:00
parent 6bc25a776e
commit 39d2ddbe49
3 changed files with 40 additions and 8 deletions
@@ -146,9 +146,9 @@ class AssetContainerBase
* \return A ContainerHandle for the UUID * \return A ContainerHandle for the UUID
*/ */
[[nodiscard]] [[nodiscard]]
ContainerHandle& AcquireContainerHandle(const UUID& p_uuid) ContainerHandle* AcquireContainerHandle(const UUID& p_uuid)
{ {
return *m_handles.Get(GetOrCreateEntry(p_uuid).m_handleSlotKey); return m_handles.Get(GetOrCreateEntry(p_uuid).m_handleSlotKey);
} }
/* /*
@@ -116,7 +116,7 @@ class HardReference
{ {
if (!m_handle) if (!m_handle)
{ {
m_handle = &assetContainer->AcquireContainerHandle(m_uuid); m_handle = assetContainer->AcquireContainerHandle(m_uuid);
} }
m_handle->IncrementSoftRefCount(); m_handle->IncrementSoftRefCount();
} }
@@ -234,7 +234,7 @@ class SoftReference
{ {
if (!m_handle) if (!m_handle)
{ {
m_handle = &assetContainer->AcquireContainerHandle(m_uuid); m_handle = assetContainer->AcquireContainerHandle(m_uuid);
} }
m_handle->IncrementSoftRefCount(); m_handle->IncrementSoftRefCount();
} }
+36 -4
View File
@@ -11,6 +11,38 @@
namespace Bigfoot namespace Bigfoot
{ {
class ContainerHandleFixture: public ::testing::Test
{
protected:
void SetUp() override
{
std::ignore = m_containerA.Insert(m_asset);
m_handle = m_containerA.AcquireContainerHandle(m_asset.GetHeader().uuid);
}
AssetA m_asset;
AssetContainer<AssetA> m_containerA;
ContainerHandle* m_handle;
};
/****************************************************************************************/
TEST_F(ContainerHandleFixture, GetAsset_ShouldReturnTheAsset)
{
EXPECT_NE(m_handle->GetAsset(), nullptr);
}
/****************************************************************************************/
TEST_F(ContainerHandleFixture, GetAsset_ShouldReturnNullptrIfTheAssetHasBeenRemoved)
{
m_containerA.Remove(m_asset.GetHeader().uuid);
EXPECT_EQ(m_handle->GetAsset(), nullptr);
}
/****************************************************************************************/
class AssetContainerFixture: public ::testing::Test class AssetContainerFixture: public ::testing::Test
{ {
protected: protected:
@@ -41,8 +73,8 @@ TEST_F(AssetContainerFixture, AcquireHandle_ShouldReturnTheAssociatedContainerHa
AssetA asset1; AssetA asset1;
std::ignore = m_containerA.Insert(asset1); std::ignore = m_containerA.Insert(asset1);
const ContainerHandle& handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid); const ContainerHandle* handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
EXPECT_EQ(static_cast<const AssetA*>(handle.GetAsset())->GetHeader().uuid, asset1.GetHeader().uuid); EXPECT_EQ(static_cast<const AssetA*>(handle->GetAsset())->GetHeader().uuid, asset1.GetHeader().uuid);
} }
/****************************************************************************************/ /****************************************************************************************/
@@ -51,8 +83,8 @@ TEST_F(AssetContainerFixture, AcquireHandle_ShouldCreateTheAssociatedContainerHa
{ {
AssetA asset1; AssetA asset1;
const ContainerHandle& handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid); const ContainerHandle* handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
EXPECT_EQ(handle.GetAsset(), nullptr); EXPECT_EQ(handle->GetAsset(), nullptr);
} }
/****************************************************************************************/ /****************************************************************************************/