test/nbt_tags: Finish test implementation for NBT::Tag::List
parent
6672a4f149
commit
f8dd10d301
|
@ -767,7 +767,7 @@ int main(){
|
||||||
NBT::Tag::Int8* pointer_1_0 = new NBT::Tag::Int8("entry_1_0", 6);
|
NBT::Tag::Int8* pointer_1_0 = new NBT::Tag::Int8("entry_1_0", 6);
|
||||||
NBT::Tag::Int8* pointer_1_1 = new NBT::Tag::Int8("entry_1_1", 38);
|
NBT::Tag::Int8* pointer_1_1 = new NBT::Tag::Int8("entry_1_1", 38);
|
||||||
NBT::Tag::Int8* pointer_1_2 = new NBT::Tag::Int8("entry_1_2", 125);
|
NBT::Tag::Int8* pointer_1_2 = new NBT::Tag::Int8("entry_1_2", 125);
|
||||||
NBT::Tag::Int8* pointer_1_3 = new NBT::Tag::Int8("entry_1_3", -64); // 0xC0 (?)
|
NBT::Tag::Int8* pointer_1_3 = new NBT::Tag::Int8("entry_1_3", -64); // 0xC0
|
||||||
NBT::Tag::Int8* pointer_2_0 = new NBT::Tag::Int8("entry_2_0", 56);
|
NBT::Tag::Int8* pointer_2_0 = new NBT::Tag::Int8("entry_2_0", 56);
|
||||||
NBT::Tag::Int8* pointer_2_1 = new NBT::Tag::Int8("entry_2_1", 28);
|
NBT::Tag::Int8* pointer_2_1 = new NBT::Tag::Int8("entry_2_1", 28);
|
||||||
NBT::Tag::Int8* pointer_2_2 = new NBT::Tag::Int8("entry_2_2", 45);
|
NBT::Tag::Int8* pointer_2_2 = new NBT::Tag::Int8("entry_2_2", 45);
|
||||||
|
@ -797,8 +797,9 @@ int main(){
|
||||||
ASSERT(!list_2.deleteElement(1).isError);
|
ASSERT(!list_2.deleteElement(1).isError);
|
||||||
ASSERT(list_2.deleteElement(3).isError && list_2.deleteElement(3).errorCode == ErrorCodes::OUT_OF_RANGE);
|
ASSERT(list_2.deleteElement(3).isError && list_2.deleteElement(3).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||||
ASSERT(!list_2.getElementPointer(2).isError && dynamic_cast<NBT::Tag::Int8*>(list_2.getElementPointer(2).value)->getValue() == 78);
|
ASSERT(!list_2.getElementPointer(2).isError && dynamic_cast<NBT::Tag::Int8*>(list_2.getElementPointer(2).value)->getValue() == 78);
|
||||||
|
ASSERT(list_2.getElementPointer(3).isError && list_2.getElementPointer(3).errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||||
ASSERT(!list_2.setElementPointerAt(0, new NBT::Tag::Int8("set_entry", 3)).isError);
|
ASSERT(!list_2.setElementPointerAt(0, new NBT::Tag::Int8("set_entry", 3)).isError);
|
||||||
ErrorOrVoid resultRange = list_2.setElementPointerAt(3, new NBT::Tag::Int8("overrun_entry", 2));
|
ErrorOrVoid resultRange = list_2.setElementPointerAt(3, new NBT::Tag::Int8("out_of_range_entry", 2));
|
||||||
ASSERT(resultRange.isError);
|
ASSERT(resultRange.isError);
|
||||||
ASSERT(resultRange.errorCode == ErrorCodes::OUT_OF_RANGE);
|
ASSERT(resultRange.errorCode == ErrorCodes::OUT_OF_RANGE);
|
||||||
ErrorOrVoid resultType = list_2.setElementPointerAt(0, new NBT::Tag::Int16());
|
ErrorOrVoid resultType = list_2.setElementPointerAt(0, new NBT::Tag::Int16());
|
||||||
|
@ -806,5 +807,71 @@ int main(){
|
||||||
ASSERT(resultType.errorCode == ErrorCodes::INVALID_TYPE);
|
ASSERT(resultType.errorCode == ErrorCodes::INVALID_TYPE);
|
||||||
ASSERT(list_2.length() == 3);
|
ASSERT(list_2.length() == 3);
|
||||||
|
|
||||||
|
ASSERT(!list_1.serialize(&vector).isError);
|
||||||
|
ASSERT(!list_2.serialize(&vector).isError);
|
||||||
|
ASSERT(vector.size() == 35);
|
||||||
|
ASSERT(
|
||||||
|
vector.at( 0) == 9 &&
|
||||||
|
vector.at( 1) == 0 &&
|
||||||
|
vector.at( 2) == 6 &&
|
||||||
|
vector.at( 3) == 'l' &&
|
||||||
|
vector.at( 4) == 'i' &&
|
||||||
|
vector.at( 5) == 's' &&
|
||||||
|
vector.at( 6) == 't' &&
|
||||||
|
vector.at( 7) == '_' &&
|
||||||
|
vector.at( 8) == '1' &&
|
||||||
|
vector.at( 9) == 1 &&
|
||||||
|
vector.at(10) == 0 &&
|
||||||
|
vector.at(11) == 0 &&
|
||||||
|
vector.at(12) == 0 &&
|
||||||
|
vector.at(13) == 4 &&
|
||||||
|
vector.at(14) == 6 &&
|
||||||
|
vector.at(15) == 38 &&
|
||||||
|
vector.at(16) == 125 &&
|
||||||
|
vector.at(17) == 0xC0 &&
|
||||||
|
vector.at(18) == 9 &&
|
||||||
|
vector.at(19) == 0 &&
|
||||||
|
vector.at(20) == 6 &&
|
||||||
|
vector.at(21) == 'l' &&
|
||||||
|
vector.at(22) == 'i' &&
|
||||||
|
vector.at(23) == 's' &&
|
||||||
|
vector.at(24) == 't' &&
|
||||||
|
vector.at(25) == '_' &&
|
||||||
|
vector.at(26) == '2' &&
|
||||||
|
vector.at(27) == 1 &&
|
||||||
|
vector.at(28) == 0 &&
|
||||||
|
vector.at(29) == 0 &&
|
||||||
|
vector.at(30) == 0 &&
|
||||||
|
vector.at(31) == 3 &&
|
||||||
|
vector.at(32) == 3 &&
|
||||||
|
vector.at(33) == 45 &&
|
||||||
|
vector.at(34) == 78
|
||||||
|
);
|
||||||
|
vector.clear();
|
||||||
|
ASSERT(!list_1.serializeWithoutHeader(&vector).isError);
|
||||||
|
ASSERT(!list_2.serializeWithoutHeader(&vector).isError);
|
||||||
|
ASSERT(vector.size() == 17);
|
||||||
|
ASSERT(
|
||||||
|
vector.at( 0) == 1 &&
|
||||||
|
vector.at( 1) == 0 &&
|
||||||
|
vector.at( 2) == 0 &&
|
||||||
|
vector.at( 3) == 0 &&
|
||||||
|
vector.at( 4) == 4 &&
|
||||||
|
vector.at( 5) == 6 &&
|
||||||
|
vector.at( 6) == 38 &&
|
||||||
|
vector.at( 7) == 125 &&
|
||||||
|
vector.at( 8) == 0xC0 &&
|
||||||
|
vector.at( 9) == 1 &&
|
||||||
|
vector.at(10) == 0 &&
|
||||||
|
vector.at(11) == 0 &&
|
||||||
|
vector.at(12) == 0 &&
|
||||||
|
vector.at(13) == 3 &&
|
||||||
|
vector.at(14) == 3 &&
|
||||||
|
vector.at(15) == 45 &&
|
||||||
|
vector.at(16) == 78
|
||||||
|
);
|
||||||
|
vector.clear();
|
||||||
|
std::cout << "Passed List test." << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue