def initExtraAlltLarge(): m_extraAllt = pizza_special.ExtraAllt() vecSize = 200 halfVecsize = vecSize / 2 m_extraAllt.extraCheese = True m_extraAllt.nrOfMushRooms = 14 m_extraAllt.meetQuality = 9 m_extraAllt.timeBakedHours = 123.4 m_extraAllt.timeBakedSeconds = 53.4 m_extraAllt.description = "Pizza with extra allt" m_cheese = pizza_special.Cheese() m_cheese.name = "gorgonzola" m_cheese.age = 12.0 m_extraAllt.cheese_ = m_cheese boolVal = True byteVal = -42 intVal = 5 floatVal = 15.0 doubleVal = 25.0 longVal = 35 stringVal = "hejsan" cheeseVal = pizza_special.Cheese() cheeseVal.age = 3 cheeseVal.name = "ecklig ost" for i in range(0, vecSize): m_extraAllt.bools.append(boolVal) m_extraAllt.bytes.append(byteVal) m_extraAllt.ints.append(intVal) m_extraAllt.floats.append(floatVal) m_extraAllt.doubles.append(doubleVal) m_extraAllt.longs.append(longVal) m_extraAllt.strings.append(stringVal) m_extraAllt.cheeses.append(cheeseVal) if i == halfVecsize: boolVal = False byteVal = 42 intVal = 10 floatVal = 20.0 doubleVal = 30.0 longVal = 40 stringVal = "hoppsan" cheeseVal = pizza_special.Cheese() cheeseVal.age = 6 cheeseVal.name = "god ost" return m_extraAllt
def initExtraAlltNormal(): m_extraAllt = pizza_special.ExtraAllt() m_extraAllt.extraCheese = True m_extraAllt.nrOfMushRooms = 14 m_extraAllt.meetQuality = 9 m_extraAllt.timeBakedHours = 123.4 m_extraAllt.timeBakedSeconds = 53.4 m_extraAllt.description = "Pizza with extra allt" m_extraAllt.bools = [True, False, True, False, True, False] m_extraAllt.bytes = [-64, -32, -16, 15, 31, 63] m_extraAllt.ints = [0, 123, -523, 1000, -5000] m_extraAllt.longs = [0, 123, -523, 1000, -5000] m_extraAllt.floats = [0.0, 123.0, -523.0, 1000.0, -5000.0] m_extraAllt.doubles = [0.0, 123.0, -523.0, 1000.0, -5000.0] m_extraAllt.strings = ["extra", "allt", "er", "den", "basta", "pizzan"] m_cheese = pizza_special.Cheese() m_cheese.name = "gorgonzola" m_cheese.age = 12.0 m_extraAllt.cheese_ = m_cheese m_listCheese1 = pizza_special.Cheese() m_listCheese1.name = "ost1" m_listCheese1.age = 1.0 m_listCheese2 = pizza_special.Cheese() m_listCheese2.name = "ost2" m_listCheese2.age = 2.0 m_listCheese3 = pizza_special.Cheese() m_listCheese3.name = "ost3" m_listCheese3.age = 3.0 m_listCheese4 = pizza_special.Cheese() m_listCheese4.name = "ost4" m_listCheese4.age = 4.0 m_extraAllt.cheeses = [ m_listCheese1, m_listCheese2, m_listCheese3, m_listCheese4 ] return m_extraAllt
def test_extraAllt(): print("testing extra allt") m_factory = PizzaProjectTypeFactory.PizzaProjectTypeFactory() #initialize data to pack / unpack extraAllt = InitData.initExtraAlltNormal() m_OPS_archiver_out = OPS_Archiver.OPS_Archiver_Out(10000, False) #buffer size #serializing m_OPS_archiver_out.Bool("extraCheese", extraAllt.extraCheese) m_OPS_archiver_out.Int8("nrOfMushRooms", extraAllt.nrOfMushRooms) m_OPS_archiver_out.Int32("meetQuality", extraAllt.meetQuality) m_OPS_archiver_out.Int64("timestamp", extraAllt.timestamp) m_OPS_archiver_out.Float32("timeBakedHours", extraAllt.timeBakedHours) m_OPS_archiver_out.Float64("timeBakedSeconds", extraAllt.timeBakedSeconds) m_OPS_archiver_out.String("description", extraAllt.description) m_OPS_archiver_out.Ops("cheese_", extraAllt.cheese_) m_OPS_archiver_out.BoolVector("bools", extraAllt.bools) m_OPS_archiver_out.Int8Vector("bytes", extraAllt.bytes) m_OPS_archiver_out.Int32Vector("ints", extraAllt.ints) m_OPS_archiver_out.Int64Vector("longs", extraAllt.longs) m_OPS_archiver_out.Float32Vector("floats", extraAllt.floats) m_OPS_archiver_out.Float64Vector("doubles", extraAllt.doubles) m_OPS_archiver_out.StringVector("strings", extraAllt.strings) m_OPS_archiver_out.OpsVector("cheeses", extraAllt.cheeses) #unpacking data m_OPS_archiver_in = OPS_Archiver.OPS_Archiver_In(m_factory, m_OPS_archiver_out.buffer) unpacked_extraAllt = pizza_special.ExtraAllt() unpacked_extraAllt.extraCheese = m_OPS_archiver_in.Bool( "extraCheese", m_OPS_archiver_out.buffer) unpacked_extraAllt.nrOfMushRooms = m_OPS_archiver_in.Int8( "nrOfMushRooms", m_OPS_archiver_out.buffer) unpacked_extraAllt.meetQuality = m_OPS_archiver_in.Int32( "meetQuality", m_OPS_archiver_out.buffer) unpacked_extraAllt.timestamp = m_OPS_archiver_in.Int64( "timestamp", m_OPS_archiver_out.buffer) unpacked_extraAllt.timeBakedHours = m_OPS_archiver_in.Float32( "timeBakedHours", m_OPS_archiver_out.buffer) unpacked_extraAllt.timeBakedSeconds = m_OPS_archiver_in.Float64( "timeBakedSeconds", m_OPS_archiver_out.buffer) unpacked_extraAllt.description = m_OPS_archiver_in.String( "description", m_OPS_archiver_out.buffer) unpacked_extraAllt.cheese_ = m_OPS_archiver_in.Ops( "cheese_", m_OPS_archiver_out.buffer) #unpacling vectors unpacked_bools = [] unpacked_bytes = [] unpacked_ints = [] unpacked_longs = [] unpacked_floats = [] unpacked_doubles = [] unpacked_strings = [] unpacked_cheeses = [] m_OPS_archiver_in.BoolVector("bools", unpacked_bools) m_OPS_archiver_in.Int8Vector("bytes", unpacked_bytes) m_OPS_archiver_in.Int32Vector("ints", unpacked_ints) m_OPS_archiver_in.Int64Vector("longs", unpacked_longs) m_OPS_archiver_in.Float32Vector("floats", unpacked_floats) m_OPS_archiver_in.Float64Vector("doubles", unpacked_doubles) m_OPS_archiver_in.StringVector("strings", unpacked_strings) m_OPS_archiver_in.OpsVector("cheeses", unpacked_cheeses) unpacked_extraAllt.bools = unpacked_bools unpacked_extraAllt.bytes = unpacked_bytes unpacked_extraAllt.ints = unpacked_ints unpacked_extraAllt.floats = unpacked_floats unpacked_extraAllt.longs = unpacked_longs unpacked_extraAllt.doubles = unpacked_doubles unpacked_extraAllt.strings = unpacked_strings unpacked_extraAllt.cheeses = unpacked_cheeses #test data assert (unpacked_extraAllt.extraCheese == True) assert (unpacked_extraAllt.nrOfMushRooms == 14) assert (unpacked_extraAllt.meetQuality == 9) assert (abs(unpacked_extraAllt.timeBakedHours - 123.4) < delta) assert (unpacked_extraAllt.timeBakedSeconds == 53.4) assert (unpacked_extraAllt.description == "Pizza with extra allt") assert (unpacked_extraAllt.cheese_.age == 12.0) assert (unpacked_extraAllt.cheese_.name == "gorgonzola") assert (len(unpacked_extraAllt.bools) == 6) assert (len(unpacked_extraAllt.bytes) == 6) assert (len(unpacked_extraAllt.ints) == 5) assert (len(unpacked_extraAllt.floats) == 5) assert (len(unpacked_extraAllt.doubles) == 5) assert (len(unpacked_extraAllt.longs) == 5) assert (len(unpacked_extraAllt.strings) == 6) assert (len(unpacked_extraAllt.cheeses) == 4) assert (unpacked_extraAllt.bools == [ True, False, True, False, True, False ]) assert (unpacked_extraAllt.bytes == [-64, -32, -16, 15, 31, 63]) assert (unpacked_extraAllt.ints == [0, 123, -523, 1000, -5000]) assert (unpacked_extraAllt.longs == [0, 123, -523, 1000, -5000]) assert (unpacked_extraAllt.floats == [0.0, 123.0, -523.0, 1000.0, -5000.0]) assert (unpacked_extraAllt.doubles == [ 0.0, 123.0, -523.0, 1000.0, -5000.0 ]) assert (unpacked_extraAllt.strings == [ "extra", "allt", "er", "den", "basta", "pizzan" ]) assert (unpacked_extraAllt.cheeses[0].age == 1) assert (unpacked_extraAllt.cheeses[0].name == "ost1") assert (unpacked_extraAllt.cheeses[1].age == 2) assert (unpacked_extraAllt.cheeses[1].name == "ost2") assert (unpacked_extraAllt.cheeses[2].age == 3) assert (unpacked_extraAllt.cheeses[2].name == "ost3") assert (unpacked_extraAllt.cheeses[3].age == 4) assert (unpacked_extraAllt.cheeses[3].name == "ost4")
sys.exit(-1) otherParticipant.addTypeSupport( PizzaProjectTypeFactory.PizzaProjectTypeFactory()) for info in ItemInfoList: if info.TypeName == pizza.PizzaData.TypeName: info.helper = CHelper() info.helper.data = pizza.PizzaData() info.helper.callback = onPizzaData elif info.TypeName == pizza.VessuvioData.TypeName: info.helper = CHelper() info.helper.data = pizza.VessuvioData() info.helper.callback = onVessuvioData elif info.TypeName == pizza_special.ExtraAllt.TypeName: info.helper = CHelper() info.helper.data = pizza_special.ExtraAllt() info.helper.callback = onExtraAllt else: print("no matching typename for " + info.TypeName) if info.Domain == "PizzaDomain": info.part = participant elif info.Domain == "OtherPizzaDomain": info.part = otherParticipant else: print("no matching domain for " + info.Domain) doExit = False menu() p3 = False