mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-21 14:58:09 +00:00
format codebase
This commit is contained in:
@@ -15,7 +15,7 @@ std::unique_ptr<AMFValue> ReadFromBitStream(RakNet::BitStream* bitStream) {
|
||||
|
||||
int ReadAMFUndefinedFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x00);
|
||||
bitStream.Write<uint8_t>(0x00);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFUndefined);
|
||||
return 0;
|
||||
@@ -23,7 +23,7 @@ int ReadAMFUndefinedFromBitStream() {
|
||||
|
||||
int ReadAMFNullFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFNull);
|
||||
return 0;
|
||||
@@ -31,7 +31,7 @@ int ReadAMFNullFromBitStream() {
|
||||
|
||||
int ReadAMFFalseFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x02);
|
||||
bitStream.Write<uint8_t>(0x02);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFFalse);
|
||||
return 0;
|
||||
@@ -39,7 +39,7 @@ int ReadAMFFalseFromBitStream() {
|
||||
|
||||
int ReadAMFTrueFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x03);
|
||||
bitStream.Write<uint8_t>(0x03);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFTrue);
|
||||
return 0;
|
||||
@@ -49,12 +49,12 @@ int ReadAMFIntegerFromBitStream() {
|
||||
CBITSTREAM
|
||||
{
|
||||
bitStream.Write<uint8_t>(0x04);
|
||||
// 127 == 01111111
|
||||
bitStream.Write<uint8_t>(127);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger);
|
||||
// Check that the max value of a byte can be read correctly
|
||||
ASSERT_EQ(static_cast<AMFIntegerValue*>(res.get())->GetIntegerValue(), 127);
|
||||
// 127 == 01111111
|
||||
bitStream.Write<uint8_t>(127);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger);
|
||||
// Check that the max value of a byte can be read correctly
|
||||
ASSERT_EQ(static_cast<AMFIntegerValue*>(res.get())->GetIntegerValue(), 127);
|
||||
}
|
||||
bitStream.Reset();
|
||||
{
|
||||
@@ -96,7 +96,7 @@ int ReadAMFIntegerFromBitStream() {
|
||||
|
||||
int ReadAMFDoubleFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x05);
|
||||
bitStream.Write<uint8_t>(0x05);
|
||||
bitStream.Write<double>(25346.4f);
|
||||
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
|
||||
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFDouble);
|
||||
@@ -106,7 +106,7 @@ int ReadAMFDoubleFromBitStream() {
|
||||
|
||||
int ReadAMFStringFromBitStream() {
|
||||
CBITSTREAM
|
||||
bitStream.Write<uint8_t>(0x06);
|
||||
bitStream.Write<uint8_t>(0x06);
|
||||
bitStream.Write<uint8_t>(0x0F);
|
||||
std::string toWrite = "stateID";
|
||||
for (auto e : toWrite) bitStream.Write<char>(e);
|
||||
@@ -118,8 +118,8 @@ int ReadAMFStringFromBitStream() {
|
||||
|
||||
int ReadAMFArrayFromBitStream() {
|
||||
CBITSTREAM
|
||||
// Test empty AMFArray
|
||||
bitStream.Write<uint8_t>(0x09);
|
||||
// Test empty AMFArray
|
||||
bitStream.Write<uint8_t>(0x09);
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
{
|
||||
@@ -154,7 +154,7 @@ int ReadAMFArrayFromBitStream() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This test checks that if we recieve an unimplemented AMFValueType
|
||||
* This test checks that if we recieve an unimplemented AMFValueType
|
||||
* we correctly throw an error and can actch it.
|
||||
*/
|
||||
int TestUnimplementedAMFValues() {
|
||||
@@ -169,7 +169,7 @@ int TestUnimplementedAMFValues() {
|
||||
AMFValueType::AMFVectorDouble,
|
||||
AMFValueType::AMFVectorObject,
|
||||
AMFValueType::AMFDictionary
|
||||
};
|
||||
};
|
||||
// Run unimplemented tests to check that errors are thrown if
|
||||
// unimplemented AMF values are attempted to be parsed.
|
||||
std::ifstream fileStream;
|
||||
@@ -222,8 +222,8 @@ int TestLiveCapture() {
|
||||
ASSERT_EQ(dynamic_cast<AMFStringValue*>(result->FindValue("BehaviorID"))->GetStringValue(), "10447");
|
||||
ASSERT_EQ(dynamic_cast<AMFStringValue*>(result->FindValue("objectID"))->GetStringValue(), "288300744895913279")
|
||||
|
||||
// Test the execution state array
|
||||
auto executionState = dynamic_cast<AMFArrayValue*>(result->FindValue("executionState"));
|
||||
// Test the execution state array
|
||||
auto executionState = dynamic_cast<AMFArrayValue*>(result->FindValue("executionState"));
|
||||
ASSERT_NE(executionState, nullptr);
|
||||
|
||||
auto strips = dynamic_cast<AMFArrayValue*>(executionState->FindValue("strips"))->GetDenseArray();
|
||||
@@ -268,7 +268,7 @@ int TestLiveCapture() {
|
||||
|
||||
ASSERT_EQ(actionID->GetDoubleValue(), 0.0f)
|
||||
|
||||
auto uiArray = dynamic_cast<AMFArrayValue*>(firstStrip->FindValue("ui"));
|
||||
auto uiArray = dynamic_cast<AMFArrayValue*>(firstStrip->FindValue("ui"));
|
||||
|
||||
auto xPos = dynamic_cast<AMFDoubleValue*>(uiArray->FindValue("x"));
|
||||
auto yPos = dynamic_cast<AMFDoubleValue*>(uiArray->FindValue("y"));
|
||||
@@ -280,7 +280,7 @@ int TestLiveCapture() {
|
||||
|
||||
ASSERT_EQ(stripID->GetDoubleValue(), 0.0f)
|
||||
|
||||
auto firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
auto firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
|
||||
auto firstType = dynamic_cast<AMFStringValue*>(firstAction->FindValue("Type"));
|
||||
|
||||
@@ -348,17 +348,17 @@ int AMFDeserializeTests(int argc, char** const argv) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Below is the AMF that is in the AMFBitStreamTest.bin file that we are reading in
|
||||
* Below is the AMF that is in the AMFBitStreamTest.bin file that we are reading in
|
||||
* from a bitstream to test.
|
||||
args: amf3!
|
||||
{
|
||||
"objectID": "288300744895913279",
|
||||
"BehaviorID": "10447",
|
||||
"executionState": amf3!
|
||||
"executionState": amf3!
|
||||
{
|
||||
"strips": amf3!
|
||||
"strips": amf3!
|
||||
[
|
||||
amf3!
|
||||
amf3!
|
||||
{
|
||||
"actionIndex": 0.0,
|
||||
"id": 0.0,
|
||||
|
Reference in New Issue
Block a user