MCPcopy Index your code
hub / github.com/apache/fory / test_stream_buffer_read

Function test_stream_buffer_read

python/pyfory/tests/test_buffer.py:377–399  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

375
376
377def test_stream_buffer_read():
378 writer = Buffer.allocate(32)
379 writer.write_uint32(0x01020304)
380 writer.write_int64(-1234567890)
381 writer.write_var_uint32(300)
382 writer.write_varint64(-4567890123)
383 writer.write_tagged_uint64(0x123456789)
384 writer.write_var_uint64(0x1FFFF)
385 writer.write_bytes_and_size(b"stream-data")
386 writer.write_string("hello-stream")
387
388 data = writer.get_bytes(0, writer.get_writer_index())
389 stream = OneByteStream(data)
390 reader = Buffer.from_stream(stream)
391
392 assert reader.read_uint32() == 0x01020304
393 assert reader.read_int64() == -1234567890
394 assert reader.read_var_uint32() == 300
395 assert reader.read_varint64() == -4567890123
396 assert reader.read_tagged_uint64() == 0x123456789
397 assert reader.read_var_uint64() == 0x1FFFF
398 assert reader.read_bytes_and_size() == b"stream-data"
399 assert reader.read_string() == "hello-stream"
400
401
402def test_stream_buffer_read_with_recv_into():

Callers

nothing calls this directly

Calls 15

OneByteStreamClass · 0.90
write_varint64Method · 0.80
get_bytesMethod · 0.80
read_varint64Method · 0.80
allocateMethod · 0.65
write_uint32Method · 0.45
write_int64Method · 0.45
write_var_uint32Method · 0.45
write_tagged_uint64Method · 0.45
write_var_uint64Method · 0.45
write_stringMethod · 0.45
read_uint32Method · 0.45

Tested by

no test coverage detected