gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / simplejson / tests / test_pass1.py @ 545
History | View | Annotate | Download (1.71 KB)
1 |
from unittest import TestCase |
---|---|
2 |
|
3 |
import simplejson as json |
4 |
|
5 |
# from http://json.org/JSON_checker/test/pass1.json
|
6 |
JSON = r'''
|
7 |
[
|
8 |
"JSON Test Pattern pass1",
|
9 |
{"object with 1 member":["array with 1 element"]},
|
10 |
{},
|
11 |
[],
|
12 |
-42,
|
13 |
true,
|
14 |
false,
|
15 |
null,
|
16 |
{
|
17 |
"integer": 1234567890,
|
18 |
"real": -9876.543210,
|
19 |
"e": 0.123456789e-12,
|
20 |
"E": 1.234567890E+34,
|
21 |
"": 23456789012E66,
|
22 |
"zero": 0,
|
23 |
"one": 1,
|
24 |
"space": " ",
|
25 |
"quote": "\"",
|
26 |
"backslash": "\\",
|
27 |
"controls": "\b\f\n\r\t",
|
28 |
"slash": "/ & \/",
|
29 |
"alpha": "abcdefghijklmnopqrstuvwyz",
|
30 |
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
|
31 |
"digit": "0123456789",
|
32 |
"special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
|
33 |
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
|
34 |
"true": true,
|
35 |
"false": false,
|
36 |
"null": null,
|
37 |
"array":[ ],
|
38 |
"object":{ },
|
39 |
"address": "50 St. James Street",
|
40 |
"url": "http://www.JSON.org/",
|
41 |
"comment": "// /* <!-- --",
|
42 |
"# -- --> */": " ",
|
43 |
" s p a c e d " :[1,2 , 3
|
44 |
|
45 |
,
|
46 |
|
47 |
4 , 5 , 6 ,7 ],"compact": [1,2,3,4,5,6,7],
|
48 |
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
|
49 |
"quotes": "" \u0022 %22 0x22 034 "",
|
50 |
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
|
51 |
: "A key can be any string"
|
52 |
},
|
53 |
0.5 ,98.6
|
54 |
,
|
55 |
99.44
|
56 |
,
|
57 |
|
58 |
1066,
|
59 |
1e1,
|
60 |
0.1e1,
|
61 |
1e-1,
|
62 |
1e00,2e+00,2e-00
|
63 |
,"rosebud"]
|
64 |
'''
|
65 |
|
66 |
class TestPass1(TestCase): |
67 |
def test_parse(self): |
68 |
# test in/out equivalence and parsing
|
69 |
res = json.loads(JSON) |
70 |
out = json.dumps(res) |
71 |
self.assertEqual(res, json.loads(out))
|