Exemplo n.º 1
0
 def test_Bonded(self):
     obj = self.randomSimpleStruct()
     src = test.Bonded()
     # initialized bonded<T> with instance of T
     src.n2 = test.bonded_unittest_SimpleStruct_(obj)
     data = Serialize(src)
     dst = test.Bonded()
     Deserialize(data, dst)
     # serialize bonded<T>
     data2 = Serialize(dst.n2)
     obj1 = test.SimpleStruct()
     # deserialize from bonded<T>
     dst.n2.Deserialize(obj1)
     self.assertTrue(obj == obj1)
     obj2 = test.SimpleStruct()
     Deserialize(data2, obj2)
     self.assertTrue(obj1 == obj2)
     # bonded<T> downcasting
     src2 = test.Nested()
     src2.n2 = self.randomSimpleWithBase()
     dst2 = test.Bonded()
     Deserialize(Serialize(src), dst2)
     # downcast bonded<SimpleStruct> to bonded<SimpleWithBase>
     bonded = test.bonded_unittest_SimpleWithBase_(dst2.n2)
     obj3 = test.SimpleWithBase()
     bonded.Deserialize(obj3)
     self.assertTrue(obj3, src2.n2)
Exemplo n.º 2
0
 def initNullable(self, obj):
     obj.nullable_list = random_list(random.random)
     obj.nullable_struct = test.SimpleStruct()
     obj.nullable_map = random_map(random_int8, random_int8)
     obj.nullable_string = random_string()
     obj.nullable_nullable_uint32 = random_uint(32)
     self.assertNotEqual(None, obj.nullable_list)
     self.assertNotEqual(None, obj.nullable_struct)
     self.assertNotEqual(None, obj.nullable_map)
     self.assertNotEqual(None, obj.nullable_string)
     self.assertNotEqual(None, obj.nullable_nullable_uint32)
Exemplo n.º 3
0
 def initNullable(self, obj):
     obj.nullable_list = random_list(random.random)
     obj.nullable_struct = test.SimpleStruct()
     obj.nullable_map = random_map(random_int8, random_int8)
     obj.nullable_string = random_string()
     obj.nullable_blob = random_blob()
     obj.nullable_nullable_uint32 = random_uint(32)
     self.assertNotEqual(None, obj.nullable_list)
     self.assertNotEqual(None, obj.nullable_struct)
     self.assertNotEqual(None, obj.nullable_map)
     self.assertNotEqual(None, obj.nullable_string)
     self.assertNotEqual(None, obj.nullable_blob)
     self.assertNotEqual(None, obj.nullable_nullable_uint32)
     obj.list_nullable_struct = [None, self.randomSimpleStruct()]
     self.assertEqual(None, obj.list_nullable_struct[0])
     self.assertNotEqual(None, obj.list_nullable_struct[1])
     obj.map_nullable_float = dict([(0, None), (1, 3.14)])
     self.assertEqual(None, obj.map_nullable_float[0])
     self.assertNotEqual(None, obj.map_nullable_float[1])
     obj.vector_nullable_string = [None, "str"]
     self.assertEqual(None, obj.vector_nullable_string[0])
     self.assertNotEqual(None, obj.vector_nullable_string[1])
Exemplo n.º 4
0
 def test_SimpleStruct(self):
     obj = test.SimpleStruct()
     self.serialization(obj, self.initSimpleStruct)
     self.marshaling(obj, self.initSimpleStruct)
Exemplo n.º 5
0
 def randomSimpleStruct(self):
     obj = test.SimpleStruct()
     self.initSimpleStruct(obj)
     return obj