예제 #1
0
 def test_deserializing(args):
     raw_tag = InputStream(bytearray([clz.clazz_id, 0, 4] + \
         list(b'Test') + \
         test_bin))
     parsed_tag = parse_nbt(raw_tag)
     expected_tag = clz(test_val, tag_name='Test')
     assert parsed_tag == expected_tag, f'Tag {clz.clazz_name}'
예제 #2
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'
예제 #3
0
 def test_deserializing(args):
     raw_tag = InputStream(bytearray([8, 0, 4] + \
         list(b'Test') + \
         [0,len('Hello World')] +\
         list(b'Hello World')))
     parsed_tag = parse_nbt(raw_tag)
     tag = StringTag('Hello World', tag_name='Test')
     assert parsed_tag == tag, 'Tag StringTag'
예제 #4
0
 def test_deserializing(args):
     raw_tag = InputStream(bytearray([clz.clazz_id, 0, 4] + \
         list(b'Test') + \
         [0,0,0,len(test_vals)] +\
         [b for sublist in test_bins for b in sublist]))
     parsed_tag = parse_nbt(raw_tag)
     expected_tag = clz(
         'Test', children=[clz.clazz_sub_type(v) for v in test_vals])
     assert parsed_tag == expected_tag, f'Tag {clz.clazz_name}'
예제 #5
0
 def test_reading_data(args):
     stream = InputStream(b'Hello World')
     read_hello = stream.read(5)
     stream.read(1)
     read_world = stream.read(5)
     assert read_hello == b'Hello'
     assert read_world == b'World'
예제 #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_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'
예제 #8
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'
예제 #9
0
 def test_peeking_data(args):
     stream = InputStream(b'Hello World')
     read_hello = stream.read(5)
     peek_space = stream.peek()
     assert read_hello == b'Hello'
     assert peek_space == 32