File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments