Skip to content

Commit

Permalink
reviving this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jadebenn committed Nov 18, 2024
1 parent ec7d0bf commit 42d3c73
Showing 1 changed file with 48 additions and 13 deletions.
61 changes: 48 additions & 13 deletions tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ TEST_F(GameMessageTests, SendBlueprintLoadItemResponse) {
TEST_F(GameMessageTests, ControlBehaviorAddStrip) {
auto data = ReadFromFile("addStrip");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -103,7 +106,10 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) {
TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) {
auto data = ReadFromFile("removeStrip");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&data[0]), data.length(), true);
RemoveStripMessage removeStrip(ReadArrayFromBitStream(inStream));

const auto arr = ReadArrayFromBitStream(inStream);
RemoveStripMessage removeStrip(*arr);

ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStripId()), 1);
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStateId()), 0);
ASSERT_EQ(removeStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
Expand All @@ -112,7 +118,10 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) {
TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
auto data = ReadFromFile("mergeStrips");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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<uint32_t>(mergeStrips.GetSourceActionContext().GetStateId()), 0);
Expand All @@ -124,9 +133,11 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
TEST_F(GameMessageTests, ControlBehaviorSplitStrip) {
auto data = ReadFromFile("splitStrip");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -139,7 +150,10 @@ TEST_F(GameMessageTests, ControlBehaviorSplitStrip) {
TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) {
auto data = ReadFromFile("updateStripUI");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -150,7 +164,10 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) {
TEST_F(GameMessageTests, ControlBehaviorAddAction) {
auto data = ReadFromFile("addAction");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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<uint32_t>(addAction.GetActionContext().GetStateId()), 0);
Expand All @@ -164,7 +181,10 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) {
TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
auto data = ReadFromFile("migrateActions");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -177,7 +197,10 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
auto data = ReadFromFile("rearrangeStrip");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -188,15 +211,21 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
TEST_F(GameMessageTests, ControlBehaviorAdd) {
auto data = ReadFromFile("add");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
}

TEST_F(GameMessageTests, ControlBehaviorRemoveActions) {
auto data = ReadFromFile("removeActions");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
Expand All @@ -206,15 +235,21 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveActions) {
TEST_F(GameMessageTests, ControlBehaviorRename) {
auto data = ReadFromFile("rename");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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);
}

TEST_F(GameMessageTests, ControlBehaviorUpdateAction) {
auto data = ReadFromFile("updateAction");
RakNet::BitStream inStream(reinterpret_cast<unsigned char*>(&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(), "");
Expand Down

0 comments on commit 42d3c73

Please sign in to comment.