Test large reads

This commit is contained in:
Jason Paryani 2016-06-17 13:50:26 -07:00
parent 239286d4ac
commit e4c128de61
2 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,13 @@
@0x86dbb3b256f5d2af;
struct Row {
values @0 :List(Int32);
}
struct MultiArray {
rows @0 :List(Row);
}
struct Msg {
data @0 :List(UInt8);
}

42
test/test_large_read.py Normal file
View file

@ -0,0 +1,42 @@
import pytest
import capnp
import os
import tempfile
import sys
this_dir = os.path.dirname(__file__)
@pytest.fixture
def test_capnp():
return capnp.load(os.path.join(this_dir, 'test_large_read.capnp'))
def test_large_read(test_capnp):
f = tempfile.TemporaryFile()
array = test_capnp.MultiArray.new_message()
row = array.init('rows', 1)[0]
values = row.init('values', 10000)
for i in range(len(values)):
values[i] = i
array.write_packed(f)
f.seek(0)
array = test_capnp.MultiArray.read_packed(f)
del f
assert array.rows[0].values[9000] == 9000
def test_large_read_multiple(test_capnp):
f = tempfile.TemporaryFile()
msg1 = test_capnp.Msg.new_message()
msg1.data = [0x41] * 8192
msg1.write(f)
msg2 = test_capnp.Msg.new_message()
msg2.write(f)
f.seek(0)
for m in test_capnp.Msg.read_multiple(f):
pass