Exemplo n.º 1
0
 def _test43_emit_in_place(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     yaml = ryml.emit(tree)
     length = ryml.compute_emit_length(tree)
     self.assertEqual(len(yaml), length)
     buf = bytearray(length)
     s = ryml.emit_in_place(tree, buf)
     self.assertEqual(len(s), length)
     self.assertTrue(s.tobytes().decode('utf-8') == yaml)
     self.assertTrue(buf.decode('utf-8') == yaml)
Exemplo n.º 2
0
 def _test44_short_buf(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     length = ryml.compute_emit_length(tree)
     buf = bytearray(length - 1)
     with self.assertRaises(IndexError):
         ryml.emit_in_place(tree, buf)
Exemplo n.º 3
0
 def _test41_emit(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     yaml = ryml.emit(tree)
     output_tree = ryml.parse_in_arena(yaml)
     self.case.check(self, output_tree)
Exemplo n.º 4
0
 def _test42_compute_emit_length(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     yaml = ryml.emit(tree)
     length = ryml.compute_emit_length(tree)
     self.assertEqual(len(yaml), length)
Exemplo n.º 5
0
 def _test32_bytearray__ro__reuse_tree(self):
     t = ryml.Tree()
     r = ryml.parse_in_arena(self.src_as_bytearray, tree=t)
     self.assertTrue(r is t)
     self.case.check(self, t)
Exemplo n.º 6
0
 def _test31_bytearray__ro(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     self.case.check(self, tree)
Exemplo n.º 7
0
 def _test21_bytes__ro(self):
     tree = ryml.parse_in_arena(self.src_as_bytes)
     self.case.check(self, tree)
Exemplo n.º 8
0
 def _test12_str__ro__reuse_tree(
         self):  # cannot read string buffers (or can we?)
     t = ryml.Tree()
     ryml.parse_in_arena(self.src_as_str, tree=t)
     self.case.check(self, t)
Exemplo n.º 9
0
 def _test11_str__ro(self):  # cannot read string buffers (or can we?)
     tree = ryml.parse_in_arena(self.src_as_str)
     self.case.check(self, tree)