Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.json_tests.test_scanstring.TestCScanstring Class Reference
Inheritance diagram for test.json_tests.test_scanstring.TestCScanstring:
Inheritance graph
[legend]
Collaboration diagram for test.json_tests.test_scanstring.TestCScanstring:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_scanstring
def test_overflow

Static Public Attributes

 json = cjson
tuple loads = staticmethod(cjson.loads)
tuple dumps = staticmethod(cjson.dumps)

Detailed Description

Definition at line 103 of file test_scanstring.py.


Member Function Documentation

Definition at line 97 of file test_scanstring.py.

00097 
00098     def test_overflow(self):
00099         with self.assertRaises(OverflowError):
00100             self.json.decoder.scanstring(b"xxx", sys.maxsize+1)
00101 

Here is the call graph for this function:

Definition at line 6 of file test_scanstring.py.

00006 
00007     def test_scanstring(self):
00008         scanstring = self.json.decoder.scanstring
00009         self.assertEqual(
00010             scanstring('"z\\ud834\\udd20x"', 1, True),
00011             ('z\U0001d120x', 16))
00012 
00013         if sys.maxunicode == 65535:
00014             self.assertEqual(
00015                 scanstring('"z\U0001d120x"', 1, True),
00016                 ('z\U0001d120x', 6))
00017         else:
00018             self.assertEqual(
00019                 scanstring('"z\U0001d120x"', 1, True),
00020                 ('z\U0001d120x', 5))
00021 
00022         self.assertEqual(
00023             scanstring('"\\u007b"', 1, True),
00024             ('{', 8))
00025 
00026         self.assertEqual(
00027             scanstring('"A JSON payload should be an object or array, not a string."', 1, True),
00028             ('A JSON payload should be an object or array, not a string.', 60))
00029 
00030         self.assertEqual(
00031             scanstring('["Unclosed array"', 2, True),
00032             ('Unclosed array', 17))
00033 
00034         self.assertEqual(
00035             scanstring('["extra comma",]', 2, True),
00036             ('extra comma', 14))
00037 
00038         self.assertEqual(
00039             scanstring('["double extra comma",,]', 2, True),
00040             ('double extra comma', 21))
00041 
00042         self.assertEqual(
00043             scanstring('["Comma after the close"],', 2, True),
00044             ('Comma after the close', 24))
00045 
00046         self.assertEqual(
00047             scanstring('["Extra close"]]', 2, True),
00048             ('Extra close', 14))
00049 
00050         self.assertEqual(
00051             scanstring('{"Extra comma": true,}', 2, True),
00052             ('Extra comma', 14))
00053 
00054         self.assertEqual(
00055             scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, True),
00056             ('Extra value after close', 26))
00057 
00058         self.assertEqual(
00059             scanstring('{"Illegal expression": 1 + 2}', 2, True),
00060             ('Illegal expression', 21))
00061 
00062         self.assertEqual(
00063             scanstring('{"Illegal invocation": alert()}', 2, True),
00064             ('Illegal invocation', 21))
00065 
00066         self.assertEqual(
00067             scanstring('{"Numbers cannot have leading zeroes": 013}', 2, True),
00068             ('Numbers cannot have leading zeroes', 37))
00069 
00070         self.assertEqual(
00071             scanstring('{"Numbers cannot be hex": 0x14}', 2, True),
00072             ('Numbers cannot be hex', 24))
00073 
00074         self.assertEqual(
00075             scanstring('[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', 21, True),
00076             ('Too deep', 30))
00077 
00078         self.assertEqual(
00079             scanstring('{"Missing colon" null}', 2, True),
00080             ('Missing colon', 16))
00081 
00082         self.assertEqual(
00083             scanstring('{"Double colon":: null}', 2, True),
00084             ('Double colon', 15))
00085 
00086         self.assertEqual(
00087             scanstring('{"Comma instead of colon", null}', 2, True),
00088             ('Comma instead of colon', 25))
00089 
00090         self.assertEqual(
00091             scanstring('["Colon instead of comma": false]', 2, True),
00092             ('Colon instead of comma', 25))
00093 
00094         self.assertEqual(
00095             scanstring('["Bad value", truth]', 2, True),
00096             ('Bad value', 12))

Here is the call graph for this function:


Member Data Documentation

tuple test.json_tests.CTest.dumps = staticmethod(cjson.dumps) [static, inherited]

Definition at line 24 of file __init__.py.

test.json_tests.CTest.json = cjson [static, inherited]

Definition at line 22 of file __init__.py.

tuple test.json_tests.CTest.loads = staticmethod(cjson.loads) [static, inherited]

Definition at line 23 of file __init__.py.


The documentation for this class was generated from the following file: