format codebase

This commit is contained in:
aronwk-aaron
2022-07-28 08:39:57 -05:00
parent 4f7aa11067
commit 19e77a38d8
881 changed files with 34700 additions and 38689 deletions

View File

@@ -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,

View File

@@ -4,49 +4,49 @@
#include "GeneralUtils.h"
#include "CommonCxxTests.h"
int TestEncoding(int argc, char* *const argv) {
std::string x = "Hello World!";
std::string_view v(x);
int TestEncoding(int argc, char** const argv) {
std::string x = "Hello World!";
std::string_view v(x);
uint32_t out;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'H');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'e');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'o');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), true);
uint32_t out;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'H');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'e');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 'o');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), true);
x = u8"Frühling";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'F');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'r');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'ü');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'h');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'i');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'n');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'g');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
x = u8"Frühling";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'F');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'r');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'ü');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'h');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'l');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'i');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'n');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'g');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
x = "中文字";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
x = "中文字";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, U'');
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
x = "👨‍⚖️";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x1F468);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x200D);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x2696);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0xFE0F);
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
x = "👨‍⚖️";
v = x;
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x1F468);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x200D);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0x2696);
GeneralUtils::_NextUTF8Char(v, out); ASSERT_EQ(out, 0xFE0F);
ASSERT_EQ(GeneralUtils::_NextUTF8Char(v, out), false);
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("Hello World!"), u"Hello World!");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("Frühling"), u"Frühling");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("中文字"), u"中文字");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("👨‍⚖️"), u"👨‍⚖️");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("Hello World!"), u"Hello World!");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("Frühling"), u"Frühling");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("中文字"), u"中文字");
ASSERT_EQ(GeneralUtils::UTF8ToUTF16("👨‍⚖️"), u"👨‍⚖️");
return 0;
return 0;
}

View File

@@ -3,15 +3,15 @@
/**
* @brief Test parsing an LDF value
*
*
* @param argc Number of command line arguments for this test
* @param argv Command line arguments
* @return 0 on success, non-zero on failure
*/
int TestLDFFormat(int argc, char* *const argv) {
int TestLDFFormat(int argc, char** const argv) {
// Create
auto* data = LDFBaseData::DataFromString("KEY=0:VALUE");
// Check that the data type is correct
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16);
@@ -19,7 +19,7 @@ int TestLDFFormat(int argc, char* *const argv) {
ASSERT_EQ(data->GetKey(), u"KEY");
// Check that the value is correct
ASSERT_EQ(((LDFData<std::u16string>* )data)->GetValue(), u"VALUE");
ASSERT_EQ(((LDFData<std::u16string>*)data)->GetValue(), u"VALUE");
// Check that the serialization is correct
ASSERT_EQ(data->GetString(), "KEY=0:VALUE");

View File

@@ -3,9 +3,9 @@
#include "NiPoint3.h"
#include "CommonCxxTests.h"
int TestNiPoint3(int argc, char* *const argv) {
int TestNiPoint3(int argc, char** const argv) {
// Check that Unitize works
ASSERT_EQ(NiPoint3(3,0,0).Unitize(), NiPoint3::UNIT_X);
ASSERT_EQ(NiPoint3(3, 0, 0).Unitize(), NiPoint3::UNIT_X);
// Check what unitize does to a vector of length 0
ASSERT_EQ(NiPoint3::ZERO.Unitize(), NiPoint3::ZERO);
// If we get here, all was successful