test/nbt_tags: Test compound serialization

Soda
BodgeMaster 2022-10-14 21:46:55 +02:00
parent fd5fe3967f
commit 77dd79398f
1 changed files with 166 additions and 1 deletions

View File

@ -906,7 +906,172 @@ int main(){
ASSERT(compound_0.length() == 1);
ASSERT(compound_1.length() == 3);
ASSERT(compound_2.length() == 4);
//TODO: test serialization
compound_0.serialize(&vector);
compound_1.serialize(&vector);
compound_2.serialize(&vector);
ASSERT(vector.size() == 95);
ASSERT(
vector.at( 0) == 10 &&
vector.at( 1) == 0 &&
vector.at( 2) == 10 &&
vector.at( 3) == 'c' &&
vector.at( 4) == 'o' &&
vector.at( 5) == 'm' &&
vector.at( 6) == 'p' &&
vector.at( 7) == 'o' &&
vector.at( 8) == 'u' &&
vector.at( 9) == 'n' &&
vector.at(10) == 'd' &&
vector.at(11) == '_' &&
vector.at(12) == '0' &&
vector.at(13) == 0 &&
vector.at(14) == 10 &&
vector.at(15) == 0 &&
vector.at(16) == 10 &&
vector.at(17) == 'c' &&
vector.at(18) == 'o' &&
vector.at(19) == 'm' &&
vector.at(20) == 'p' &&
vector.at(21) == 'o' &&
vector.at(22) == 'u' &&
vector.at(23) == 'n' &&
vector.at(24) == 'd' &&
vector.at(25) == '_' &&
vector.at(26) == '1' &&
vector.at(27) == 3 &&
vector.at(28) == 0 &&
vector.at(29) == 1 &&
vector.at(30) == '0' &&
vector.at(31) == 0x00 &&
vector.at(32) == 0x01 &&
vector.at(33) == 0x0f &&
vector.at(34) == 0x2c &&
vector.at(35) == 2 &&
vector.at(36) == 0 &&
vector.at(37) == 11 &&
vector.at(38) == 's' &&
vector.at(39) == 'e' &&
vector.at(40) == 't' &&
vector.at(41) == '_' &&
vector.at(42) == 'e' &&
vector.at(43) == 'l' &&
vector.at(44) == 'e' &&
vector.at(45) == 'm' &&
vector.at(46) == 'e' &&
vector.at(47) == 'n' &&
vector.at(48) == 't' &&
vector.at(49) == 0x0F &&
vector.at(50) == 0xFF &&
vector.at(51) == 0 &&
vector.at(52) == 10 &&
vector.at(53) == 0 &&
vector.at(54) == 10 &&
vector.at(55) == 'c' &&
vector.at(56) == 'o' &&
vector.at(57) == 'm' &&
vector.at(58) == 'p' &&
vector.at(59) == 'o' &&
vector.at(60) == 'u' &&
vector.at(61) == 'n' &&
vector.at(62) == 'd' &&
vector.at(63) == '_' &&
vector.at(64) == '2' &&
vector.at(65) == 1 &&
vector.at(66) == 0 &&
vector.at(67) == 1 &&
vector.at(68) == '0' &&
vector.at(69) == 0x0 &&
vector.at(70) == 2 &&
vector.at(71) == 0 &&
vector.at(72) == 1 &&
vector.at(73) == '1' &&
vector.at(74) == 0x13 &&
vector.at(75) == 0x37 &&
vector.at(76) == 8 &&
vector.at(77) == 0 &&
vector.at(78) == 1 &&
vector.at(79) == '2' &&
vector.at(80) == 0 &&
vector.at(81) == 12 &&
vector.at(82) == 'H' &&
vector.at(83) == 'e' &&
vector.at(84) == 'l' &&
vector.at(85) == 'l' &&
vector.at(86) == 'o' &&
vector.at(87) == ' ' &&
vector.at(88) == 'W' &&
vector.at(89) == 'o' &&
vector.at(90) == 'r' &&
vector.at(91) == 'l' &&
vector.at(92) == 'd' &&
vector.at(93) == '!' &&
vector.at(94) == 0
);
vector.clear();
compound_0.serializeWithoutHeader(&vector);
compound_1.serializeWithoutHeader(&vector);
compound_2.serializeWithoutHeader(&vector);
ASSERT(vector.size() == 56);
ASSERT(
vector.at( 0) == 0 &&
vector.at( 1) == 3 &&
vector.at( 2) == 0 &&
vector.at( 3) == 1 &&
vector.at( 4) == '0' &&
vector.at( 5) == 0x00 &&
vector.at( 6) == 0x01 &&
vector.at( 7) == 0x0f &&
vector.at( 8) == 0x2c &&
vector.at( 9) == 2 &&
vector.at(10) == 0 &&
vector.at(11) == 11 &&
vector.at(12) == 's' &&
vector.at(13) == 'e' &&
vector.at(14) == 't' &&
vector.at(15) == '_' &&
vector.at(16) == 'e' &&
vector.at(17) == 'l' &&
vector.at(18) == 'e' &&
vector.at(19) == 'm' &&
vector.at(20) == 'e' &&
vector.at(21) == 'n' &&
vector.at(22) == 't' &&
vector.at(23) == 0x0F &&
vector.at(24) == 0xFF &&
vector.at(25) == 0 &&
vector.at(26) == 1 &&
vector.at(27) == 0 &&
vector.at(28) == 1 &&
vector.at(29) == '0' &&
vector.at(30) == 0x0 &&
vector.at(31) == 2 &&
vector.at(32) == 0 &&
vector.at(33) == 1 &&
vector.at(34) == '1' &&
vector.at(35) == 0x13 &&
vector.at(36) == 0x37 &&
vector.at(37) == 8 &&
vector.at(38) == 0 &&
vector.at(39) == 1 &&
vector.at(40) == '2' &&
vector.at(41) == 0 &&
vector.at(42) == 12 &&
vector.at(43) == 'H' &&
vector.at(44) == 'e' &&
vector.at(45) == 'l' &&
vector.at(46) == 'l' &&
vector.at(47) == 'o' &&
vector.at(48) == ' ' &&
vector.at(49) == 'W' &&
vector.at(50) == 'o' &&
vector.at(51) == 'r' &&
vector.at(52) == 'l' &&
vector.at(53) == 'd' &&
vector.at(54) == '!' &&
vector.at(55) == 0
);
vector.clear();
std::cout << "Passed Compound test." << std::endl;
return 0;
}