Skip to content

Commit 88b1c14

Browse files
committed
add test_json unittest to check for loading bigInt values from json data
1 parent a483150 commit 88b1c14

File tree

1 file changed

+33
-2
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests

1 file changed

+33
-2
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_json.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,46 @@
3939

4040
import unittest
4141

42+
BIGINT_JSON_DATA = '''
43+
{
44+
"int_values": [
45+
1521583201297000000,
46+
13,
47+
5,
48+
1521583201297000000,
49+
67,
50+
87,
51+
1521583201331000000,
52+
1521583201347000000,
53+
10,
54+
]
55+
}
56+
'''
4257

4358
class JsonTest(unittest.TestCase):
44-
4559
def test_dump(self):
4660
import json
4761
import os
4862
cwd = os.getcwd()
49-
new_file_path = os.path.join(cwd , 'myFile.json')
63+
new_file_path = os.path.join(cwd, 'myFile.json')
5064
json.dump(['a', 'b', 'c'], open(new_file_path, 'w'))
5165
assert json.load(open(new_file_path)) == ['a', 'b', 'c']
5266
os.remove(new_file_path)
5367

68+
def test_load_bigin(self):
69+
import json
70+
data = json.loads(BIGINT_JSON_DATA)
71+
assert "int_values" in data
72+
int_values_ = data['int_values']
73+
assert isinstance(int_values_, list)
74+
assert set(int_values_) == {
75+
1521583201297000000,
76+
13,
77+
5,
78+
1521583201297000000,
79+
67,
80+
87,
81+
1521583201331000000,
82+
1521583201347000000,
83+
10,
84+
}

0 commit comments

Comments
 (0)