mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-20 04:13:16 +00:00
More limit check.
This commit is contained in:
parent
6c0c306f96
commit
e7f87d9d41
1 changed files with 18 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from msgpack import packb, unpackb
|
from msgpack import packb, unpackb, Packer
|
||||||
|
|
||||||
|
|
||||||
def test_integer():
|
def test_integer():
|
||||||
|
@ -16,11 +16,27 @@ def test_integer():
|
||||||
with pytest.raises(OverflowError):
|
with pytest.raises(OverflowError):
|
||||||
packb(x+1)
|
packb(x+1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_array_header():
|
||||||
|
packer = Packer()
|
||||||
|
packer.pack_array_header(2**32-1)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
packer.pack_array_header(2**32)
|
||||||
|
|
||||||
|
|
||||||
|
def test_map_header():
|
||||||
|
packer = Packer()
|
||||||
|
packer.pack_map_header(2**32-1)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
packer.pack_array_header(2**32)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(True, "Requires very large memory.")
|
@pytest.mark.skipif(True, "Requires very large memory.")
|
||||||
def test_binary():
|
def test_binary():
|
||||||
x = b'x' * (2**32 - 1)
|
x = b'x' * (2**32 - 1)
|
||||||
assert unpackb(packb(x)) == x
|
assert unpackb(packb(x)) == x
|
||||||
x += b'y'
|
del x
|
||||||
|
x = b'x' * (2**32)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
packb(x)
|
packb(x)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue