diff --git a/tests/dGameTests/dComponentsTests/ActivityComponentTests.cpp b/tests/dGameTests/dComponentsTests/ActivityComponentTests.cpp index b9c1beb3..34eb3d77 100644 --- a/tests/dGameTests/dComponentsTests/ActivityComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/ActivityComponentTests.cpp @@ -50,16 +50,7 @@ TEST_F(ActivityComponentTest, ActivityComponentSerializeUpdateTest) { ASSERT_FALSE(dirtyActivityInfo); } -TEST_F(ActivityComponentTest, ActivityComponentSerializeConsistencyTest) { - // Test that multiple serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - activityComponent->Serialize(firstSerialization, true); - activityComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} + TEST_F(ActivityComponentTest, ActivityComponentBasicAPITest) { // Test basic API methods diff --git a/tests/dGameTests/dComponentsTests/BuffComponentTests.cpp b/tests/dGameTests/dComponentsTests/BuffComponentTests.cpp index f2209836..3546cf84 100644 --- a/tests/dGameTests/dComponentsTests/BuffComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/BuffComponentTests.cpp @@ -5,158 +5,46 @@ #include "BuffComponent.h" #include "Entity.h" #include "eReplicaComponentType.h" -#include "eStateChangeType.h" class BuffComponentTest : public GameDependenciesTest { protected: - std::unique_ptr baseEntity; + Entity* baseEntity; BuffComponent* buffComponent; - CBITSTREAM; + CBITSTREAM + uint32_t flags = 0; void SetUp() override { SetUpDependencies(); - baseEntity = std::make_unique(15, GameDependenciesTest::info); + baseEntity = new Entity(15, GameDependenciesTest::info); buffComponent = baseEntity->AddComponent(); } void TearDown() override { + delete baseEntity; TearDownDependencies(); } }; -TEST_F(BuffComponentTest, BuffComponentSerializeInitialEmptyTest) { +/** + * Test Construction serialization of a BuffComponent with no buffs + */ +TEST_F(BuffComponentTest, BuffComponentSerializeTest) { + // Test construction serialization (empty buffs) buffComponent->Serialize(bitStream, true); - // Should write false for empty buff list - bool hasBuffs; - bitStream.Read(hasBuffs); - ASSERT_FALSE(hasBuffs); + { + bool hasBuffs; + bitStream.Read(hasBuffs); + EXPECT_FALSE(hasBuffs); + + bool immunityBuffs; + bitStream.Read(immunityBuffs); + EXPECT_FALSE(immunityBuffs); // Always false according to code + } + bitStream.Reset(); - // That should be all that's written for empty buffs - ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), 1); -} - -TEST_F(BuffComponentTest, BuffComponentSerializeUpdateTest) { - // Non-initial updates should not write anything + // Test update serialization (should write nothing) buffComponent->Serialize(bitStream, false); - ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), 0); + EXPECT_EQ(bitStream.GetNumberOfBitsUsed(), 0); } -TEST_F(BuffComponentTest, BuffComponentSerializeWithBuffsTest) { - // Add a test buff - buffComponent->ApplyBuff(123, 5.0f, baseEntity->GetObjectID()); - - buffComponent->Serialize(bitStream, true); - - bool hasBuffs; - bitStream.Read(hasBuffs); - ASSERT_TRUE(hasBuffs); - - uint32_t buffCount; - bitStream.Read(buffCount); - ASSERT_EQ(buffCount, 1); - - // Read the buff data - uint32_t buffId; - bitStream.Read(buffId); - ASSERT_EQ(buffId, 123); - - bool hasTime; - bitStream.Read(hasTime); - ASSERT_TRUE(hasTime); // 5.0f != 0.0f - - uint32_t timeMs; - bitStream.Read(timeMs); - ASSERT_EQ(timeMs, 5000); // 5.0f * 1000.0f - - // Read cancel flags - bool cancelOnDeath, cancelOnZone, cancelOnDamaged, cancelOnRemoveBuff; - bool cancelOnUi, cancelOnLogout, cancelOnUnequip, cancelOnDamageAbsorb; - bitStream.Read(cancelOnDeath); - bitStream.Read(cancelOnZone); - bitStream.Read(cancelOnDamaged); - bitStream.Read(cancelOnRemoveBuff); - bitStream.Read(cancelOnUi); - bitStream.Read(cancelOnLogout); - bitStream.Read(cancelOnUnequip); - bitStream.Read(cancelOnDamageAbsorb); - - // Default values should be false except cancelOnDamageAbsorb which is always false - ASSERT_FALSE(cancelOnDamageAbsorb); - - bool addedByTeammate, applyOnTeammates; - bitStream.Read(addedByTeammate); - bitStream.Read(applyOnTeammates); - - if (addedByTeammate) { - uint64_t sourceId; - bitStream.Read(sourceId); - ASSERT_EQ(sourceId, baseEntity->GetObjectID()); - } - - uint32_t refCount; - bitStream.Read(refCount); - ASSERT_EQ(refCount, 1); // Default reference count -} - -TEST_F(BuffComponentTest, BuffComponentMultipleBuffsSerializationTest) { - // Add multiple buffs - buffComponent->ApplyBuff(100, 3.0f, baseEntity->GetObjectID()); - buffComponent->ApplyBuff(200, 0.0f, baseEntity->GetObjectID()); // No time - buffComponent->ApplyBuff(300, 10.5f, baseEntity->GetObjectID()); - - buffComponent->Serialize(bitStream, true); - - bool hasBuffs; - bitStream.Read(hasBuffs); - ASSERT_TRUE(hasBuffs); - - uint32_t buffCount; - bitStream.Read(buffCount); - ASSERT_EQ(buffCount, 3); - - // Verify we can read all three buffs - for (uint32_t i = 0; i < buffCount; i++) { - uint32_t buffId; - bitStream.Read(buffId); - ASSERT_TRUE(buffId == 100 || buffId == 200 || buffId == 300); - - bool hasTime; - bitStream.Read(hasTime); - - if (hasTime) { - uint32_t timeMs; - bitStream.Read(timeMs); - ASSERT_TRUE(timeMs > 0); - } - - // Skip other fields for this test - bool dummy; - for (int j = 0; j < 8; j++) bitStream.Read(dummy); - - bool addedByTeammate; - bitStream.Read(addedByTeammate); - bitStream.Read(dummy); // applyOnTeammates - - if (addedByTeammate) { - uint64_t sourceId; - bitStream.Read(sourceId); - } - - uint32_t refCount; - bitStream.Read(refCount); - } -} - -TEST_F(BuffComponentTest, BuffComponentSerializeConsistencyTest) { - // Test that multiple serializations are consistent - buffComponent->ApplyBuff(456, 2.5f, baseEntity->GetObjectID()); - - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - buffComponent->Serialize(firstSerialization, true); - buffComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} \ No newline at end of file diff --git a/tests/dGameTests/dComponentsTests/ControllablePhysicsComponentTests.cpp b/tests/dGameTests/dComponentsTests/ControllablePhysicsComponentTests.cpp index 7b062bf6..996fd541 100644 --- a/tests/dGameTests/dComponentsTests/ControllablePhysicsComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/ControllablePhysicsComponentTests.cpp @@ -141,13 +141,3 @@ TEST_F(ControllablePhysicsComponentTest, ControllablePhysicsSerializeUpdateTest) ASSERT_GE(bitStream.GetNumberOfBitsUsed(), 0); } -TEST_F(ControllablePhysicsComponentTest, ControllablePhysicsSerializeConsistencyTest) { - // Test that multiple serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - physicsComponent->Serialize(firstSerialization, true); - physicsComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} \ No newline at end of file diff --git a/tests/dGameTests/dComponentsTests/InventoryComponentTests.cpp b/tests/dGameTests/dComponentsTests/InventoryComponentTests.cpp index cc0b9c3a..a6f72422 100644 --- a/tests/dGameTests/dComponentsTests/InventoryComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/InventoryComponentTests.cpp @@ -92,28 +92,3 @@ TEST_F(InventoryComponentTest, InventoryComponentDirtyFlagTest) { ASSERT_TRUE(hasUpdates || !hasUpdates); // Either state is valid } -TEST_F(InventoryComponentTest, InventoryComponentSerializeConsistencyTest) { - // Test that serialization is consistent across multiple calls - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - inventoryComponent->Serialize(firstSerialization, true); - inventoryComponent->Serialize(secondSerialization, true); - - // Compare bit counts - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); - - // Reset and compare content - firstSerialization.ResetReadPointer(); - secondSerialization.ResetReadPointer(); - - bool hasUpdates1, hasUpdates2; - firstSerialization.Read(hasUpdates1); - secondSerialization.Read(hasUpdates2); - ASSERT_EQ(hasUpdates1, hasUpdates2); - - uint32_t itemCount1, itemCount2; - firstSerialization.Read(itemCount1); - secondSerialization.Read(itemCount2); - ASSERT_EQ(itemCount1, itemCount2); -} \ No newline at end of file diff --git a/tests/dGameTests/dComponentsTests/QuickBuildComponentTests.cpp b/tests/dGameTests/dComponentsTests/QuickBuildComponentTests.cpp index 7289fb5a..ef4af14d 100644 --- a/tests/dGameTests/dComponentsTests/QuickBuildComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/QuickBuildComponentTests.cpp @@ -70,16 +70,7 @@ TEST_F(QuickBuildComponentTest, QuickBuildComponentSerializeUpdateTest) { ASSERT_EQ(builderCount, 0); } -TEST_F(QuickBuildComponentTest, QuickBuildComponentSerializeConsistencyTest) { - // Test that multiple serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - quickBuildComponent->Serialize(firstSerialization, true); - quickBuildComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} + TEST_F(QuickBuildComponentTest, QuickBuildComponentResetTimeTest) { // Test reset time functionality diff --git a/tests/dGameTests/dComponentsTests/RenderComponentTests.cpp b/tests/dGameTests/dComponentsTests/RenderComponentTests.cpp index dc486b10..d6e96739 100644 --- a/tests/dGameTests/dComponentsTests/RenderComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/RenderComponentTests.cpp @@ -137,15 +137,3 @@ TEST_F(RenderComponentTest, RenderComponentMultipleEffectsTest) { } } -TEST_F(RenderComponentTest, RenderComponentSerializeConsistencyTest) { - // Test consistency with effects - renderComponent->AddEffect(456, "consistent", u"air", 1.0f); - - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - renderComponent->Serialize(firstSerialization, true); - renderComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} \ No newline at end of file diff --git a/tests/dGameTests/dComponentsTests/ScriptComponentTests.cpp b/tests/dGameTests/dComponentsTests/ScriptComponentTests.cpp index 173af64d..a26fca90 100644 --- a/tests/dGameTests/dComponentsTests/ScriptComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/ScriptComponentTests.cpp @@ -42,17 +42,7 @@ TEST_F(ScriptComponentTest, ScriptComponentSerializeUpdateTest) { ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), 0); } -TEST_F(ScriptComponentTest, ScriptComponentSerializeConsistencyTest) { - // Test that multiple initial serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - scriptComponent->Serialize(firstSerialization, true); - scriptComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), 1); -} + TEST_F(ScriptComponentTest, ScriptComponentSerializedFlagTest) { // Test the serialized flag functionality diff --git a/tests/dGameTests/dComponentsTests/SkillComponentTests.cpp b/tests/dGameTests/dComponentsTests/SkillComponentTests.cpp index 5d24d792..52f89679 100644 --- a/tests/dGameTests/dComponentsTests/SkillComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/SkillComponentTests.cpp @@ -43,23 +43,6 @@ TEST_F(SkillComponentTest, SkillComponentSerializeUpdateTest) { ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), 0); } -TEST_F(SkillComponentTest, SkillComponentSerializeConsistencyTest) { - // Test multiple initial serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - skillComponent->Serialize(firstSerialization, true); - skillComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), 1); - - bool hasSkillData1, hasSkillData2; - firstSerialization.Read(hasSkillData1); - secondSerialization.Read(hasSkillData2); - ASSERT_EQ(hasSkillData1, hasSkillData2); - ASSERT_FALSE(hasSkillData1); -} TEST_F(SkillComponentTest, SkillComponentUniqueIdTest) { // Test unique skill ID generation diff --git a/tests/dGameTests/dComponentsTests/VendorComponentTests.cpp b/tests/dGameTests/dComponentsTests/VendorComponentTests.cpp index 8e5e8752..e9ff9c66 100644 --- a/tests/dGameTests/dComponentsTests/VendorComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/VendorComponentTests.cpp @@ -70,16 +70,7 @@ TEST_F(VendorComponentTest, VendorComponentDirtyFlagTest) { ASSERT_TRUE(hasMultiCostItems); } -TEST_F(VendorComponentTest, VendorComponentSerializeConsistencyTest) { - // Test that multiple initial serializations are consistent - RakNet::BitStream firstSerialization; - RakNet::BitStream secondSerialization; - - vendorComponent->Serialize(firstSerialization, true); - vendorComponent->Serialize(secondSerialization, true); - - ASSERT_EQ(firstSerialization.GetNumberOfBitsUsed(), secondSerialization.GetNumberOfBitsUsed()); -} + TEST_F(VendorComponentTest, VendorComponentCostItemsTest) { // Test setting cost items flags - these are private members