Compare commits

..

No commits in common. "fd5fe3967fe348f59c2045f69873029d0089cfc6" and "7be73f86d4c1bbc99a3764dedad1231f8dba92c6" have entirely different histories.

2 changed files with 0 additions and 37 deletions

View File

@ -992,7 +992,6 @@ namespace NBT {
if (position == this->tags.size() && pointer->getTagType() == TagType::END) {
delete pointer;
// do nothing, already have one of those
return ErrorOrVoid();
} else {
delete pointer;
// End tags may only go at the end and
@ -1012,7 +1011,6 @@ namespace NBT {
ErrorOrVoid Compound::appendPointer(Generic* pointer) {
if (pointer->getTagType() == TagType::END) {
delete pointer;
return ErrorOrVoid(true, ErrorCodes::NOT_ALLOWED);
}
this->tags.push_back(pointer);

View File

@ -873,40 +873,5 @@ int main(){
vector.clear();
std::cout << "Passed List test." << std::endl;
// COMPOUND ################################################################
// Things to put in the compound
std::vector<NBT::Tag::Generic*> compoundDataVector = std::vector<NBT::Tag::Generic*>();
compoundDataVector.push_back(new NBT::Tag::Int8("0", 0));
compoundDataVector.push_back(new NBT::Tag::Int16("will be deleted", 0x1337));
compoundDataVector.push_back(new NBT::Tag::Int16("1", 0x1337));
compoundDataVector.push_back(new NBT::Tag::String("2", "Hello World!"));
NBT::Tag::Compound compound_0 = NBT::Tag::Compound();
compound_0.name = "compound_0";
NBT::Tag::Compound compound_1 = NBT::Tag::Compound("compound_1");
NBT::Tag::Compound compound_2 = NBT::Tag::Compound("compound_2", compoundDataVector);
ASSERT(!compound_1.appendPointer(new NBT::Tag::Int32("0", 69420)).isError);
ASSERT(!compound_1.appendPointer(new NBT::Tag::Int8("1", 1)).isError);
ASSERT(compound_1.appendPointer(new NBT::Tag::End()).isError && compound_1.appendPointer(new NBT::Tag::End()).errorCode == ErrorCodes::NOT_ALLOWED);
ASSERT(!compound_0.getElementPointer(0).isError && compound_0.getElementPointer(0).value->getTagType() == NBT::TagType::END);
ASSERT(compound_0.getElementPointer(1).isError && compound_0.getElementPointer(1).errorCode == ErrorCodes::OUT_OF_RANGE);
ASSERT(!compound_1.getElementPointer(0).isError && compound_1.getElementPointer(0).value->getTagType() == NBT::TagType::INT32);
ASSERT(!compound_1.getElementPointer(1).isError && compound_1.getElementPointer(1).value->getTagType() == NBT::TagType::INT8);
ASSERT(!compound_0.setElementPointerAt(0, new NBT::Tag::End()).isError);
ASSERT(!compound_1.setElementPointerAt(1, new NBT::Tag::Int16("set_element", 0xFFF)).isError);
ErrorOrVoid resultNotAllowed = compound_0.setElementPointerAt(0, new NBT::Tag::Int64());
ASSERT(resultNotAllowed.isError && resultNotAllowed.errorCode==ErrorCodes::NOT_ALLOWED);
resultNotAllowed = compound_1.setElementPointerAt(0, new NBT::Tag::End());
ASSERT(resultNotAllowed.isError && resultNotAllowed.errorCode==ErrorCodes::NOT_ALLOWED);
ASSERT(compound_0.setElementPointerAt(1, new NBT::Tag::Int8()).isError && compound_0.setElementPointerAt(1, new NBT::Tag::Int8()).errorCode == ErrorCodes::OUT_OF_RANGE);
ASSERT(!compound_2.deleteElement(1).isError);
ASSERT(compound_0.deleteElement(0).isError && compound_0.deleteElement(0).errorCode == ErrorCodes::NOT_ALLOWED);
ASSERT(compound_0.deleteElement(1).isError && compound_0.deleteElement(1).errorCode == ErrorCodes::OUT_OF_RANGE);
ASSERT(compound_0.length() == 1);
ASSERT(compound_1.length() == 3);
ASSERT(compound_2.length() == 4);
//TODO: test serialization
return 0;
}