static void testCopy() { TEST_COPY(PVBoolean, 1); TEST_COPY(PVByte, 12); TEST_COPY(PVShort, 128); TEST_COPY(PVInt, 128000); TEST_COPY(PVLong, 128000000); TEST_COPY(PVUByte, 12); TEST_COPY(PVUShort, 128); TEST_COPY(PVUInt, 128000); TEST_COPY(PVULong, 128000000); TEST_COPY(PVFloat, 12.8); TEST_COPY(PVDouble, 8.12); TEST_COPY(PVString, "jikes"); int32 testValue = 128; // PVStructure test PVStructurePtr pvStructure = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); pvStructure->getSubField<PVInt>("value")->put(testValue); PVTimeStamp timeStamp; timeStamp.attach(pvStructure->getSubField<PVStructure>("timeStamp")); TimeStamp current; current.getCurrent(); timeStamp.set(current); PVStructurePtr pvStructureCopy = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); pvStructureCopy->copy(*pvStructure); testOk(*pvStructure == *pvStructureCopy, "PVStructure copy"); PVStructurePtr pvStructureCopy2 = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); pvStructureCopy2->copyUnchecked(*pvStructure); testOk(*pvStructure == *pvStructureCopy2, "PVStructure copyUnchecked"); BitSet mask(pvStructure->getNumberFields()); PVStructurePtr pvStructureCopy3 = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); PVStructurePtr pvStructureCopy4 = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); pvStructureCopy3->copyUnchecked(*pvStructure, mask); testOk(*pvStructureCopy3 == *pvStructureCopy4, "PVStructure copyUnchecked w/ cleared mask"); mask.set(pvStructure->getSubField<PVInt>("value")->getFieldOffset()); pvStructureCopy3->copyUnchecked(*pvStructure, mask); pvStructureCopy4->getSubField<PVInt>("value")->put(testValue); testOk(*pvStructureCopy3 == *pvStructureCopy4, "PVStructure copyUnchecked w/ value mask only"); mask.set(pvStructure->getSubField<PVStructure>("timeStamp")->getFieldOffset()); PVStructurePtr pvStructureCopy5 = standardPVField->scalar(pvInt, alarmTimeStampValueAlarm); pvStructureCopy5->copyUnchecked(*pvStructure, mask); testOk(*pvStructure == *pvStructureCopy5, "PVStructure copyUnchecked w/ value+timeStamp mask"); UnionConstPtr _union = fieldCreate->createFieldBuilder()-> add("doubleValue", pvDouble)-> add("intValue", pvInt)-> add("timeStamp",standardField->timeStamp())-> createUnion(); PVUnionPtr pvUnion = pvDataCreate->createPVUnion(_union); PVUnionPtr pvUnion2 = pvDataCreate->createPVUnion(_union); pvUnion2->copy(*pvUnion); testOk(*pvUnion == *pvUnion2, "null PVUnion copy"); pvUnion->select<PVInt>("intValue")->put(123); pvUnion2->copy(*pvUnion); testOk(*pvUnion == *pvUnion2, "PVUnion scalar copy, to null PVUnion"); pvUnion->select("doubleValue"); pvUnion2->copy(*pvUnion); testOk(*pvUnion == *pvUnion2, "PVUnion scalar copy, to different type PVUnion"); pvUnion->select<PVStructure>("timeStamp")->copy( *pvStructure->getSubField<PVStructure>("timeStamp") ); pvUnion2->copy(*pvUnion); testOk(*pvUnion == *pvUnion2, "PVUnion PVStructure copy, to different type PVUnion"); }