]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/json/tests/test_pass1.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / json / tests / test_pass1.py
1 from json.tests import PyTest, CTest
2
3
4 # from http://json.org/JSON_checker/test/pass1.json
5 JSON = r'''
6 [
7 "JSON Test Pattern pass1",
8 {"object with 1 member":["array with 1 element"]},
9 {},
10 [],
11 -42,
12 true,
13 false,
14 null,
15 {
16 "integer": 1234567890,
17 "real": -9876.543210,
18 "e": 0.123456789e-12,
19 "E": 1.234567890E+34,
20 "": 23456789012E666,
21 "zero": 0,
22 "one": 1,
23 "space": " ",
24 "quote": "\"",
25 "backslash": "\\",
26 "controls": "\b\f\n\r\t",
27 "slash": "/ & \/",
28 "alpha": "abcdefghijklmnopqrstuvwyz",
29 "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
30 "digit": "0123456789",
31 "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
32 "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
33 "true": true,
34 "false": false,
35 "null": null,
36 "array":[ ],
37 "object":{ },
38 "address": "50 St. James Street",
39 "url": "http://www.JSON.org/",
40 "comment": "// /* <!-- --",
41 "# -- --> */": " ",
42 " s p a c e d " :[1,2 , 3
43
44 ,
45
46 4 , 5 , 6 ,7 ],
47 "compact": [1,2,3,4,5,6,7],
48 "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
49 "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
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
60
61 ,"rosebud"]
62 '''
63
64 class TestPass1(object):
65 def test_parse(self):
66 # test in/out equivalence and parsing
67 res = self.loads(JSON)
68 out = self.dumps(res)
69 self.assertEqual(res, self.loads(out))
70 try:
71 self.dumps(res, allow_nan=False)
72 except ValueError:
73 pass
74 else:
75 self.fail("23456789012E666 should be out of range")
76
77
78 class TestPyPass1(TestPass1, PyTest): pass
79 class TestCPass1(TestPass1, CTest): pass