From ac12bcf86548204458dd0835f46be9a3a83e705f Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 15 Sep 2022 01:06:59 +0200 Subject: [PATCH 1/5] Makefile: Finally get rid of this as we don't need it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A makefile may be added back when we are preparing distribution but it’s a long road until then. --- Makefile | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index dfd93c1..0000000 --- a/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: build -build: - bash ./scripts/build.sh -clean: - bash ./scripts/clean.sh -mrproper: - bash ./scripts/clean.sh - bash ./scripts/clean_dependencies.sh -setup: - bash ./scripts/setup_project.sh -test: - bash ./scripts/test.sh From 6149418f5285c52f345cf4b110317ae068e97df7 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 15 Sep 2022 01:51:51 +0200 Subject: [PATCH 2/5] Add a level.dat to test the NBT parser on. --- resources/NBT_data/level.dat | Bin 0 -> 5452 bytes resources/NBT_data/level.dat_decompressed | Bin 0 -> 35617 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/NBT_data/level.dat create mode 100644 resources/NBT_data/level.dat_decompressed diff --git a/resources/NBT_data/level.dat b/resources/NBT_data/level.dat new file mode 100644 index 0000000000000000000000000000000000000000..4e58ded54f164c2f2a900633278b6df72f373f3b GIT binary patch literal 5452 zcmZvAXE+=Tx2-k^MvFRn7rpm31R;8_L3BYdf+0H5dyN{=dkxV$6TL?7W%Lnkl;FJQ zJ?Fd6z0Y&^ueH}+d+qgm)5Tz;{9Dhb=A#MJDkcdYpA5bATTYu-5cR`1_@G_^pU2GM z20=+L*;U%fWx=@7#+$KX5`9Yjv=w7Y#n*PoIqJmCo_FaH1CEx(G+_fT9CcMA zP_p(2HhWNej2%bAs4Ctm`_{n5fD94EyBLv)G1I;K|yA@|E zpqVZ=EKC~SlwQ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3QJv<>{V!x^*4fH+{CcgWb^*pF!W)!$*b2@)>l6k8rPjINir*%)j<; zfBNFGI``r9QHD=)3dGG7^hWGpFogAM95Al8WjXkU(El`nPvxP7D z<@owY5^kvVhgghsw2Hx(cK+&L#@j!6>9_PUb=P=$ZdtAF4<&boC2y$Z2U(#fd^7#+ zkNzqAlYhVY^1r_I!gKlj=E3u`XMXR`K3-N|#(CZ+aW*R+$h~zY!Sa$?xs8{~{_lUT zs^t%-58mFra08#2zlAgK`CWW+w7?ibi}QOy8GJX&^~}}zA1$j5S$8$1YnBeTJ{boy zoWHhokhV)|UA}Bz@osA$pC%rbQ7FCdCz*UJeQiT+;H&HSJa?AQH}PP#r&gq_x2~4( z{WN-uk4Y@rJdi#H)Kjaw^3C-guI=kaOQsQ>S#G@_+rs5m(`D0?wnNN#1_-vQubS!v zT{=;Yq*+^S*GyZwk|Hm;NwSfzxvVY*tFxupGMn1_~C2PNn3_Dp^cF02Xg6oL!G;o%KISXr4EqUb5DX) bUKpaz-ws6Dp1+@ksI-oEKj>O!T1x#NMSRle literal 0 HcmV?d00001 From ad291ee77dda3a65d55f106e472f840b7002ed16 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 15 Sep 2022 02:00:07 +0200 Subject: [PATCH 3/5] lib/nbt: Capitalize NBT::Helper because I feel like it --- src/lib/nbt.cpp | 68 ++++++++++++++++++++++++------------------------- src/lib/nbt.hpp | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index ba80d7e..4782ad9 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -36,7 +36,7 @@ #endif namespace NBT { - namespace helper { + namespace Helper { ErrorOr readInt8(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) { if (currentPosition>=dataSize) return ErrorOr(true, ErrorCodes::OUT_OF_RANGE); return ErrorOr((int8_t) data[currentPosition]); @@ -92,7 +92,7 @@ namespace NBT { *(valueAsBytes+2) = data[currentPosition+1]; *(valueAsBytes+3) = data[currentPosition]; #else - #error "NBT::helper::readFloat: An implementation for your endianness is unavailable." + #error "NBT::Helper::readFloat: An implementation for your endianness is unavailable." #endif #endif float dereferencedValue = *value; @@ -126,7 +126,7 @@ namespace NBT { *(valueAsBytes+6) = data[currentPosition+1]; *(valueAsBytes+7) = data[currentPosition]; #else - #error "NBT::helper::readDouble: An implementation for your endianness is unavailable." + #error "NBT::Helper::readDouble: An implementation for your endianness is unavailable." #endif #endif double dereferencedValue = *value; @@ -232,7 +232,7 @@ namespace NBT { destination->push_back(*(valueAsBytes+1)); destination->push_back(*valueAsBytes); #else - #error "NBT::helper::writeInt16: An implementation for your endianness is unavailable." + #error "NBT::Helper::writeInt16: An implementation for your endianness is unavailable." #endif #endif delete value; @@ -255,7 +255,7 @@ namespace NBT { destination->push_back(*(valueAsBytes+1)); destination->push_back(*valueAsBytes); #else - #error "NBT::helper::writeInt16: An implementation for your endianness is unavailable." + #error "NBT::Helper::writeInt16: An implementation for your endianness is unavailable." #endif #endif delete value; @@ -286,7 +286,7 @@ namespace NBT { destination->push_back(*(valueAsBytes+1)); destination->push_back(*valueAsBytes); #else - #error "NBT::helper::writeInt16: An implementation for your endianness is unavailable." + #error "NBT::Helper::writeInt16: An implementation for your endianness is unavailable." #endif #endif delete value; @@ -309,7 +309,7 @@ namespace NBT { destination->push_back(*(valueAsBytes+1)); destination->push_back(*valueAsBytes); #else - #error "NBT::helper::writeInt16: An implementation for your endianness is unavailable." + #error "NBT::Helper::writeInt16: An implementation for your endianness is unavailable." #endif #endif delete value; @@ -340,7 +340,7 @@ namespace NBT { destination->push_back(*(valueAsBytes+1)); destination->push_back(*valueAsBytes); #else - #error "NBT::helper::writeInt16: An implementation for your endianness is unavailable." + #error "NBT::Helper::writeInt16: An implementation for your endianness is unavailable." #endif #endif delete value; @@ -363,7 +363,7 @@ namespace NBT { void writeString(std::vector* destination, tiny_utf8::string data) { ErrorOr> exportedString = JavaCompat::exportJavaString(data); if(exportedString.isError){ - std::cerr << "NBT::helpers::writeString encountered an error: " << (int) exportedString.errorCode << std::endl; + std::cerr << "NBT::Helpers::writeString encountered an error: " << (int) exportedString.errorCode << std::endl; std::abort(); } *destination = exportedString.value; @@ -426,7 +426,7 @@ namespace NBT { // deal with end tag before trying to access the name if (nextTag == TagType::END) return ErrorOr(1); - ErrorOr nameSize = helper::readInt16(data, dataSize, currentPosition+1); + ErrorOr nameSize = Helper::readInt16(data, dataSize, currentPosition+1); if (nameSize.isError) { return ErrorOr(true, nameSize.errorCode); } @@ -446,28 +446,28 @@ namespace NBT { case TagType::DOUBLE: return ErrorOr(prefixSize+8); case TagType::INT8_ARRAY: { - ErrorOr arrayLength = helper::readInt32(data, dataSize, currentPosition+prefixSize); + ErrorOr arrayLength = Helper::readInt32(data, dataSize, currentPosition+prefixSize); if (arrayLength.isError) { return ErrorOr(true, arrayLength.errorCode); } return ErrorOr((uint64_t) arrayLength.value + prefixSize + 4); } case TagType::STRING: { - ErrorOr stringSize = helper::readInt16(data, dataSize, currentPosition+prefixSize); + ErrorOr stringSize = Helper::readInt16(data, dataSize, currentPosition+prefixSize); if (stringSize.isError) { return ErrorOr(true, stringSize.errorCode); } return ErrorOr((uint64_t) stringSize.value + prefixSize + 2); } case TagType::INT32_ARRAY: { - ErrorOr arrayLength = helper::readInt32(data, dataSize, currentPosition+prefixSize); + ErrorOr arrayLength = Helper::readInt32(data, dataSize, currentPosition+prefixSize); if (arrayLength.isError) { return ErrorOr(true, arrayLength.errorCode); } return ErrorOr((uint64_t) arrayLength.value*4 + prefixSize + 4); } case TagType::INT64_ARRAY: { - ErrorOr arrayLength = helper::readInt32(data, dataSize, currentPosition+prefixSize); + ErrorOr arrayLength = Helper::readInt32(data, dataSize, currentPosition+prefixSize); if (arrayLength.isError) { return ErrorOr(true, arrayLength.errorCode); } @@ -509,7 +509,7 @@ namespace NBT { return ErrorOr(1); } - ErrorOr nameSize = helper::readInt16(data, dataSize, currentPosition+1); + ErrorOr nameSize = Helper::readInt16(data, dataSize, currentPosition+1); if (nameSize.isError) { return ErrorOr(true, nameSize.errorCode); } @@ -517,10 +517,10 @@ namespace NBT { uint64_t prefixSize = (uint64_t) nameSize.value + 3; switch (nextTag) { case TagType::INT8_ARRAY: { - return helper::readInt32(data, dataSize, currentPosition+prefixSize); + return Helper::readInt32(data, dataSize, currentPosition+prefixSize); } case TagType::STRING: { - ErrorOr stringSize = helper::readInt16(data, dataSize, currentPosition+prefixSize); + ErrorOr stringSize = Helper::readInt16(data, dataSize, currentPosition+prefixSize); if (stringSize.isError) { return ErrorOr(true, stringSize.errorCode); } @@ -528,13 +528,13 @@ namespace NBT { } case TagType::LIST: { // add an additional byte for the contained data type - return helper::readInt32(data, dataSize, currentPosition+prefixSize+1); + return Helper::readInt32(data, dataSize, currentPosition+prefixSize+1); } case TagType::INT32_ARRAY: { - return helper::readInt32(data, dataSize, currentPosition+prefixSize); + return Helper::readInt32(data, dataSize, currentPosition+prefixSize); } case TagType::INT64_ARRAY: { - return helper::readInt32(data, dataSize, currentPosition+prefixSize); + return Helper::readInt32(data, dataSize, currentPosition+prefixSize); } default: // unknown tag or parsing error @@ -562,7 +562,7 @@ namespace NBT { uint8_t nameSizeSlice[] = {data[1], data[2]}; - ErrorOr readIntResult = helper::readInt16(nameSizeSlice, 2, 0); + ErrorOr readIntResult = Helper::readInt16(nameSizeSlice, 2, 0); if(!readIntResult.isError){ this->nameSize = readIntResult.value; }else{ @@ -574,7 +574,7 @@ namespace NBT { nameSlice[i] = data[i+1]; } - ErrorOr readStringResult = helper::readString(nameSlice, this->nameSize, 0); + ErrorOr readStringResult = Helper::readString(nameSlice, this->nameSize, 0); if(!readStringResult.isError){ this->name = readStringResult.value; }else{ @@ -601,7 +601,7 @@ namespace NBT { // headerless tags // // add one byte to position to skip the type byte - ErrorOr elementCount = helper::readInt32(data, dataSize, initialPosition+1); + ErrorOr elementCount = Helper::readInt32(data, dataSize, initialPosition+1); if (elementCount.isError) { return false; } @@ -634,7 +634,7 @@ namespace NBT { } case TagType::INT8_ARRAY: { for (int32_t i=0; i> nextArray = helper::readInt8Array(data, dataSize, initialPosition+*processedDataSize); + ErrorOr> nextArray = Helper::readInt8Array(data, dataSize, initialPosition+*processedDataSize); if (nextArray.isError) { return false; } @@ -644,12 +644,12 @@ namespace NBT { } case TagType::STRING: { for (int32_t i=0; i nextString = helper::readString(data, dataSize, initialPosition+*processedDataSize); + ErrorOr nextString = Helper::readString(data, dataSize, initialPosition+*processedDataSize); if (nextString.isError) { return false; } // this cannot be an error because it just got checked - int16_t nextStringSize = helper::readInt16(data, dataSize, initialPosition+*processedDataSize).value; + int16_t nextStringSize = Helper::readInt16(data, dataSize, initialPosition+*processedDataSize).value; *processedDataSize += (uint64_t) nextStringSize + 2; } return true; @@ -685,7 +685,7 @@ namespace NBT { } case TagType::INT32_ARRAY: { for (int32_t i=0; i> nextArray = helper::readInt32Array(data, dataSize, initialPosition+*processedDataSize); + ErrorOr> nextArray = Helper::readInt32Array(data, dataSize, initialPosition+*processedDataSize); if (nextArray.isError) { return false; } @@ -695,7 +695,7 @@ namespace NBT { } case TagType::INT64_ARRAY: { for (int32_t i=0; i> nextArray = helper::readInt64Array(data, dataSize, initialPosition+*processedDataSize); + ErrorOr> nextArray = Helper::readInt64Array(data, dataSize, initialPosition+*processedDataSize); if (nextArray.isError) { return false; } @@ -737,11 +737,11 @@ namespace NBT { uint64_t currentPosition = initialPosition; #define return if (processedDataSize!=nullptr) *processedDataSize = currentPosition-initialPosition; return while (currentPosition nextTagSize = helper::totalTagSize(data, dataSize, currentPosition); + ErrorOr nextTagSize = Helper::totalTagSize(data, dataSize, currentPosition); if (nextTagSize.isError) { if (nextTagSize.errorCode == ErrorCodes::NOT_YET_KNOWN) { // attempt parsing the name - ErrorOr tagName = helper::readString(data, dataSize, currentPosition+1); + ErrorOr tagName = Helper::readString(data, dataSize, currentPosition+1); if (tagName.isError) { return false; } @@ -750,7 +750,7 @@ namespace NBT { // // there is no way this is an error bc it gets // checked while trying to parse the string above - int16_t nameSize = helper::readInt16(data, dataSize, currentPosition+1).value; + int16_t nameSize = Helper::readInt16(data, dataSize, currentPosition+1).value; uint64_t* processedTagSize = new uint64_t; *processedTagSize = 0; @@ -791,7 +791,7 @@ namespace NBT { // nameSize cannot be an error here bc it got checked in // nextTagSize() already - int16_t nameSize = helper::readInt16(data, dataSize, currentPosition+1).value; + int16_t nameSize = Helper::readInt16(data, dataSize, currentPosition+1).value; // attempt parsing the name // @@ -800,7 +800,7 @@ namespace NBT { // being guarded against with // if (currentPosition + nextTagSize.value > dataSize) return false; // It might, however, turn out to be a useful check in the future. - ErrorOr name = helper::readString(data, dataSize, currentPosition+1); + ErrorOr name = Helper::readString(data, dataSize, currentPosition+1); if (name.isError) { return false; } @@ -825,7 +825,7 @@ namespace NBT { // in the future. // // type byte + two name size bytes = 3 - ErrorOr content = helper::readString(data, dataSize, currentPosition+nameSize+3); + ErrorOr content = Helper::readString(data, dataSize, currentPosition+nameSize+3); if (content.isError) { return false; } diff --git a/src/lib/nbt.hpp b/src/lib/nbt.hpp index b40d804..e1ade91 100644 --- a/src/lib/nbt.hpp +++ b/src/lib/nbt.hpp @@ -41,7 +41,7 @@ #include "error.hpp" namespace NBT { - namespace helper { + namespace Helper { ErrorOr readInt8(uint8_t data[], uint64_t dataSize, uint64_t currentPosition); ErrorOr readInt16(uint8_t data[], uint64_t dataSize, uint64_t currentPosition); ErrorOr readInt32(uint8_t data[], uint64_t dataSize, uint64_t currentPosition); From 53878c3e2b6805034ed12490f72493a0f8f8e2c5 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 15 Sep 2022 06:06:47 +0200 Subject: [PATCH 4/5] lib/nbt: Start implementing the in-memory data structure for NBT --- src/lib/error.hpp | 2 ++ src/lib/nbt.cpp | 51 ++++------------------------------------ src/lib/nbt.hpp | 59 +++++++++++++++++++---------------------------- 3 files changed, 31 insertions(+), 81 deletions(-) diff --git a/src/lib/error.hpp b/src/lib/error.hpp index 2cc55ef..58c44eb 100644 --- a/src/lib/error.hpp +++ b/src/lib/error.hpp @@ -89,6 +89,8 @@ namespace ErrorCodes { const uint8_t NOT_YET_KNOWN = 7; + const uint8_t INVALID_TYPE = 8; + const uint8_t UNIMPLEMENTED = 254; const uint8_t UNKNOWN = 255; diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 4782ad9..17e5352 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -543,56 +543,15 @@ namespace NBT { } } - //Tag constructors - + // generic class that all tag types are derived from template - Tag::Tag(uint8_t tagType, tiny_utf8::string name, uint16_t nameSize, T content, uint32_t size) - : tagType(tagType), name(name), nameSize(nameSize), content(content) ,size(size) - {} + Tag::Tag() { - End::End() : Tag::Tag(0, "", 0, 0, 0) {} - - Byte::Byte(tiny_utf8::string name, uint16_t nameSize, int8_t content) - : Tag::Tag(1, name, nameSize, content, 1) - {} - - Byte::Byte(uint8_t data[]){ - if(validate(data)){ - this->tagType = 1; - - uint8_t nameSizeSlice[] = {data[1], data[2]}; - - ErrorOr readIntResult = Helper::readInt16(nameSizeSlice, 2, 0); - if(!readIntResult.isError){ - this->nameSize = readIntResult.value; - }else{ - throw readIntResult.errorCode; - } - - uint8_t nameSlice[this->nameSize+2]; - for(int i=0; inameSize+2; i++){ - nameSlice[i] = data[i+1]; - } - - ErrorOr readStringResult = Helper::readString(nameSlice, this->nameSize, 0); - if(!readStringResult.isError){ - this->name = readStringResult.value; - }else{ - throw readStringResult.errorCode; - } - - //int8 needs only one byte - this->content = data[this->nameSize+4]; - } } - //more conditions will be added - bool Byte::validate(uint8_t data[]){ - if(data[0] == 0x01){ - return true; - }else{ - return false; - } + template + ErrorOr> Tag::toRawData() { + return ErrorOr>(true, ErrorCodes::INVALID_TYPE); } bool validateRawListContents(uint8_t data[], uint64_t dataSize, uint64_t initialPosition, uint64_t* processedDataSize) { diff --git a/src/lib/nbt.hpp b/src/lib/nbt.hpp index e1ade91..eae5ed9 100644 --- a/src/lib/nbt.hpp +++ b/src/lib/nbt.hpp @@ -72,45 +72,34 @@ namespace NBT { } namespace TagType { - const uint8_t END = 0; - const uint8_t INT8 = 1; - const uint8_t INT16 = 2; - const uint8_t INT32 = 3; - const uint8_t INT64 = 4; - const uint8_t FLOAT = 5; - const uint8_t DOUBLE = 6; - const uint8_t INT8_ARRAY = 7; - const uint8_t STRING = 8; - const uint8_t LIST = 9; - const uint8_t COMPOUND = 10; - const uint8_t INT32_ARRAY= 11; - const uint8_t INT64_ARRAY= 12; + const uint8_t END = 0; + const uint8_t INT8 = 1; + const uint8_t INT16 = 2; + const uint8_t INT32 = 3; + const uint8_t INT64 = 4; + const uint8_t FLOAT = 5; + const uint8_t DOUBLE = 6; + const uint8_t INT8_ARRAY = 7; + const uint8_t STRING = 8; + const uint8_t LIST = 9; + const uint8_t COMPOUND = 10; + const uint8_t INT32_ARRAY= 11; + const uint8_t INT64_ARRAY= 12; + // This is a workaround that's not part of the spec. + const uint8_t INVALID = 255; + + // This class is used as a placeholder for implementing the end tag. + class End {}; } - //Generic parent class to make declaration easier + // generic class that all tag types are derived from template - class Tag{ - public: - uint8_t tagType; - tiny_utf8::string name; - uint16_t nameSize; - T content; - int32_t size; + struct Tag { + const uint8_t type = TagType::INVALID; + T* containedData; - Tag(){} - Tag(uint8_t tagType, tiny_utf8::string name, uint16_t nameSize, T content, uint32_t size); - }; - - class End: public Tag{ - public: - End(); - }; - - class Byte: public Tag{ - public: - Byte(tiny_utf8::string name, uint16_t nameSize, int8_t content); - Byte(uint8_t data[]); - bool validate(uint8_t data[]); + Tag(); + ErrorOr> toRawData(); }; bool validateRawNBTData(uint8_t data[], uint64_t dataSize, uint64_t initialPosition=0, uint64_t* processedDataSize=nullptr); From 398321e415a9615dfdb112c51de394d1c12a158e Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Mon, 19 Sep 2022 11:20:51 +0200 Subject: [PATCH 5/5] test/nbt*: Replace NBT::helper with NBT::Helper Yes, I forgot to run the test suite before committing. This is why we need CI. --- src/test/nbt_read_write_helpers.cpp | 232 ++++++++++----------- src/test/nbt_size_helpers.cpp | 68 +++--- src/test/nbt_write_string_failure_mode.cpp | 2 +- 3 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/test/nbt_read_write_helpers.cpp b/src/test/nbt_read_write_helpers.cpp index b53a9ae..3f85d9a 100644 --- a/src/test/nbt_read_write_helpers.cpp +++ b/src/test/nbt_read_write_helpers.cpp @@ -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* writeInt8TestResult = new std::vector(); - NBT::helper::writeInt8(writeInt8TestResult, (int8_t) 8); + NBT::Helper::writeInt8(writeInt8TestResult, (int8_t) 8); std::vector 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* writeInt16TestResult = new std::vector(); - NBT::helper::writeInt16(writeInt16TestResult, (int16_t) 0xABCD); + NBT::Helper::writeInt16(writeInt16TestResult, (int16_t) 0xABCD); std::vector 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* writeInt32TestResult = new std::vector(); - 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 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* writeInt64TestResult = new std::vector(); - 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 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({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({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()); - ASSERT(NBT::helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).isError == false); + ASSERT(NBT::Helper::readInt8Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector()); + 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) 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) 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* int8ArrayTestOutput = new std::vector(); 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({1,2,3,4})); + NBT::Helper::writeInt8Array(int8ArrayTestOutput, std::vector({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({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({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()); - ASSERT(NBT::helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).isError == false); + ASSERT(NBT::Helper::readInt32Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector()); + 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) 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) 0x17bfe83c, (int32_t) 0xa8fb, (int32_t) 0x7fffffff, (int32_t) 0x61727261})); std::cout << "Passed readInt32Array NBT helper test" << std::endl; std::vector* int32ArrayTestOutput = new std::vector(); 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({0x01234567, 0x01234567})); + NBT::Helper::writeInt32Array(int32ArrayTestOutput, std::vector({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({2966230773313449776, 3544952156018063160, 4123673537695186954, 4413034230074983236, 4991755612779596620})); - ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false); + ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector({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()); - ASSERT(NBT::helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).isError == false); + ASSERT(NBT::Helper::readInt64Array(dataForIntArrayTest, dataSize, currentPosition).value == std::vector()); + 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) 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) 239865, (int64_t) 23586749, (int64_t) 9223372036854775807, (int64_t) 188944201329624, (int64_t) 3116157694992754})); std::cout << "Passed readInt64Array NBT helper test" << std::endl; std::vector* int64ArrayTestOutput = new std::vector(); 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({0x0123456789ABCDEF, 0x0123456789ABCDEF})); + NBT::Helper::writeInt64Array(int64ArrayTestOutput, std::vector({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* writeFloatTestResult = new std::vector(); - NBT::helper::writeFloat(writeFloatTestResult, (float) -63351.46484375f); + NBT::Helper::writeFloat(writeFloatTestResult, (float) -63351.46484375f); std::vector 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* writeDoubleTestResult = new std::vector(); - NBT::helper::writeDouble(writeDoubleTestResult, (double) -20.015625476837158203125); + NBT::Helper::writeDouble(writeDoubleTestResult, (double) -20.015625476837158203125); std::vector 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(javaStdString.data()), javaStdString.size(), 0).value) + ASSERT(normalString == NBT::Helper::readString(reinterpret_cast(javaStdString.data()), javaStdString.size(), 0).value) javaStdString[0] = '1'; - ASSERT(NBT::helper::readString(reinterpret_cast(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN); - ASSERT(NBT::helper::readString(reinterpret_cast(javaStdString.data()), javaStdString.size(), javaStdString.size()).errorCode == ErrorCodes::OUT_OF_RANGE); + ASSERT(NBT::Helper::readString(reinterpret_cast(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN); + ASSERT(NBT::Helper::readString(reinterpret_cast(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* exportedString = new std::vector(); - NBT::helper::writeString(exportedString, normalString); + NBT::Helper::writeString(exportedString, normalString); ASSERT(javaStdString1 == *exportedString); std::cout << "Passed writeString NBT helper test." << std::endl; diff --git a/src/test/nbt_size_helpers.cpp b/src/test/nbt_size_helpers.cpp index 2f1174d..e3b93f7 100644 --- a/src/test/nbt_size_helpers.cpp +++ b/src/test/nbt_size_helpers.cpp @@ -101,16 +101,16 @@ int main() { // Basic valid data tests //################################################################## // const uint8_t END = 0; - ErrorOr totalSize = NBT::helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x93); - ErrorOr dataLength = NBT::helper::containedDataLength(simpleNBTData, simpleNBTDataSize, 0x93); + ErrorOr totalSize = NBT::Helper::totalTagSize(simpleNBTData, simpleNBTDataSize, 0x93); + ErrorOr 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); diff --git a/src/test/nbt_write_string_failure_mode.cpp b/src/test/nbt_write_string_failure_mode.cpp index 042b624..cbc8367 100644 --- a/src/test/nbt_write_string_failure_mode.cpp +++ b/src/test/nbt_write_string_failure_mode.cpp @@ -27,5 +27,5 @@ int main() { std::cout << "This is supposed to abort." << std::endl; std::vector* exportedString = new std::vector(); std::string overrunString = std::string(0xFFFFF, '.'); - NBT::helper::writeString(exportedString, tiny_utf8::string(overrunString)); + NBT::Helper::writeString(exportedString, tiny_utf8::string(overrunString)); }