예제 #1
0
    def test_serializing_compund_data(args):
        tag = ListTag(CompoundTag.clazz_id,
                      tag_name='Test',
                      children=[
                          CompoundTag(children=[
                              ByteTag(25, tag_name='dp1'),
                              ByteTag(31, tag_name='dp2')
                          ]),
                          CompoundTag(children=[
                              ByteTag(25, tag_name='dp3'),
                              ByteTag(31, tag_name='dp4')
                          ])
                      ])
        stream = OutputStream()
        tag.serialize(stream, include_name=True)
        binary_tag = list(stream.get_data())
        expected_tag = [9, 0, 4] + \
            list(b'Test') + \
            [10, 0, 0, 0, 2] +\
            [1, 0, 3,] + list(b'dp1') + [25] +\
            [1, 0, 3,] + list(b'dp2') + [31, 0] +\
            [1, 0, 3,] + list(b'dp3') + [25] +\
            [1, 0, 3,] + list(b'dp4') + [31, 0]

        assert binary_tag == expected_tag, 'Tag ListTag with ListTag elements'
예제 #2
0
    def test_serializing_simple_data(args):
        tag = ListTag(FloatTag.clazz_id,
                      tag_name='Test',
                      children=[FloatTag(1.5), FloatTag(11.15)])
        stream = OutputStream()
        tag.serialize(stream, include_name=True)
        binary_tag = list(stream.get_data())
        expected_tag = [9, 0, 4] + \
            list(b'Test') + \
            [5, 0, 0, 0, 2] +\
            [63, 192, 0, 0, 65, 50, 102, 102]

        assert binary_tag == expected_tag, 'Tag ListTag with FloatTag elements'
예제 #3
0
 def test_deserializing(args):
     raw_tag = InputStream(bytearray([10, 0, 4] + \
         list(b'Test') + \
         [1, 0, 3,] + list(b'dp1') + [25] +\
         [5, 0, 3,] + list(b'dp2') + [63, 192, 0, 0] +\
         [9, 0, 3,] + list(b'dp3') + [1, 0, 0, 0, 1] + [35] +\
         [10, 0, 3,] + list(b'dp4') +\
         [7, 0, 6,] + list(b'sub_dp') + [0, 0, 0, 2, 10, 20] + [0] +\
         [0]))
     parsed_tag = parse_nbt(raw_tag)
     tag = CompoundTag(tag_name='Test',
                       children=[
                           ByteTag(25, tag_name='dp1'),
                           FloatTag(1.5, tag_name='dp2'),
                           ListTag(ByteTag.clazz_id,
                                   tag_name='dp3',
                                   children=[ByteTag(35)]),
                           CompoundTag(tag_name='dp4',
                                       children=[
                                           ByteArrayTag(tag_name='sub_dp',
                                                        children=[
                                                            ByteTag(10),
                                                            ByteTag(20)
                                                        ])
                                       ])
                       ])
     assert parsed_tag == tag, 'Tag ListTag with ListTag elements'
예제 #4
0
 def test_serializing(args):
     tag = CompoundTag(tag_name='Test',
                       children=[
                           ByteTag(25, tag_name='dp1'),
                           FloatTag(1.5, tag_name='dp2'),
                           ListTag(ByteTag.clazz_id,
                                   tag_name='dp3',
                                   children=[ByteTag(35)]),
                           CompoundTag(tag_name='dp4',
                                       children=[
                                           ByteArrayTag(tag_name='sub_dp',
                                                        children=[
                                                            ByteTag(10),
                                                            ByteTag(20)
                                                        ])
                                       ])
                       ])
     stream = OutputStream()
     tag.serialize(stream, include_name=True)
     binary_tag = list(stream.get_data())
     expected_tag = [10, 0, 4] + \
         list(b'Test') + \
         [1, 0, 3,] + list(b'dp1') + [25] +\
         [5, 0, 3,] + list(b'dp2') + [63, 192, 0, 0] +\
         [9, 0, 3,] + list(b'dp3') + [1, 0, 0, 0, 1] + [35] +\
         [10, 0, 3,] + list(b'dp4') +\
         [7, 0, 6,] + list(b'sub_dp') + [0, 0, 0, 2, 10, 20] + [0] +\
         [0]
     assert binary_tag == expected_tag, 'Tag ListTag with ListTag elements'
예제 #5
0
 def test_deserializing_list_data(args):
     raw_tag = InputStream(bytearray([9, 0, 4] + \
         list(b'Test') + \
         [9, 0, 0, 0, 2] +\
         [1, 0, 0, 0, 2] +\
         [25, 31] +\
         [5, 0, 0, 0, 1] +\
         [63, 192, 0, 0]))
     parsed_tag = parse_nbt(raw_tag)
     tag = ListTag(ListTag.clazz_id,
                   tag_name='Test',
                   children=[
                       ListTag(ByteTag.clazz_id,
                               children=[ByteTag(25),
                                         ByteTag(31)]),
                       ListTag(FloatTag.clazz_id, children=[FloatTag(1.5)])
                   ])
     assert parsed_tag == tag, 'Tag ListTag with ListTag elements'
예제 #6
0
 def test_deserializing_simple_data(args):
     raw_tag = InputStream(bytearray([9, 0, 4] + \
         list(b'Test') + \
         [5, 0, 0, 0, 2] +\
         [63, 192, 0, 0, 65, 50, 102, 102]))
     parsed_tag = parse_nbt(raw_tag)
     tag = ListTag(
         FloatTag.clazz_id,
         tag_name='Test',
         children=[
             FloatTag(1.5),
             FloatTag(11.149999618530273)  # float pack error
         ])
     assert parsed_tag == tag, 'Tag ListTag with FloatTag elements'
예제 #7
0
 def test_deserializing_compund_data(args):
     raw_tag = InputStream(bytearray([9, 0, 4] + \
         list(b'Test') + \
         [10, 0, 0, 0, 2] +\
         [1, 0, 3,] + list(b'dp1') + [25] +\
         [1, 0, 3,] + list(b'dp2') + [31, 0] +\
         [1, 0, 3,] + list(b'dp3') + [25] +\
         [1, 0, 3,] + list(b'dp4') + [31, 0]))
     parsed_tag = parse_nbt(raw_tag)
     tag = ListTag(CompoundTag.clazz_id,
                   tag_name='Test',
                   children=[
                       CompoundTag(children=[
                           ByteTag(25, tag_name='dp1'),
                           ByteTag(31, tag_name='dp2')
                       ]),
                       CompoundTag(children=[
                           ByteTag(25, tag_name='dp3'),
                           ByteTag(31, tag_name='dp4')
                       ])
                   ])
     assert parsed_tag == tag, 'Tag ListTag with ListTag elements'
예제 #8
0
    def test_serializing_list_data(args):
        tag = ListTag(ListTag.clazz_id,
                      tag_name='Test',
                      children=[
                          ListTag(ByteTag.clazz_id,
                                  children=[ByteTag(25),
                                            ByteTag(31)]),
                          ListTag(FloatTag.clazz_id, children=[FloatTag(1.5)])
                      ])
        stream = OutputStream()
        tag.serialize(stream, include_name=True)
        binary_tag = list(stream.get_data())

        expected_tag = [9, 0, 4] + \
            list(b'Test') + \
            [9, 0, 0, 0, 2] +\
            [1, 0, 0, 0, 2] +\
            [25, 31] +\
            [5, 0, 0, 0, 1] +\
            [63, 192, 0, 0]

        assert binary_tag == expected_tag, 'Tag ListTag with ListTag elements'