diff --git a/Bigfoot/Sources/Engine/Include/Engine/Asset/Asset.hpp b/Bigfoot/Sources/Engine/Include/Engine/Asset/Asset.hpp index be84b78..6ace46a 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Asset/Asset.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Asset/Asset.hpp @@ -130,7 +130,6 @@ class Asset: public AssetBase flatbuffers::GetRoot(asset->inner_asset()->data())->UnPackTo(&m_asset, nullptr); } -#ifdef BIGFOOT_TOOLMODE /** * Pack the asset to a flatbuffer * @@ -150,7 +149,6 @@ class Asset: public AssetBase return eastl::vector {std::bit_cast(assetFbb.GetBufferPointer()), std::bit_cast(assetFbb.GetBufferPointer() + assetFbb.GetSize())}; } -#endif /** * Get the AssetTypeID diff --git a/Bigfoot/Tests/Engine/Asset/Asset.cpp b/Bigfoot/Tests/Engine/Asset/Asset.cpp index b927950..97a1944 100644 --- a/Bigfoot/Tests/Engine/Asset/Asset.cpp +++ b/Bigfoot/Tests/Engine/Asset/Asset.cpp @@ -16,26 +16,6 @@ namespace Bigfoot class AssetFixture: public ::testing::Test { protected: - /** - * Packs a header and an asset the same way Asset::Pack() does. Pack() is intentionally - * BIGFOOT_TOOLMODE-only: game code must never be able to build asset buffers. - */ - template - static eastl::vector PackAssetBuffer(const ::Flat::Bigfoot::AssetHeaderT& p_header, - const typename ASSET::FLAT_ASSET::NativeTableType& p_asset) - { - flatbuffers::FlatBufferBuilder innerAssetFbb; - innerAssetFbb.Finish(ASSET::FLAT_ASSET::Pack(innerAssetFbb, &p_asset)); - - flatbuffers::FlatBufferBuilder assetFbb; - const auto header = ::Flat::Bigfoot::AssetHeader::Pack(assetFbb, &p_header); - const auto innerAsset = assetFbb.CreateVector(innerAssetFbb.GetBufferPointer(), innerAssetFbb.GetSize()); - assetFbb.Finish(::Flat::Bigfoot::CreateAsset(assetFbb, header, innerAsset)); - - return eastl::vector {std::bit_cast(assetFbb.GetBufferPointer()), - std::bit_cast(assetFbb.GetBufferPointer() + assetFbb.GetSize())}; - } - AssetA m_asset; }; @@ -100,32 +80,6 @@ TEST_F(AssetFixture, GetTypeName_ShouldReturnTheFlatbufferFullyQualifiedName) /****************************************************************************************/ -TEST_F(AssetFixture, Unpack_ShouldPopulateTheHeaderAndTheAsset) -{ - ::Flat::Bigfoot::AssetHeaderT header; - header.name = "MyAsset"; - header.version = 3; - header.type_id = AssetA::GetTypeID(); - header.type_name = eastl::string {AssetA::GetTypeName()}; - - AssetA::FLAT_ASSET::NativeTableType inner; - inner.health = 42; - inner.mana = 7; - - m_asset.Unpack(PackAssetBuffer(header, inner)); - - EXPECT_EQ(m_asset.GetHeader().uuid, header.uuid); - EXPECT_STREQ(m_asset.GetHeader().name.c_str(), header.name.c_str()); - EXPECT_EQ(m_asset.GetHeader().version, header.version); - EXPECT_EQ(m_asset.GetHeader().type_id, header.type_id); - EXPECT_STREQ(m_asset.GetHeader().type_name.c_str(), header.type_name.c_str()); - EXPECT_EQ(m_asset.GetAsset().health, 42); - EXPECT_EQ(m_asset.GetAsset().mana, 7); -} - -/****************************************************************************************/ - -#ifdef BIGFOOT_TOOLMODE TEST_F(AssetFixture, PackThenUnpack_ShouldRoundTripTheHeaderAndTheAsset) { m_asset.SetName("MyAsset"); @@ -144,5 +98,4 @@ TEST_F(AssetFixture, PackThenUnpack_ShouldRoundTripTheHeaderAndTheAsset) EXPECT_EQ(unpacked.GetAsset().health, m_asset.GetAsset().health); EXPECT_EQ(unpacked.GetAsset().mana, m_asset.GetAsset().mana); } -#endif } // namespace Bigfoot diff --git a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp index 41660d7..9eb8a05 100644 --- a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp +++ b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp @@ -141,7 +141,11 @@ TEST_F(AssetContainerFixture, Insert_ShouldReturnValidAndUniqueSlotKeyOnInsert) TEST_F(AssetContainerFixture, Insert_ShouldReturnTheSameSlotKeyInCaseOfDuplicatedUUID) { const SlotMapKey slotKey = m_containerA.Insert(); - EXPECT_EQ(slotKey, m_containerA.Insert()); + + AssetA duplicate; + duplicate.Unpack(m_containerA.Get(slotKey)->Pack()); + + EXPECT_EQ(slotKey, m_containerA.Insert(std::move(duplicate))); } /****************************************************************************************/