mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-19 20:03:16 +00:00
Add tests for limits.
This commit is contained in:
parent
e9de6b7f39
commit
6c0c306f96
1 changed files with 43 additions and 0 deletions
43
test/test_limits.py
Normal file
43
test/test_limits.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# coding: utf-8
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from msgpack import packb, unpackb
|
||||||
|
|
||||||
|
|
||||||
|
def test_integer():
|
||||||
|
x = -(2 ** 63)
|
||||||
|
assert unpackb(packb(x)) == x
|
||||||
|
with pytest.raises(OverflowError):
|
||||||
|
packb(x-1)
|
||||||
|
|
||||||
|
x = 2 ** 64 - 1
|
||||||
|
assert unpackb(packb(x)) == x
|
||||||
|
with pytest.raises(OverflowError):
|
||||||
|
packb(x+1)
|
||||||
|
|
||||||
|
@pytest.mark.skipif(True, "Requires very large memory.")
|
||||||
|
def test_binary():
|
||||||
|
x = b'x' * (2**32 - 1)
|
||||||
|
assert unpackb(packb(x)) == x
|
||||||
|
x += b'y'
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
packb(x)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(True, "Requires very large memory.")
|
||||||
|
def test_string():
|
||||||
|
x = u'x' * (2**32 - 1)
|
||||||
|
assert unpackb(packb(x)) == x
|
||||||
|
x += u'y'
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
packb(x)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(True, "Requires very large memory.")
|
||||||
|
def test_array():
|
||||||
|
x = [0] * (2**32 - 1)
|
||||||
|
assert unpackb(packb(x)) == x
|
||||||
|
x.append(0)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
packb(x)
|
Loading…
Add table
Add a link
Reference in a new issue