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