Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #6
0
 def _test31_bytearray__ro(self):
     tree = ryml.parse_in_arena(self.src_as_bytearray)
     self.case.check(self, tree)
Пример #7
0
 def _test21_bytes__ro(self):
     tree = ryml.parse_in_arena(self.src_as_bytes)
     self.case.check(self, tree)
Пример #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)
Пример #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)