示例#1
0
 def test_read_everything(self):
     text = """
         [ [ "Jon Snow"
           , "Lord Varys"
           , "The "Little Finger"" ]
         , [ ] ]
         , 20.14, fAlSe, 'X'
         , [ -2 , 0 , 1 , 4 ]
     """
     reader = tc.Reader(text)
     self.assertTrue(deep_equals(reader.next("String[][]"), 
                     [["Jon Snow", "Lord Varys", 'The "Little Finger"'], []]))
     reader.next()
     self.assertEqual(reader.next("double"), 20.14)
     reader.next()
     self.assertEqual(reader.next("boolean"), False)
     reader.next()
     self.assertEqual(reader.next("char"), 'X')
     reader.next()
     self.assertEqual(reader.next("int[]"), [-2, 0, 1, 4])
示例#2
0
 def check(self, value, type):
     self.assertTrue(deep_equals(tc.Reader(tc.write(value, type)).next(type), value))
示例#3
0
 def test_deep_equals(self):
     self.assertTrue(deep_equals([], []))
     self.assertTrue(deep_equals([123], [123]))
     self.assertFalse(deep_equals([123], [123, 456]))
     self.assertTrue(deep_equals([[123], [1, 2, 3]], [[123], [1, 2, 3]]))
示例#4
0
 def test_read_array_2d(self):
     reader = tc.Reader('[ ["abc", "def"], ["foo", "bar"] ]')
     arr = reader.next("String[][]")
     self.assertTrue(deep_equals(arr, [["abc", "def"], ["foo", "bar"]]))
示例#5
0
 def test_read_array(self):
     reader = tc.Reader("[2, 3, 1, 4, 6, 5]")
     arr = reader.next("int[]")
     self.assertTrue(deep_equals(arr, [2, 3, 1, 4, 6, 5]))
示例#6
0
 def test_deep_equals(self):
     self.assertTrue(deep_equals([], []))
     self.assertTrue(deep_equals([123], [123]))
     self.assertFalse(deep_equals([123], [123, 456]))
     self.assertTrue(deep_equals([[123], [1, 2, 3]], [[123], [1, 2, 3]]))
示例#7
0
 def test_read_array_2d(self):
     reader = tc.Reader('[ ["abc", "def"], ["foo", "bar"] ]')
     arr = reader.next("String[][]")
     self.assertTrue(deep_equals(arr, [["abc", "def"], ["foo", "bar"]]))
示例#8
0
 def test_read_array(self):
     reader = tc.Reader("[2, 3, 1, 4, 6, 5]")
     arr = reader.next("int[]")
     self.assertTrue(deep_equals(arr, [2, 3, 1, 4, 6, 5]))
示例#9
0
 def check(self, value, type):
     self.assertTrue(
         deep_equals(tc.Reader(tc.write(value, type)).next(type), value))