Beispiel #1
0
	def test_bool(self):
		a = True
		self.assertTrue(isinstance(pcv(a), bool))
		b = 'true'
		self.assertTrue(isinstance(pcv(b), bool))
		c = 'FALSE'
		self.assertTrue(isinstance(pcv(c), bool))
Beispiel #2
0
	def test_obj_array(self):
		a = u'id:12,name:king;id:20,name:queen'
		parsed_a = pcv(a)
		self.assertTrue(isinstance(parsed_a, list))
		b = u'id:7,name:jake;'
		parsed_b = pcv(b)
		self.assertEquals(len(parsed_b), 1)
		self.assertEquals(parsed_b[0], {u'id': 7, u'name': 'jake'})
Beispiel #3
0
	def test_array(self):
		a = u'1,2,3,4'
		self.assertTrue(isinstance(pcv(a), list))
		b = u'1,'
		self.assertTrue(isinstance(pcv(b), list))
		c = u'hello,world'
		parsed_c = pcv(c)
		self.assertTrue(isinstance(parsed_c, list))
		self.assertEquals(parsed_c[0], 'hello')
		d = u'true,false'
		self.assertEquals(pcv(d)[0], True)
Beispiel #4
0
	def test_object(self):
		a = u'name:dong,age:18,isMax:true'
		parsed_a = pcv(a)
		self.assertTrue(isinstance(parsed_a, dict))
		self.assertEquals(parsed_a[u'name'], 'dong')
		self.assertEquals(parsed_a[u'age'], 18)
		self.assertEquals(parsed_a[u'isMax'], True)
Beispiel #5
0
	def test_int(self):
		a = 18
		self.assertTrue(isinstance(pcv(a), int))
Beispiel #6
0
	def test_string(self):
		a = u'foo'
		self.assertTrue(isinstance(pcv(a), str))
		b = u'你好'
		self.assertTrue(isinstance(pcv(b), str))
Beispiel #7
0
	def test_date(self):
		a = datetime.datetime.now()
		self.assertEquals(pcv(a), a.ctime())
Beispiel #8
0
	def test_float(self):
		a = 3.14
		self.assertTrue(isinstance(pcv(a), float))