mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Add some edge case tests for read_multiple_bytes
This commit is contained in:
parent
29e63de41d
commit
da8f8869fc
1 changed files with 30 additions and 0 deletions
|
@ -56,14 +56,44 @@ def test_large_read_multiple_bytes(test_capnp):
|
|||
for m in test_capnp.Msg.read_multiple_bytes(data):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp)[:-1]
|
||||
for m in test_capnp.Msg.read_multiple_bytes(data):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp) + b' '
|
||||
for m in test_capnp.Msg.read_multiple_bytes(data):
|
||||
pass
|
||||
|
||||
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason="PyPy memoryview support is limited")
|
||||
def test_large_read_mutltiple_bytes_memoryview(test_capnp):
|
||||
data = get_two_adjacent_messages(test_capnp)
|
||||
for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp)[:-1]
|
||||
for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp) + b' '
|
||||
for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)):
|
||||
pass
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0] == 3, reason="Legacy buffer support only for python 2.7")
|
||||
def test_large_read_mutltiple_bytes_buffer(test_capnp):
|
||||
data = get_two_adjacent_messages(test_capnp)
|
||||
for m in test_capnp.Msg.read_multiple_bytes(buffer(data)):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp)[:-1]
|
||||
for m in test_capnp.Msg.read_multiple_bytes(buffer(data)):
|
||||
pass
|
||||
|
||||
with pytest.raises(capnp.KjException):
|
||||
data = get_two_adjacent_messages(test_capnp) + b' '
|
||||
for m in test_capnp.Msg.read_multiple_bytes(buffer(data)):
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue