8000 Add tests for limits. · Vayu/msgpack-python@6c0c306 · GitHub
[go: up one dir, main page]

Skip to cont 8000 ent

Commit 6c0c306

Browse files
committed
Add tests for limits.
1 parent e9de6b7 commit 6c0c306

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/test_limits.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
import pytest
4+
5+
from msgpack import packb, unpackb
6+
7+
8+
def test_integer():
9+
x = -(2 ** 63)
10+
assert unpackb(packb(x)) == x
11+
with pytest.raises(OverflowError):
12+
packb(x-1)
13+
14+
x = 2 ** 64 - 1
15+
assert unpackb(packb(x)) == x
16+
with pytest.raises(OverflowError):
17+
packb(x+1)
18+
19+
@pytest.mark.skipif(True, "Requires very large memory.")
20+
def test_binary():
21+
x = b'x' * (2**32 - 1)
22+
assert unpackb(packb(x)) == x
23+
x += b'y'
24+
with pytest.raises(ValueError):
25+
packb(x)
26+
27+
28+
@pytest.mark.skipif(True, "Requires very large memory.")
29+
def test_string():
30+
x = u'x' * (2**32 - 1)
31+
assert unpackb(packb(x)) == x
32+
x += u'y'
33+
with pytest.raises(ValueError):
34+
packb(x)
35+
36+
37+
@pytest.mark.skipif(True, "Requires very large memory.")
38+
def test_array():
39+
x = [0] * (2**32 - 1)
40+
assert unpackb(packb(x)) == x
41+
x.append(0)
42+
with pytest.raises(ValueError):
43+
packb(x)

0 commit comments

Comments
 (0)
0