test/nbt*: Replace NBT::helper with NBT::Helper
Yes, I forgot to run the test suite before committing. This is why we need CI.Soda
parent
53878c3e2b
commit
398321e415
|
@ -41,29 +41,29 @@ int main(){
|
|||
// int8 ############################################################
|
||||
// read successfully
|
||||
currentPosition = 5;
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 35);
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 35);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// begin of data
|
||||
currentPosition = 0;
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 30);
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 30);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// end of data
|
||||
currentPosition = 9;
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 39);
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).value == 39);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// out of bounds
|
||||
currentPosition = 10;
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt8(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt8(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0x13A;
|
||||
ASSERT(NBT::helper::readInt8(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt8(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 100);
|
||||
ASSERT(NBT::Helper::readInt8(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 100);
|
||||
|
||||
std::cout << "Passed readInt8 NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeInt8TestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeInt8(writeInt8TestResult, (int8_t) 8);
|
||||
NBT::Helper::writeInt8(writeInt8TestResult, (int8_t) 8);
|
||||
std::vector<uint8_t> dereferencedWriteInt8TestResult = *writeInt8TestResult;
|
||||
delete writeInt8TestResult;
|
||||
ASSERT(dereferencedWriteInt8TestResult.back() == (uint8_t) 8);
|
||||
|
@ -73,33 +73,33 @@ int main(){
|
|||
// int16 ###########################################################
|
||||
// read successfully
|
||||
currentPosition = 5;
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 8996);
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 8996);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// begin of data
|
||||
currentPosition = 0;
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 7711);
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 7711);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// end of data
|
||||
currentPosition = 8;
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 9767);
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).value == 9767);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// partially out of bounds
|
||||
currentPosition = 9;
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// fully out of bounds
|
||||
currentPosition = 10;
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt16(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt16(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0xb9;
|
||||
ASSERT(NBT::helper::readInt16(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt16(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 2000);
|
||||
ASSERT(NBT::Helper::readInt16(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt16(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 2000);
|
||||
|
||||
std::cout << "Passed readInt16 NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeInt16TestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeInt16(writeInt16TestResult, (int16_t) 0xABCD);
|
||||
NBT::Helper::writeInt16(writeInt16TestResult, (int16_t) 0xABCD);
|
||||
std::vector<uint8_t> dereferencedWriteInt16TestResult = *writeInt16TestResult;
|
||||
delete writeInt16TestResult;
|
||||
ASSERT(dereferencedWriteInt16TestResult[0] == (uint8_t) 0xAB && dereferencedWriteInt16TestResult[1] == (uint8_t) 0xCD);
|
||||
|
@ -109,33 +109,33 @@ int main(){
|
|||
// int32 ###########################################################
|
||||
// read successfully
|
||||
currentPosition = 5;
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 589571366);
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 589571366);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// begin of data
|
||||
currentPosition = 0;
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 505356321);
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 505356321);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// end of data
|
||||
currentPosition = 6;
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 606414375);
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).value == 606414375);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// partially out of bounds
|
||||
currentPosition = 7;
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// fully out of bounds
|
||||
currentPosition = 10;
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt32(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt32(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0xc3;
|
||||
ASSERT(NBT::helper::readInt32(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt32(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 10101010);
|
||||
ASSERT(NBT::Helper::readInt32(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 10101010);
|
||||
|
||||
std::cout << "Passed readInt32 NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeInt32TestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeInt32(writeInt32TestResult, (int32_t) 0x12345678);
|
||||
NBT::Helper::writeInt32(writeInt32TestResult, (int32_t) 0x12345678);
|
||||
// delete before checking assertions so we don't leak
|
||||
std::vector<uint8_t> dereferencedWriteInt32TestResult = *writeInt32TestResult;
|
||||
delete writeInt32TestResult;
|
||||
|
@ -151,33 +151,33 @@ int main(){
|
|||
// int64 ###########################################################
|
||||
// read successfully
|
||||
currentPosition = 1;
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2242829044932683046);
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2242829044932683046);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// begin of data
|
||||
currentPosition = 0;
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2170488872094606373);
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2170488872094606373);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// end of data
|
||||
currentPosition = 2;
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2315169217770759719);
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).value == 2315169217770759719);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == false);
|
||||
// partially out of bounds
|
||||
currentPosition = 3;
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// fully out of bounds
|
||||
currentPosition = 10;
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt64(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt64(dataForIntTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0xf1;
|
||||
ASSERT(NBT::helper::readInt64(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt64(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 810001800766);
|
||||
ASSERT(NBT::Helper::readInt64(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 810001800766);
|
||||
|
||||
std::cout << "Passed readInt64 NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeInt64TestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeInt64(writeInt64TestResult, (int64_t) 0x0123456789ABCDEF);
|
||||
NBT::Helper::writeInt64(writeInt64TestResult, (int64_t) 0x0123456789ABCDEF);
|
||||
// delete before checking assertions so we don't leak
|
||||
std::vector<uint8_t> dereferencedWriteInt64TestResult = *writeInt64TestResult;
|
||||
delete writeInt64TestResult;
|
||||
|
@ -213,34 +213,34 @@ int main(){
|
|||
// int8 "array" ####################################################
|
||||
// read successfully
|
||||
currentPosition = 0;
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int8_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}));
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int8_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}));
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read empty
|
||||
currentPosition = 112;
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int8_t>());
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int8_t>());
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read overrun
|
||||
currentPosition = 20;
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read with size partially out of bounds
|
||||
currentPosition = 114;
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read out of bounds
|
||||
currentPosition = 200;
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0x148;
|
||||
ASSERT(NBT::helper::readInt8Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt8Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int8_t>({(int8_t) 0x71, (int8_t) 0x35, (int8_t) 0x77, (int8_t) 0x62, (int8_t) 0x54, (int8_t) 0x64, (int8_t) 0xf5, (int8_t) 0x32}));
|
||||
ASSERT(NBT::Helper::readInt8Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt8Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int8_t>({(int8_t) 0x71, (int8_t) 0x35, (int8_t) 0x77, (int8_t) 0x62, (int8_t) 0x54, (int8_t) 0x64, (int8_t) 0xf5, (int8_t) 0x32}));
|
||||
|
||||
std::cout << "Passed readInt8Array NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* int8ArrayTestOutput = new std::vector<uint8_t>();
|
||||
int8_t writeDataTest[] = {1,2,3,4};
|
||||
NBT::helper::writeInt8Array(int8ArrayTestOutput, writeDataTest, (uint32_t)4);
|
||||
NBT::Helper::writeInt8Array(int8ArrayTestOutput, writeDataTest, (uint32_t)4);
|
||||
ASSERT(
|
||||
int8ArrayTestOutput->at(0) == 0 &&
|
||||
int8ArrayTestOutput->at(1) == 0 &&
|
||||
|
@ -252,7 +252,7 @@ int main(){
|
|||
int8ArrayTestOutput->at(7) == 4
|
||||
);
|
||||
int8ArrayTestOutput->clear();
|
||||
NBT::helper::writeInt8Array(int8ArrayTestOutput, std::vector<int8_t>({1,2,3,4}));
|
||||
NBT::Helper::writeInt8Array(int8ArrayTestOutput, std::vector<int8_t>({1,2,3,4}));
|
||||
ASSERT(
|
||||
int8ArrayTestOutput->at(0) == 0 &&
|
||||
int8ArrayTestOutput->at(1) == 0 &&
|
||||
|
@ -269,34 +269,34 @@ int main(){
|
|||
// int32 "array" ###################################################
|
||||
// read successfully
|
||||
currentPosition = 68;
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int32_t>({1027489600, 1094861636, 1162233672, 1229605708, 1296977744, 1364349780, 1431721816, 1499093852, 1566465888, 1633837924}));
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int32_t>({1027489600, 1094861636, 1162233672, 1229605708, 1296977744, 1364349780, 1431721816, 1499093852, 1566465888, 1633837924}));
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read empty
|
||||
currentPosition = 112;
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int32_t>());
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int32_t>());
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read overrun
|
||||
currentPosition = 20;
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read with size partially out of bounds
|
||||
currentPosition = 114;
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read out of bounds
|
||||
currentPosition = 200;
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0xd5;
|
||||
ASSERT(NBT::helper::readInt32Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt32Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int32_t>({(int32_t) 0x17bfe83c, (int32_t) 0xa8fb, (int32_t) 0x7fffffff, (int32_t) 0x61727261}));
|
||||
ASSERT(NBT::Helper::readInt32Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt32Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int32_t>({(int32_t) 0x17bfe83c, (int32_t) 0xa8fb, (int32_t) 0x7fffffff, (int32_t) 0x61727261}));
|
||||
|
||||
std::cout << "Passed readInt32Array NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* int32ArrayTestOutput = new std::vector<uint8_t>();
|
||||
int32_t input32[] = {0x01234567, 0x01234567};
|
||||
NBT::helper::writeInt32Array(int32ArrayTestOutput, input32, 2);
|
||||
NBT::Helper::writeInt32Array(int32ArrayTestOutput, input32, 2);
|
||||
ASSERT(
|
||||
int32ArrayTestOutput->at(0) == 0x00 &&
|
||||
int32ArrayTestOutput->at(1) == 0x00 &&
|
||||
|
@ -312,7 +312,7 @@ int main(){
|
|||
int32ArrayTestOutput->at(11) == 0x67
|
||||
);
|
||||
int32ArrayTestOutput->clear();
|
||||
NBT::helper::writeInt32Array(int32ArrayTestOutput, std::vector<int32_t>({0x01234567, 0x01234567}));
|
||||
NBT::Helper::writeInt32Array(int32ArrayTestOutput, std::vector<int32_t>({0x01234567, 0x01234567}));
|
||||
ASSERT(
|
||||
int32ArrayTestOutput->at(0) == 0x00 &&
|
||||
int32ArrayTestOutput->at(1) == 0x00 &&
|
||||
|
@ -334,34 +334,34 @@ int main(){
|
|||
// int64 "array" ###################################################
|
||||
// read successfully
|
||||
currentPosition = 44;
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int64_t>({2966230773313449776, 3544952156018063160, 4123673537695186954, 4413034230074983236, 4991755612779596620}));
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int64_t>({2966230773313449776, 3544952156018063160, 4123673537695186954, 4413034230074983236, 4991755612779596620}));
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read empty
|
||||
currentPosition = 112;
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int64_t>());
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector<int64_t>());
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false);
|
||||
// read overrun
|
||||
currentPosition = 20;
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read with size partially out of bounds
|
||||
currentPosition = 114;
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read out of bounds
|
||||
currentPosition = 200;
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0x107;
|
||||
ASSERT(NBT::helper::readInt64Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readInt64Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int64_t>({(int64_t) 239865, (int64_t) 23586749, (int64_t) 9223372036854775807, (int64_t) 188944201329624, (int64_t) 3116157694992754}));
|
||||
ASSERT(NBT::Helper::readInt64Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readInt64Array(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == std::vector<int64_t>({(int64_t) 239865, (int64_t) 23586749, (int64_t) 9223372036854775807, (int64_t) 188944201329624, (int64_t) 3116157694992754}));
|
||||
|
||||
std::cout << "Passed readInt64Array NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* int64ArrayTestOutput = new std::vector<uint8_t>();
|
||||
int64_t input64[] = {0x0123456789ABCDEF, 0x0123456789ABCDEF};
|
||||
NBT::helper::writeInt64Array(int64ArrayTestOutput, input64, 2);
|
||||
NBT::Helper::writeInt64Array(int64ArrayTestOutput, input64, 2);
|
||||
ASSERT(
|
||||
int64ArrayTestOutput->at(0) == 0x00 &&
|
||||
int64ArrayTestOutput->at(1) == 0x00 &&
|
||||
|
@ -385,7 +385,7 @@ int main(){
|
|||
int64ArrayTestOutput->at(19) == 0xEF
|
||||
);
|
||||
int64ArrayTestOutput->clear();
|
||||
NBT::helper::writeInt64Array(int64ArrayTestOutput, std::vector<int64_t>({0x0123456789ABCDEF, 0x0123456789ABCDEF}));
|
||||
NBT::Helper::writeInt64Array(int64ArrayTestOutput, std::vector<int64_t>({0x0123456789ABCDEF, 0x0123456789ABCDEF}));
|
||||
ASSERT(
|
||||
int64ArrayTestOutput->at(0) == 0x00 &&
|
||||
int64ArrayTestOutput->at(1) == 0x00 &&
|
||||
|
@ -418,25 +418,25 @@ int main(){
|
|||
dataSize = 4;
|
||||
currentPosition = 0;
|
||||
// read successfully
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).value == -63351.46484375f);
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).value == -63351.46484375f);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == false);
|
||||
// read overrun
|
||||
currentPosition = 1;
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read out of bounds
|
||||
currentPosition = 4;
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readFloat(dataForFloatTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readFloat(dataForFloatTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0xad;
|
||||
ASSERT(NBT::helper::readFloat(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readFloat(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 35.2678337097168);
|
||||
ASSERT(NBT::Helper::readFloat(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readFloat(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 35.2678337097168);
|
||||
|
||||
std::cout << "Passed readFloat NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeFloatTestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeFloat(writeFloatTestResult, (float) -63351.46484375f);
|
||||
NBT::Helper::writeFloat(writeFloatTestResult, (float) -63351.46484375f);
|
||||
std::vector<uint8_t> dereferencedWriteFloatTestResult = *writeFloatTestResult;
|
||||
delete writeFloatTestResult;
|
||||
ASSERT(
|
||||
|
@ -453,25 +453,25 @@ int main(){
|
|||
dataSize = 8;
|
||||
currentPosition = 0;
|
||||
// read successfully
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).value == -20.015625476837158203125);
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == false);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).value == -20.015625476837158203125);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == false);
|
||||
// read overrun
|
||||
currentPosition = 1;
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).errorCode == ErrorCodes::OVERRUN);
|
||||
// read out of bounds
|
||||
currentPosition = 8;
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::helper::readDouble(dataForDoubleTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).isError == true);
|
||||
ASSERT(NBT::Helper::readDouble(dataForDoubleTest, dataSize, currentPosition).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
// read from a bigger blob
|
||||
currentPositionInBlob = 0x9d;
|
||||
ASSERT(NBT::helper::readDouble(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readDouble(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 623593.6542742235);
|
||||
ASSERT(NBT::Helper::readDouble(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readDouble(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == 623593.6542742235);
|
||||
|
||||
std::cout << "Passed readDouble NBT helper test" << std::endl;
|
||||
|
||||
std::vector<uint8_t>* writeDoubleTestResult = new std::vector<uint8_t>();
|
||||
NBT::helper::writeDouble(writeDoubleTestResult, (double) -20.015625476837158203125);
|
||||
NBT::Helper::writeDouble(writeDoubleTestResult, (double) -20.015625476837158203125);
|
||||
std::vector<uint8_t> dereferencedWriteDoubleTestResult = *writeDoubleTestResult;
|
||||
delete writeDoubleTestResult;
|
||||
ASSERT(
|
||||
|
@ -533,16 +533,16 @@ int main(){
|
|||
tiny_utf8::string normalString = tiny_utf8::string(normalStdString);
|
||||
delete nextChar;
|
||||
|
||||
ASSERT(normalString == NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).value)
|
||||
ASSERT(normalString == NBT::Helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).value)
|
||||
|
||||
javaStdString[0] = '1';
|
||||
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), javaStdString.size()).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
ASSERT(NBT::Helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN);
|
||||
ASSERT(NBT::Helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), javaStdString.size()).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||
|
||||
//reading data from the blob at the top of this file
|
||||
currentPositionInBlob = 0x1cf;
|
||||
ASSERT(NBT::helper::readString(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::helper::readString(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == "Hello World!");
|
||||
ASSERT(NBT::Helper::readString(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).isError == false);
|
||||
ASSERT(NBT::Helper::readString(validNBTDataBlob, validNBTDataBlobSize, currentPositionInBlob).value == "Hello World!");
|
||||
|
||||
std::cout << "Passed readString NBT helper test." << std::endl;
|
||||
|
||||
|
@ -570,7 +570,7 @@ int main(){
|
|||
delete nextChar1;
|
||||
|
||||
std::vector<uint8_t>* exportedString = new std::vector<uint8_t>();
|
||||
NBT::helper::writeString(exportedString, normalString);
|
||||
NBT::Helper::writeString(exportedString, normalString);
|
||||
ASSERT(javaStdString1 == *exportedString);
|
||||
|
||||
std::cout << "Passed writeString NBT helper test." << std::endl;
|
||||
|
|
|
@ -101,16 +101,16 @@ int main() {
|
|||
// Basic valid data tests
|
||||
//##################################################################
|
||||
// const uint8_t END = 0;
|
||||
ErrorOr<uint64_t> totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x93);
|
||||
ErrorOr<int32_t> dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x93);
|
||||
ErrorOr<uint64_t> totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x93);
|
||||
ErrorOr<int32_t> dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x93);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 1);
|
||||
ASSERT(!dataLength.isError);
|
||||
ASSERT(dataLength.value == 0);
|
||||
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 477);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 477);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 477);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 477);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 1);
|
||||
|
@ -118,8 +118,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 0);
|
||||
|
||||
//const uint8_t INT8 = 1;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x133);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x133);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x133);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x133);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 8);
|
||||
|
@ -127,8 +127,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t INT16 = 2;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xb1);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xb1);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xb1);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xb1);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 10);
|
||||
|
@ -136,16 +136,16 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t INT32 = 3;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xbb);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xbb);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xbb);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xbb);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 12);
|
||||
ASSERT(!dataLength.isError);
|
||||
ASSERT(dataLength.value == 1);
|
||||
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x67);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x67);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x67);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x67);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 18);
|
||||
|
@ -153,8 +153,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t INT64 = 4;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xe9);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xe9);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xe9);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xe9);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 16);
|
||||
|
@ -162,8 +162,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t FLOAT = 5;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xa5);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xa5);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xa5);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xa5);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 12);
|
||||
|
@ -171,8 +171,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t DOUBLE = 6;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x94);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x94);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x94);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x94);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 17);
|
||||
|
@ -180,8 +180,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 1);
|
||||
|
||||
//const uint8_t INT8_ARRAY = 7;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x13b);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x13b);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x13b);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x13b);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 25);
|
||||
|
@ -189,16 +189,16 @@ int main() {
|
|||
ASSERT(dataLength.value == 8);
|
||||
|
||||
//const uint8_t STRING = 8;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x1c6);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x1c6);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x1c6);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x1c6);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 23);
|
||||
ASSERT(!dataLength.isError);
|
||||
ASSERT(dataLength.value == 12);
|
||||
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x79);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x79);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x79);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x79);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 26);
|
||||
|
@ -206,16 +206,16 @@ int main() {
|
|||
ASSERT(dataLength.value == 12);
|
||||
|
||||
//const uint8_t LIST = 9;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x154);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x154);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x154);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x154);
|
||||
|
||||
ASSERT(totalSize.isError);
|
||||
ASSERT(totalSize.errorCode == ErrorCodes::NOT_YET_KNOWN);
|
||||
ASSERT(!dataLength.isError);
|
||||
ASSERT(dataLength.value == 5);
|
||||
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x16a);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x16a);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x16a);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x16a);
|
||||
|
||||
ASSERT(totalSize.isError);
|
||||
ASSERT(totalSize.errorCode == ErrorCodes::NOT_YET_KNOWN);
|
||||
|
@ -223,8 +223,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 12);
|
||||
|
||||
//const uint8_t COMPOUND = 10;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x5c);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x5c);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x5c);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x5c);
|
||||
|
||||
ASSERT(totalSize.isError);
|
||||
ASSERT(totalSize.errorCode == ErrorCodes::NOT_YET_KNOWN);
|
||||
|
@ -232,8 +232,8 @@ int main() {
|
|||
ASSERT(dataLength.errorCode == ErrorCodes::NOT_YET_KNOWN);
|
||||
|
||||
//const uint8_t INT32_ARRAY= 11;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xc7);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xc7);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xc7);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xc7);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 34);
|
||||
|
@ -241,8 +241,8 @@ int main() {
|
|||
ASSERT(dataLength.value == 4);
|
||||
|
||||
//const uint8_t INT64_ARRAY= 12;
|
||||
totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xf9);
|
||||
dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xf9);
|
||||
totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0xf9);
|
||||
dataLength = NBT::Helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0xf9);
|
||||
|
||||
ASSERT(!totalSize.isError);
|
||||
ASSERT(totalSize.value == 58);
|
||||
|
|
|
@ -27,5 +27,5 @@ int main() {
|
|||
std::cout << "This is supposed to abort." << std::endl;
|
||||
std::vector<uint8_t>* exportedString = new std::vector<uint8_t>();
|
||||
std::string overrunString = std::string(0xFFFFF, '.');
|
||||
NBT::helper::writeString(exportedString, tiny_utf8::string(overrunString));
|
||||
NBT::Helper::writeString(exportedString, tiny_utf8::string(overrunString));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue