diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 73a2baf..3fb198e 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -319,7 +319,10 @@ namespace NBT { } void writeInt8Array(std::vector* destination, std::vector data) { - + writeInt32(destination, data.size()); + for(int8_t datum: data){ + destination->push_back(datum); + } } void writeInt8Array(std::vector* destination, int8_t data[], uint32_t dataSize) { diff --git a/src/test/nbt_helpers.cpp b/src/test/nbt_helpers.cpp index 6ff7f19..c2eabcc 100644 --- a/src/test/nbt_helpers.cpp +++ b/src/test/nbt_helpers.cpp @@ -219,6 +219,18 @@ int main(){ int8ArrayTestOutput->at(6) == 3 && int8ArrayTestOutput->at(7) == 4 ); + int8ArrayTestOutput->clear(); + NBT::helper::writeInt8Array(int8ArrayTestOutput, std::vector({1,2,3,4})); + ASSERT( + int8ArrayTestOutput->at(0) == 0 && + int8ArrayTestOutput->at(1) == 0 && + int8ArrayTestOutput->at(2) == 0 && + int8ArrayTestOutput->at(3) == 4 && + int8ArrayTestOutput->at(4) == 1 && + int8ArrayTestOutput->at(5) == 2 && + int8ArrayTestOutput->at(6) == 3 && + int8ArrayTestOutput->at(7) == 4 + ); delete int8ArrayTestOutput; std::cout << "Passed writeInt8Array NBT helper test" << std::endl;