Esempio 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)
Esempio n. 2
0
 def test_Polymorphism(self):
     src = test.Bonded()
     obj = self.randomSimpleWithBase()
     # Marshal and instance of SimpleWithBase and us it to
     # initialized bonded<SimpleStruct> field
     Unmarshal(Marshal(obj), src.n2)
     data = Serialize(src)
     dst = test.Bonded()
     Deserialize(data, dst)
     # downcast bonded<SimpleStruct> to bonded<SimpleWithBase>
     bonded = test.bonded_unittest_SimpleWithBase_(dst.n2)
     obj2 = test.SimpleWithBase()
     bonded.Deserialize(obj2)
     self.assertTrue(obj, obj2)
Esempio n. 3
0
 def test_SimpleWithBase(self):
     obj = test.SimpleWithBase()
     self.serialization(obj, self.initSimpleWithBase)
     self.marshaling(obj, self.initSimpleWithBase)
Esempio n. 4
0
 def randomSimpleWithBase(self):
     obj = test.SimpleWithBase()
     self.initSimpleWithBase(obj)
     return obj