Exemple #1
0
 def test_byte_buffer(self):
     bs = bytearray(1024)
     buf = ArrayByteBuffer(bs)
     buf.write_int32(12)
     buf.write_bytes(b"34")
     buf.set_offset(0)
     assert buf.read_int32() == 12
     assert buf.read_bytes(2) == b"34"
Exemple #2
0
 def test_pair_bin(self):
     bs = bytearray(32)
     buf = ArrayByteBuffer(bs)
     writer = PairBinWriter(buf)
     for i in range(10):
         try:
             writer.write(str(i).encode(), str(i).encode())
         except IndexError as e:
             print(buf.read_bytes(buf.get_offset(), 0))
             buf.set_offset(0)
             writer = PairBinWriter(buf)
             writer.write(str(i).encode(), str(i).encode())
     buf.set_offset(0)
     reader = PairBinReader(buf)
     print("last")
     print(list(reader.read_all()))