File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2424namespace pocketmine \nbt \tag ;
2525
2626use PHPUnit \Framework \TestCase ;
27+ use pocketmine \nbt \BigEndianNbtSerializer ;
2728use pocketmine \nbt \NBT ;
29+ use pocketmine \nbt \TreeRoot ;
2830use function array_fill ;
2931use function array_key_first ;
3032use function array_keys ;
@@ -145,4 +147,19 @@ public function testDelete() : void{
145147 self ::assertSame ([0 , 2 ], $ list ->getAllValues ());
146148 self ::assertSame ([0 , 1 ], array_keys ($ list ->getValue ()));
147149 }
150+
151+ /**
152+ * Tests that empty lists remember their original type from deserialization
153+ * Previously we were discarding these, creating problems for read/write integrity testing
154+ */
155+ public function testEmptyBinarySymmetry () : void {
156+ $ list = new ListTag ([], NBT ::TAG_Byte);
157+
158+ $ serializer = new BigEndianNbtSerializer ();
159+ $ list2 = $ serializer ->read ($ serializer ->write (new TreeRoot ($ list )))->getTag ();
160+
161+ self ::assertInstanceOf (ListTag::class, $ list2 );
162+ self ::assertSame ($ list ->getTagType (), $ list2 ->getTagType ());
163+ self ::assertSame ($ list ->getCount (), $ list2 ->getCount ());
164+ }
148165}
You can’t perform that action at this time.
0 commit comments