예제 #1
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadWriteCopies(self):
     orig_obj = {'a':' " '}
     json_str = cjsonx.encode(orig_obj)
     copy_obj = cjsonx.decode(json_str)
     self.assertEqual(orig_obj, copy_obj)
     self.assertEqual(True, orig_obj == copy_obj)
     self.assertEqual(False, orig_obj is copy_obj)
예제 #2
0
파일: tests.py 프로젝트: petronius/cjsonx
    def testReadLongArray(self):
        src = '''[    "used",
    "abused",
    "confused",
    true, false, null,
    1,
    2,
    [3, 4, 5]]
'''
        obj = cjsonx.decode(src)
        self.assertEqual(["used","abused","confused", True, False, None,
                          1,2,[3,4,5]], obj)
예제 #3
0
파일: tests.py 프로젝트: petronius/cjsonx
    def testReadComplexArray(self):
        src = '''
[
    { "name": "Patrick", "age" : 44,
      "Employed?" : true, "Female?" : false,
      "grandchildren":null },
    "used",
    "abused",
    "confused",
    1,
    2,
    [3, 4, 5]
]
'''
        obj = cjsonx.decode(src)
        self.assertEqual([{"name":"Patrick","age":44,"Employed?":True,"Female?":False,"grandchildren":None},
                          "used","abused","confused",
                          1,2,[3,4,5]], obj)
예제 #4
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEmptyObjectAtEndOfArray(self):
     self.assertEqual(["a","b","c",{}],
                      cjsonx.decode('["a","b","c",{}]'))
예제 #5
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEmptyObjectMidArray(self):
     self.assertEqual(["a","b",{},"c"],
                      cjsonx.decode('["a","b",{},"c"]'))
예제 #6
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEmptyArray(self):
     obj = cjsonx.decode('[]')
     self.assertEqual([], obj)
예제 #7
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadNegativeFloatValue(self):
     obj = cjsonx.decode(' { "key" : -44.5 } ')
     self.assertEqual({ "key" : -44.5 }, obj)
예제 #8
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedQuotationMark(self):
     obj = cjsonx.decode(r'"\""')
     self.assertEqual(r'"', obj)
예제 #9
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedBackspace(self):
     obj = cjsonx.decode(r'"\b"')
     self.assertEqual("\b", obj)
예제 #10
0
파일: tests.py 프로젝트: petronius/cjsonx
    def testReadComplexObject(self):
        src = '''
    { "name": "Patrick", "age" : 44, "Employed?" : true, "Female?" : false, "grandchildren":null }
'''
        obj = cjsonx.decode(src)
        self.assertEqual({"name":"Patrick","age":44,"Employed?":True,"Female?":False,"grandchildren":None}, obj)
예제 #11
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testObjectWithNonEmptyList(self):
     obj = cjsonx.decode('{"test": [3, 4, 5] }')
     self.assertEqual({"test":[3, 4, 5]}, obj)
예제 #12
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadNull(self):
     self.assertEqual(None, cjsonx.decode("null"))
예제 #13
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadArrayOfSymbols(self):
     self.assertEqual([True, False, None], cjsonx.decode(" [ true, false,null] "))
예제 #14
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadFalse(self):
     self.assertEqual(False, cjsonx.decode("false"))
예제 #15
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadTrue(self):
     self.assertEqual(True, cjsonx.decode("true"))
예제 #16
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadSmallArray(self):
     obj = cjsonx.decode(' [ "a" , "b", "c" ] ')
     self.assertEqual(["a", "b", "c"], obj)
예제 #17
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadClosingObjectBracket(self):
     self.assertEqual({"a":[1,2,3]}, cjsonx.decode('{"a":[1,2,3]}'))
예제 #18
0
파일: tests.py 프로젝트: petronius/cjsonx
 def doReadBadNumber(self):
     cjsonx.decode('-44.4.4')
예제 #19
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testEmptyObjectInList(self):
     obj = cjsonx.decode('[{}]')
     self.assertEqual([{}], obj)
예제 #20
0
파일: tests.py 프로젝트: petronius/cjsonx
 def doReadIncompleteArray(self):
     cjsonx.decode('[')
예제 #21
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadStringValue(self):
     obj = cjsonx.decode('{ "name" : "Patrick" }')
     self.assertEqual({ "name" : "Patrick" }, obj)
예제 #22
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedNewline(self):
     obj = cjsonx.decode(r'"\n"')
     self.assertEqual("\n", obj)
예제 #23
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedReverseSolidus(self):
     obj = cjsonx.decode(r'"\\"')
     self.assertEqual("\\", obj)
예제 #24
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedHorizontalTab(self):
     obj = cjsonx.decode(r'"\t"')
     self.assertEqual("\t", obj)
예제 #25
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedFormfeed(self):
     obj = cjsonx.decode(r'"\f"')
     self.assertEqual("\f", obj)
예제 #26
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadSmallObject(self):
     obj = cjsonx.decode('{ "name" : "Patrick", "age":44} ')
     self.assertEqual({ "age" : 44, "name" : "Patrick" }, obj)        
예제 #27
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedCarriageReturn(self):
     obj = cjsonx.decode(r'"\r"')
     self.assertEqual("\r", obj)
예제 #28
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEmptyObject(self):
     obj = cjsonx.decode("{}")
     self.assertEqual({}, obj)
예제 #29
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadEscapedHexCharacter(self):
     obj = cjsonx.decode(r'"\u000A"')
     self.assertEqual("\n", obj)
     obj = cjsonx.decode(r'"\u1001"')
     self.assertEqual(u'\u1001', obj)
예제 #30
0
파일: tests.py 프로젝트: petronius/cjsonx
 def testReadFloatValue(self):
     obj = cjsonx.decode('{ "age" : 44.5 }')
     self.assertEqual({ "age" : 44.5 }, obj)