From 42d3c73cb1d9afa3a8920a64017ffc3d0e7c8998 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sun, 17 Nov 2024 21:45:05 -0600 Subject: [PATCH] reviving this branch --- .../dGameMessagesTests/GameMessageTests.cpp | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp index 528136e17..7c33c6d0f 100644 --- a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp +++ b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp @@ -88,7 +88,10 @@ TEST_F(GameMessageTests, SendBlueprintLoadItemResponse) { TEST_F(GameMessageTests, ControlBehaviorAddStrip) { auto data = ReadFromFile("addStrip"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - AddStripMessage addStrip(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + AddStripMessage addStrip(*arr); + ASSERT_FLOAT_EQ(addStrip.GetPosition().GetX(), 50.65); ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05); ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0); @@ -103,7 +106,10 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) { TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { auto data = ReadFromFile("removeStrip"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - RemoveStripMessage removeStrip(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + RemoveStripMessage removeStrip(*arr); + ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStripId()), 1); ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStateId()), 0); ASSERT_EQ(removeStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId); @@ -112,7 +118,10 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { auto data = ReadFromFile("mergeStrips"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - MergeStripsMessage mergeStrips(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + MergeStripsMessage mergeStrips(*arr); + ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2); ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0); ASSERT_EQ(static_cast(mergeStrips.GetSourceActionContext().GetStateId()), 0); @@ -124,9 +133,11 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { auto data = ReadFromFile("splitStrip"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - SplitStripMessage splitStrip(ReadArrayFromBitStream(inStream)); - ASSERT_EQ(splitStrip.GetBehaviorId(), -1); + const auto arr = ReadArrayFromBitStream(inStream); + SplitStripMessage splitStrip(*arr); + + ASSERT_EQ(splitStrip.GetBehaviorId(), -1); ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetX(), 275.65); ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetY(), 28.7); ASSERT_EQ(splitStrip.GetSourceActionContext().GetStripId(), 0); @@ -139,7 +150,10 @@ TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { auto data = ReadFromFile("updateStripUI"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - UpdateStripUiMessage updateStripUi(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + UpdateStripUiMessage updateStripUi(*arr); + ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetX(), 116.65); ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35); ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0); @@ -150,7 +164,10 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { TEST_F(GameMessageTests, ControlBehaviorAddAction) { auto data = ReadFromFile("addAction"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - AddActionMessage addAction(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + AddActionMessage addAction(*arr); + ASSERT_EQ(addAction.GetActionIndex(), 3); ASSERT_EQ(addAction.GetActionContext().GetStripId(), 0); ASSERT_EQ(static_cast(addAction.GetActionContext().GetStateId()), 0); @@ -164,7 +181,10 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) { TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { auto data = ReadFromFile("migrateActions"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - MigrateActionsMessage migrateActions(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + MigrateActionsMessage migrateActions(*arr); + ASSERT_EQ(migrateActions.GetSrcActionIndex(), 1); ASSERT_EQ(migrateActions.GetDstActionIndex(), 2); ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1); @@ -177,7 +197,10 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { auto data = ReadFromFile("rearrangeStrip"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - RearrangeStripMessage rearrangeStrip(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + RearrangeStripMessage rearrangeStrip(*arr); + ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2); ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1); ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0); @@ -188,7 +211,10 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { TEST_F(GameMessageTests, ControlBehaviorAdd) { auto data = ReadFromFile("add"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - AddMessage add(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + AddMessage add(*arr); + ASSERT_EQ(add.GetBehaviorId(), 10446); ASSERT_EQ(add.GetBehaviorIndex(), 0); } @@ -196,7 +222,10 @@ TEST_F(GameMessageTests, ControlBehaviorAdd) { TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { auto data = ReadFromFile("removeActions"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - RemoveActionsMessage removeActions(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + RemoveActionsMessage removeActions(*arr); + ASSERT_EQ(removeActions.GetBehaviorId(), -1); ASSERT_EQ(removeActions.GetActionIndex(), 1); ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0); @@ -206,7 +235,10 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { TEST_F(GameMessageTests, ControlBehaviorRename) { auto data = ReadFromFile("rename"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - RenameMessage rename(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + RenameMessage rename(*arr); + ASSERT_EQ(rename.GetName(), "test"); ASSERT_EQ(rename.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId); } @@ -214,7 +246,10 @@ TEST_F(GameMessageTests, ControlBehaviorRename) { TEST_F(GameMessageTests, ControlBehaviorUpdateAction) { auto data = ReadFromFile("updateAction"); RakNet::BitStream inStream(reinterpret_cast(&data[0]), data.length(), true); - UpdateActionMessage updateAction(ReadArrayFromBitStream(inStream)); + + const auto arr = ReadArrayFromBitStream(inStream); + UpdateActionMessage updateAction(*arr); + ASSERT_EQ(updateAction.GetAction().GetType(), "FlyDown"); ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance"); ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), "");