Пример #1
0
void testDeserializeStructureAndCreatePVStructure()
{
	buffer->clear();
	registry->reset();
	StructureConstPtr structureIn = getStructure("structure1");
	serialize(structureIn,registry);

	buffer->flip();
	PVStructurePtr pvStructureOut = registry->deserializeStructureAndCreatePVStructure(buffer,control);
	StructureConstPtr structureOut = pvStructureOut->getStructure();
	assert(structureIn->getFieldName() == structureOut->getFieldName());
	assert(structureIn->getType() == structureOut->getType());
	delete pvStructureOut;
}
Пример #2
0
void testSerializeFull()
{
	buffer->clear();
	ScalarConstPtr scalarIn = getScalar("field1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarIn),buffer,flusher);
	buffer->flip();
        ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(IntrospectionRegistry::deserializeFull(buffer,control));
	PVField *pvField = pvDataCreate->createPVField(0,scalarOut);
	pvFieldArray.push_back(pvField);
	assert(scalarIn->getFieldName() == scalarOut->getFieldName());
	assert(scalarIn->getType() == scalarOut->getType());

	buffer->clear();
	ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarArrayIn),buffer,flusher);
	buffer->flip();
        ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,scalarArrayOut);
	pvFieldArray.push_back(pvField);
	assert(scalarArrayIn->getFieldName() == scalarArrayOut->getFieldName());
	assert(scalarArrayIn->getType() == scalarArrayOut->getType());

	buffer->clear();
	StructureConstPtr structureIn = getStructure("struct1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureIn),buffer,flusher);
	buffer->flip();
        StructureConstPtr structureOut = static_pointer_cast<const Structure>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,structureOut);
	pvFieldArray.push_back(pvField);
	assert(structureIn->getFieldName() == structureOut->getFieldName());
	assert(structureIn->getType() == structureOut->getType());

	buffer->clear();
	StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureArrayIn),buffer,flusher);
	buffer->flip();
        StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,structureArrayOut);
	pvFieldArray.push_back(pvField);
	assert(structureArrayIn->getFieldName() == structureArrayOut->getFieldName());
	assert(structureArrayIn->getType() == structureArrayOut->getType());
}