test cleanup
remove compile time "debug" flag from from tests. use testDiag() instead
This commit is contained in:
@@ -22,8 +22,6 @@ using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static void testCreateRequestInternal() {
|
||||
printf("testCreateRequest... \n");
|
||||
CreateRequest::shared_pointer createRequest = CreateRequest::create();
|
||||
@@ -32,19 +30,19 @@ static void testCreateRequestInternal() {
|
||||
|
||||
string out;
|
||||
string request = "";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
PVStructurePtr pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getStructure()->getNumberFields()==0);
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[]field()getField()putField()";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field").get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("putField").get()!=NULL);
|
||||
@@ -52,10 +50,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[a=b,x=y]field(a) putField(a),getField(a)";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("record._options.a");
|
||||
sval = pvString->get();
|
||||
@@ -69,10 +67,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "field(a.b[x=y])";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("field.a.b._options.x");
|
||||
sval = pvString->get();
|
||||
@@ -80,19 +78,19 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "field(a.b{c.d})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField("field.a.b.c.d").get()!=NULL);
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "field(a.b[x=y]{c.d})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("field.a.b._options.x");
|
||||
sval = pvString->get();
|
||||
@@ -101,10 +99,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "field(a.b[x=y]{c.d[x=y]})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("field.a.b._options.x");
|
||||
sval = pvString->get();
|
||||
@@ -115,10 +113,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[a=b,c=d] field(a.a[a=b]{a.a[a=b]},b.a[a=b]{a,b})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("field.a.a._options.a");
|
||||
sval = pvString->get();
|
||||
@@ -135,10 +133,10 @@ static void testCreateRequestInternal() {
|
||||
|
||||
|
||||
request = "alarm,timeStamp,power.value";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field.alarm").get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field.timeStamp").get()!=NULL);
|
||||
@@ -146,10 +144,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[process=true]field(alarm,timeStamp,power.value)";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("record._options.process");
|
||||
sval = pvString->get();
|
||||
@@ -160,10 +158,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[process=true]field(alarm,timeStamp[algorithm=onChange,causeMonitor=false],power{value,alarm})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("record._options.process");
|
||||
sval = pvString->get();
|
||||
@@ -181,10 +179,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[int=2,float=3.14159]field(alarm,timeStamp[shareData=true],power.value)";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
pvString = pvRequest->getSubField<PVString>("record._options.int");
|
||||
sval = pvString->get();
|
||||
@@ -203,10 +201,10 @@ static void testCreateRequestInternal() {
|
||||
+ "putField(power.value)"
|
||||
+ "getField(alarm,timeStamp,power{value,alarm},"
|
||||
+ "current{value,alarm},voltage{value,alarm})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("putField.power.value").get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("getField.alarm").get()!=NULL);
|
||||
@@ -223,10 +221,10 @@ static void testCreateRequestInternal() {
|
||||
+ "zero{voltage.value,current.value,power.value},"
|
||||
+ "one{voltage.value,current.value,power.value}"
|
||||
+ "})";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field.alarm").get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field.timeStamp").get()!=NULL);
|
||||
@@ -245,10 +243,10 @@ static void testCreateRequestInternal() {
|
||||
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
|
||||
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}"
|
||||
+ ")";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("putField.power.value").get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("getField.alarm").get()!=NULL);
|
||||
@@ -278,10 +276,10 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "a{b{c{d}}}";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(!pvRequest) { cout<< createRequest->getMessage() << endl;}
|
||||
if(debug) { cout << pvRequest << endl;}
|
||||
|
||||
testOk1(pvRequest.get()!=NULL);
|
||||
testOk1(pvRequest->getSubField<PVStructure>("field.a.b.c.d").get()!=NULL);
|
||||
testPass("request %s",request.c_str());
|
||||
@@ -293,14 +291,14 @@ static void testCreateRequestInternal() {
|
||||
+ "ps0{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}},"
|
||||
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}"
|
||||
+ ")";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
cout << endl << "Error Expected for next call!!" << endl;
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
cout << "reason " << createRequest->getMessage() << endl;
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "record[process=true,power.value";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
cout << endl << "Error Expected for next call!!" << endl;
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
cout << "reason " << createRequest->getMessage() << endl;
|
||||
@@ -308,7 +306,7 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = "field(alarm.status,alarm.severity)";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
cout << endl << "Error Expected for next call!!" << endl;
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
cout << "reason " << createRequest->getMessage() << endl;
|
||||
@@ -316,7 +314,7 @@ static void testCreateRequestInternal() {
|
||||
testPass("request %s",request.c_str());
|
||||
|
||||
request = ":field(record[process=false]power.value)";
|
||||
if(debug) { cout << "request " << request <<endl;}
|
||||
|
||||
cout << endl << "Error Expected for next call!!" << endl;
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
cout << "reason " << createRequest->getMessage() << endl;
|
||||
|
||||
+28
-87
@@ -31,8 +31,6 @@ using namespace std;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace epics::pvData;
|
||||
|
||||
static bool debug = true;
|
||||
|
||||
static void testPVScalar(
|
||||
string const & valueNameMaster,
|
||||
string const & valueNameCopy,
|
||||
@@ -49,58 +47,34 @@ static void testPVScalar(
|
||||
pvValueMaster = pvMaster->getSubField<PVScalar>(valueNameMaster);
|
||||
convert->fromDouble(pvValueMaster,.04);
|
||||
StructureConstPtr structure = pvCopy->getStructure();
|
||||
if(debug) { cout << "structure from copy" << endl << *structure << endl; }
|
||||
pvStructureCopy = pvCopy->createPVStructure();
|
||||
pvValueCopy = pvStructureCopy->getSubField<PVScalar>(valueNameCopy);
|
||||
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
|
||||
pvCopy->initCopy(pvStructureCopy, bitSet);
|
||||
if(debug) { cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
convert->fromDouble(pvValueMaster,.06);
|
||||
testOk1(convert->toDouble(pvValueCopy)==.04);
|
||||
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
|
||||
testOk1(convert->toDouble(pvValueCopy)==.06);
|
||||
testOk1(bitSet->get(pvValueCopy->getFieldOffset()));
|
||||
if(debug) { cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
offset = pvCopy->getCopyOffset(pvValueMaster);
|
||||
if(debug) { cout << "getCopyOffset() " << offset; }
|
||||
if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
|
||||
if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
bitSet->clear();
|
||||
convert->fromDouble(pvValueMaster,1.0);
|
||||
if(debug) { cout << "before updateCopyFromBitSet"; }
|
||||
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
|
||||
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
bitSet->set(0);
|
||||
testOk1(convert->toDouble(pvValueCopy)==0.06);
|
||||
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
|
||||
testOk1(convert->toDouble(pvValueCopy)==1.0);
|
||||
if(debug) { cout << "after updateCopyFromBitSet"; }
|
||||
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
|
||||
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
convert->fromDouble(pvValueCopy,2.0);
|
||||
bitSet->set(0);
|
||||
if(debug) { cout << "before updateMaster"; }
|
||||
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
|
||||
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
testOk1(convert->toDouble(pvValueMaster)==1.0);
|
||||
pvCopy->updateMaster(pvStructureCopy,bitSet);
|
||||
testOk1(convert->toDouble(pvValueMaster)==2.0);
|
||||
if(debug) { cout << "after updateMaster"; }
|
||||
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
|
||||
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
}
|
||||
|
||||
static void testPVScalarArray(
|
||||
@@ -123,13 +97,12 @@ static void testPVScalarArray(
|
||||
const shared_vector<const double> xxx(freeze(values));
|
||||
pvValueMaster->putFrom(xxx);
|
||||
StructureConstPtr structure = pvCopy->getStructure();
|
||||
if(debug) { cout << "structure from copy" << endl << *structure << endl;}
|
||||
|
||||
pvStructureCopy = pvCopy->createPVStructure();
|
||||
pvValueCopy = pvStructureCopy->getSubField<PVScalarArray>(valueNameCopy);
|
||||
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
|
||||
pvCopy->initCopy(pvStructureCopy, bitSet);
|
||||
if(debug) { cout << "after initCopy pvValueCopy " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
values.resize(n);
|
||||
for(size_t i=0; i<n; i++) values[i] = i + .06;
|
||||
const shared_vector<const double> yyy(freeze(values));
|
||||
@@ -139,61 +112,38 @@ static void testPVScalarArray(
|
||||
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
|
||||
pvValueCopy->getAs(cvalues);
|
||||
testOk1(cvalues[0]==0.06);
|
||||
if(debug) { cout << "after put(i+ .06) pvValueCopy " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
offset = pvCopy->getCopyOffset(pvValueMaster);
|
||||
if(debug) { cout << "getCopyOffset() " << offset; }
|
||||
if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
|
||||
if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
bitSet->clear();
|
||||
values.resize(n);
|
||||
for(size_t i=0; i<n; i++) values[i] = i + 1.0;
|
||||
const shared_vector<const double> zzz(freeze(values));
|
||||
pvValueMaster->putFrom(zzz);
|
||||
if(debug) { cout << "before updateCopyFromBitSet"; }
|
||||
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
|
||||
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
bitSet->set(0);
|
||||
pvValueCopy->getAs(cvalues);
|
||||
testOk1(cvalues[0]==0.06);
|
||||
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
|
||||
pvValueCopy->getAs(cvalues);
|
||||
testOk1(cvalues[0]==1.0);
|
||||
if(debug) { cout << "after updateCopyFromBitSet"; }
|
||||
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
|
||||
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
values.resize(n);
|
||||
for(size_t i=0; i<n; i++) values[i] = i + 2.0;
|
||||
const shared_vector<const double> ttt(freeze(values));
|
||||
pvValueMaster->putFrom(ttt);
|
||||
bitSet->set(0);
|
||||
if(debug) { cout << "before updateMaster"; }
|
||||
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
|
||||
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
|
||||
pvValueMaster->getAs(cvalues);
|
||||
testOk1(cvalues[0]==2.0);
|
||||
pvCopy->updateMaster(pvStructureCopy,bitSet);
|
||||
pvValueMaster->getAs(cvalues);
|
||||
testOk1(cvalues[0]==1.0);
|
||||
if(debug) { cout << "before updateMaster"; }
|
||||
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
|
||||
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
|
||||
if(debug) { cout << " bitSet " << *bitSet; }
|
||||
if(debug) { cout << endl; }
|
||||
}
|
||||
|
||||
static void scalarTest()
|
||||
{
|
||||
if(debug) { cout << endl << endl << "****scalarTest****" << endl; }
|
||||
testDiag("scalarTest()");
|
||||
PVStructurePtr pvMaster;
|
||||
string request;
|
||||
PVStructurePtr pvRequest;
|
||||
@@ -208,24 +158,20 @@ static void scalarTest()
|
||||
valueNameMaster = request = "value";
|
||||
CreateRequest::shared_pointer createRequest = CreateRequest::create();
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "";
|
||||
valueNameMaster = "value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "alarm,timeStamp,value";
|
||||
valueNameMaster = "value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
@@ -233,7 +179,8 @@ static void scalarTest()
|
||||
|
||||
static void arrayTest()
|
||||
{
|
||||
if(debug) { cout << endl << endl << "****arrayTest****" << endl; }
|
||||
testDiag("arrayTest");
|
||||
|
||||
PVStructurePtr pvMaster;
|
||||
string request;
|
||||
PVStructurePtr pvRequest;
|
||||
@@ -247,24 +194,21 @@ static void arrayTest()
|
||||
pvMaster = standardPVField->scalarArray(pvDouble,"alarm,timeStamp");
|
||||
valueNameMaster = request = "value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalarArray(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "";
|
||||
valueNameMaster = "value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalarArray(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "alarm,timeStamp,value";
|
||||
valueNameMaster = "value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "value";
|
||||
testPVScalarArray(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
@@ -300,7 +244,8 @@ static PVStructurePtr createPowerSupply()
|
||||
|
||||
static void powerSupplyTest()
|
||||
{
|
||||
if(debug) { cout << endl << endl << "****powerSupplyTest****" << endl; }
|
||||
testDiag("powerSupplyTest");
|
||||
|
||||
PVStructurePtr pvMaster;
|
||||
string request;
|
||||
PVStructurePtr pvRequest;
|
||||
@@ -314,32 +259,28 @@ static void powerSupplyTest()
|
||||
pvMaster = createPowerSupply();
|
||||
valueNameMaster = request = "power.value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "power.value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "";
|
||||
valueNameMaster = "power.value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "power.value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "alarm,timeStamp,voltage.value,power.value,current.value";
|
||||
valueNameMaster = "power.value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "power.value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
request = "alarm,timeStamp,voltage{value,alarm},power{value,alarm,display},current.value";
|
||||
valueNameMaster = "power.value";
|
||||
pvRequest = createRequest->createRequest(request);
|
||||
if(debug) { cout << "request " << request << endl; }
|
||||
if(debug) { cout << "pvRequest\n" << *pvRequest << endl; }
|
||||
|
||||
pvCopy = PVCopy::create(pvMaster,pvRequest,"");
|
||||
valueNameCopy = "power.value";
|
||||
testPVScalar(valueNameMaster,valueNameCopy,pvMaster,pvCopy);
|
||||
|
||||
@@ -25,14 +25,12 @@
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
void testTimeStampInternal()
|
||||
{
|
||||
testOk1(nanoSecPerSec==1000000000);
|
||||
TimeStamp current;
|
||||
current.getCurrent();
|
||||
printf("current %lli %i milliSec %lli\n",
|
||||
testDiag("current %lli %i milliSec %lli\n",
|
||||
(long long)current.getSecondsPastEpoch(),
|
||||
(int)current.getNanoseconds(),
|
||||
(long long)current.getMilliseconds());
|
||||
@@ -40,7 +38,7 @@ void testTimeStampInternal()
|
||||
current.toTime_t(tt);
|
||||
struct tm ctm;
|
||||
memcpy(&ctm,localtime(&tt),sizeof(struct tm));
|
||||
printf(
|
||||
testDiag(
|
||||
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
|
||||
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
|
||||
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
|
||||
@@ -48,13 +46,13 @@ void testTimeStampInternal()
|
||||
(ctm.tm_isdst==0) ? "false" : "true");
|
||||
tt = time(&tt);
|
||||
current.fromTime_t(tt);
|
||||
printf("fromTime_t\ncurrent %lli %i milliSec %lli\n",
|
||||
testDiag("fromTime_t\ncurrent %lli %i milliSec %lli\n",
|
||||
(long long)current.getSecondsPastEpoch(),
|
||||
(int)current.getNanoseconds(),
|
||||
(long long)current.getMilliseconds());
|
||||
current.toTime_t(tt);
|
||||
memcpy(&ctm,localtime(&tt),sizeof(struct tm));
|
||||
printf(
|
||||
testDiag(
|
||||
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d isDst %s\n",
|
||||
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
|
||||
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
|
||||
@@ -66,7 +64,7 @@ void testTimeStampInternal()
|
||||
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
|
||||
double diff;
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
testOk1(diff==0.0);
|
||||
testOk1((left==right));
|
||||
testOk1(!(left!=right));
|
||||
@@ -76,7 +74,7 @@ void testTimeStampInternal()
|
||||
testOk1(!(left>right));
|
||||
left.put(current.getSecondsPastEpoch()+1,current.getNanoseconds());
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
testOk1(diff==1.0);
|
||||
testOk1(!(left==right));
|
||||
testOk1((left!=right));
|
||||
@@ -86,7 +84,7 @@ void testTimeStampInternal()
|
||||
testOk1((left>right));
|
||||
left.put(current.getSecondsPastEpoch()-1,current.getNanoseconds());
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
testOk1(diff==-1.0);
|
||||
testOk1(!(left==right));
|
||||
testOk1((left!=right));
|
||||
@@ -96,7 +94,7 @@ void testTimeStampInternal()
|
||||
testOk1(!(left>right));
|
||||
left.put(current.getSecondsPastEpoch(),current.getNanoseconds()-nanoSecPerSec);
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
testOk1(diff==-1.0);
|
||||
testOk1(!(left==right));
|
||||
testOk1((left!=right));
|
||||
@@ -106,7 +104,7 @@ void testTimeStampInternal()
|
||||
testOk1(!(left>right));
|
||||
left.put(current.getSecondsPastEpoch(),current.getNanoseconds()-1);
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
testOk1(diff<0.0);
|
||||
testOk1(!(left==right));
|
||||
testOk1((left!=right));
|
||||
@@ -117,13 +115,12 @@ void testTimeStampInternal()
|
||||
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
|
||||
left += .1;
|
||||
diff = TimeStamp::diff(left,right);
|
||||
if(debug) printf("diff %e\n",diff);
|
||||
testDiag("diff %e\n",diff);
|
||||
left.put(current.getSecondsPastEpoch(),current.getNanoseconds());
|
||||
int64 inc = -1;
|
||||
left += inc;
|
||||
diff = TimeStamp::diff(left,right);
|
||||
testOk1(diff==-1.0);
|
||||
printf("PASSED\n");
|
||||
}
|
||||
|
||||
MAIN(testTimeStamp)
|
||||
|
||||
+13
-37
@@ -32,7 +32,6 @@ static double oneDelay = 4.0;
|
||||
static double twoDelay = 2.0;
|
||||
static double threeDelay = 1.0;
|
||||
static int ntimes = 3;
|
||||
static bool debug = false;
|
||||
|
||||
class MyCallback;
|
||||
typedef std::tr1::shared_ptr<MyCallback> MyCallbackPtr;
|
||||
@@ -66,10 +65,9 @@ private:
|
||||
|
||||
static void testBasic()
|
||||
{
|
||||
if(debug) {
|
||||
printf("\n\ntestBasic oneDelay %lf twoDelay %lf threeDaley %lf\n",
|
||||
oneDelay,twoDelay,threeDelay);
|
||||
}
|
||||
testDiag("\n\ntestBasic oneDelay %lf twoDelay %lf threeDaley %lf\n",
|
||||
oneDelay,twoDelay,threeDelay);
|
||||
|
||||
string one("one");
|
||||
string two("two");
|
||||
string three("three");
|
||||
@@ -91,10 +89,7 @@ static void testBasic()
|
||||
if(oneDelay>.1) testOk1(timer->isScheduled(callbackOne));
|
||||
if(twoDelay>.1) testOk1(timer->isScheduled(callbackTwo));
|
||||
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
|
||||
if(debug) {
|
||||
std::cout << "timerQueue" << std::endl;
|
||||
std::cout << *timer;
|
||||
}
|
||||
|
||||
eventOne->wait();
|
||||
eventTwo->wait();
|
||||
eventThree->wait();
|
||||
@@ -103,28 +98,19 @@ static void testBasic()
|
||||
diff = TimeStamp::diff(
|
||||
callbackOne->getTimeStamp(),currentTimeStamp);
|
||||
delta = diff - oneDelay;
|
||||
if(debug) {
|
||||
printf("one requested %f actual %f delta %f\n",
|
||||
oneDelay,diff,delta);
|
||||
}
|
||||
|
||||
if(delta<0.0) delta = -delta;
|
||||
testOk1(delta<.1);
|
||||
diff = TimeStamp::diff(
|
||||
callbackTwo->getTimeStamp(),currentTimeStamp);
|
||||
delta = diff - twoDelay;
|
||||
if(debug) {
|
||||
printf("two requested %f actual %f delta %f\n",
|
||||
twoDelay,diff,delta);
|
||||
}
|
||||
|
||||
if(delta<0.0) delta = -delta;
|
||||
testOk1(delta<.1);
|
||||
diff = TimeStamp::diff(
|
||||
callbackThree->getTimeStamp(),currentTimeStamp);
|
||||
delta = diff - threeDelay;
|
||||
if(debug) {
|
||||
printf("three requested %f actual %f delta %f\n",
|
||||
threeDelay,diff,delta);
|
||||
}
|
||||
|
||||
if(delta<0.0) delta = -delta;
|
||||
testOk1(delta<.1);
|
||||
}
|
||||
@@ -133,10 +119,9 @@ static void testBasic()
|
||||
|
||||
static void testCancel()
|
||||
{
|
||||
if(debug) {
|
||||
printf("\n\ntestCancel oneDelay %lf twoDelay %lf threeDaley %lf\n",
|
||||
oneDelay,twoDelay,threeDelay);
|
||||
}
|
||||
testDiag("\n\ntestCancel oneDelay %lf twoDelay %lf threeDaley %lf\n",
|
||||
oneDelay,twoDelay,threeDelay);
|
||||
|
||||
string one("one");
|
||||
string two("two");
|
||||
string three("three");
|
||||
@@ -159,10 +144,7 @@ static void testCancel()
|
||||
if(oneDelay>.1) testOk1(timer->isScheduled(callbackOne));
|
||||
testOk1(!timer->isScheduled(callbackTwo));
|
||||
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
|
||||
if(debug) {
|
||||
std::cout << "timerQueue" << std::endl;
|
||||
std::cout << *timer;
|
||||
}
|
||||
|
||||
eventOne->wait();
|
||||
eventThree->wait();
|
||||
double diff;
|
||||
@@ -170,19 +152,13 @@ static void testCancel()
|
||||
diff = TimeStamp::diff(
|
||||
callbackOne->getTimeStamp(),currentTimeStamp);
|
||||
delta = diff - oneDelay;
|
||||
if(debug) {
|
||||
printf("one requested %f actual %f delta %f\n",
|
||||
oneDelay,diff,delta);
|
||||
}
|
||||
|
||||
if(delta<0.0) delta = -delta;
|
||||
testOk1(delta<.1);
|
||||
diff = TimeStamp::diff(
|
||||
callbackThree->getTimeStamp(),currentTimeStamp);
|
||||
delta = diff - threeDelay;
|
||||
if(debug) {
|
||||
printf("three requested %f actual %f delta %f\n",
|
||||
threeDelay,diff,delta);
|
||||
}
|
||||
|
||||
if(delta<0.0) delta = -delta;
|
||||
testOk1(delta<.1);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
using namespace epics::pvData;
|
||||
using std::string;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static FieldCreatePtr fieldCreate;
|
||||
static PVDataCreatePtr pvDataCreate;
|
||||
static StandardFieldPtr standardField;
|
||||
@@ -47,8 +45,8 @@ static PVStructurePtr enumeratedRecord;
|
||||
|
||||
static void printRecords()
|
||||
{
|
||||
std::cout << "doubleRecord" << std::endl << *doubleRecord << std::endl;
|
||||
std::cout << "enumeratedRecord" << std::endl << *enumeratedRecord << std::endl;
|
||||
std::cout << "# doubleRecord" << std::endl << *doubleRecord << std::endl;
|
||||
std::cout << "# enumeratedRecord" << std::endl << *enumeratedRecord << std::endl;
|
||||
}
|
||||
|
||||
static void createRecords()
|
||||
@@ -61,18 +59,17 @@ static void createRecords()
|
||||
choices.push_back("3");
|
||||
choices.push_back("4");
|
||||
enumeratedRecord = standardPVField->enumerated(choices,alarmTimeStamp);
|
||||
if(debug) printRecords();
|
||||
}
|
||||
|
||||
static void testAlarm()
|
||||
{
|
||||
if(debug) printf("testAlarm\n");
|
||||
testDiag("testAlarm\n");
|
||||
Alarm alarm;
|
||||
PVAlarm pvAlarm;
|
||||
bool result;
|
||||
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("alarm"));
|
||||
if(pvField.get()==NULL) {
|
||||
printf("testAlarm ERROR did not find field alarm\n");
|
||||
testFail("testAlarm ERROR did not find field alarm\n");
|
||||
return;
|
||||
}
|
||||
result = pvAlarm.attach(pvField);
|
||||
@@ -90,22 +87,18 @@ static void testAlarm()
|
||||
string message = alarm.getMessage();
|
||||
string severity = (*AlarmSeverityFunc::getSeverityNames())[alarm.getSeverity()];
|
||||
string status = (*AlarmStatusFunc::getStatusNames())[alarm.getStatus()];
|
||||
if(debug) {
|
||||
printf(" message %s severity %s status %s\n",
|
||||
message.c_str(),severity.c_str(),status.c_str());
|
||||
}
|
||||
printf("testAlarm PASSED\n");
|
||||
testPass("testAlarm PASSED");
|
||||
}
|
||||
|
||||
static void testTimeStamp()
|
||||
{
|
||||
if(debug) printf("testTimeStamp\n");
|
||||
testDiag("testTimeStamp\n");
|
||||
TimeStamp timeStamp;
|
||||
PVTimeStamp pvTimeStamp;
|
||||
bool result;
|
||||
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("timeStamp"));
|
||||
if(pvField.get()==NULL) {
|
||||
printf("testTimeStamp ERROR did not find field timeStamp\n");
|
||||
testFail("testTimeStamp ERROR did not find field timeStamp");
|
||||
return;
|
||||
}
|
||||
result = pvTimeStamp.attach(pvField);
|
||||
@@ -123,29 +116,28 @@ static void testTimeStamp()
|
||||
timeStamp.toTime_t(tt);
|
||||
struct tm ctm;
|
||||
memcpy(&ctm,localtime(&tt),sizeof(struct tm));
|
||||
if(debug) {
|
||||
printf(
|
||||
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d nanoseconds isDst %s userTag %d\n",
|
||||
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
|
||||
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
|
||||
(int)timeStamp.getNanoseconds(),
|
||||
(ctm.tm_isdst==0) ? "false" : "true",
|
||||
(int)timeStamp.getUserTag());
|
||||
}
|
||||
testDiag(
|
||||
"%4.4d.%2.2d.%2.2d %2.2d:%2.2d:%2.2d %d nanoseconds isDst %s userTag %d",
|
||||
ctm.tm_year+1900,ctm.tm_mon + 1,ctm.tm_mday,
|
||||
ctm.tm_hour,ctm.tm_min,ctm.tm_sec,
|
||||
(int)timeStamp.getNanoseconds(),
|
||||
(ctm.tm_isdst==0) ? "false" : "true",
|
||||
(int)timeStamp.getUserTag());
|
||||
|
||||
timeStamp.put(0,0);
|
||||
pvTimeStamp.set(timeStamp);
|
||||
printf("testTimeStamp PASSED\n");
|
||||
testPass("testTimeStamp PASSED\n");
|
||||
}
|
||||
|
||||
static void testControl()
|
||||
{
|
||||
if(debug) printf("testControl\n");
|
||||
testDiag("testControl\n");
|
||||
Control control;
|
||||
PVControl pvControl;
|
||||
bool result;
|
||||
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("control"));
|
||||
if(pvField.get()==NULL) {
|
||||
printf("testControl ERROR did not find field control\n");
|
||||
testFail("testControl ERROR did not find field control\n");
|
||||
return;
|
||||
}
|
||||
result = pvControl.attach(pvField);
|
||||
@@ -160,19 +152,19 @@ static void testControl()
|
||||
testOk1(cl.getHigh()==control.getHigh());
|
||||
double low = control.getLow();
|
||||
double high = control.getHigh();
|
||||
if(debug) printf(" low %f high %f\n",low,high);
|
||||
printf("testControl PASSED\n");
|
||||
testDiag(" low %f high %f\n",low,high);
|
||||
testPass("testControl PASSED\n");
|
||||
}
|
||||
|
||||
static void testDisplay()
|
||||
{
|
||||
if(debug) printf("testDisplay\n");
|
||||
testDiag("testDisplay\n");
|
||||
Display display;
|
||||
PVDisplay pvDisplay;
|
||||
bool result;
|
||||
PVFieldPtr pvField = doubleRecord->getSubField<PVStructure>(string("display"));
|
||||
if(pvField.get()==NULL) {
|
||||
printf("testDisplay ERROR did not find field display\n");
|
||||
testFail("testDisplay ERROR did not find field display\n");
|
||||
return;
|
||||
}
|
||||
result = pvDisplay.attach(pvField);
|
||||
@@ -193,18 +185,18 @@ static void testDisplay()
|
||||
testOk1(dy.getUnits().compare(display.getUnits())==0);
|
||||
double low = display.getLow();
|
||||
double high = display.getHigh();
|
||||
if(debug) printf(" low %f high %f\n",low,high);
|
||||
printf("testDisplay PASSED\n");
|
||||
testDiag(" low %f high %f\n",low,high);
|
||||
testPass("testDisplay PASSED\n");
|
||||
}
|
||||
|
||||
static void testEnumerated()
|
||||
{
|
||||
if(debug) printf("testEnumerated\n");
|
||||
testDiag("testEnumerated\n");
|
||||
PVEnumerated pvEnumerated;
|
||||
bool result;
|
||||
PVFieldPtr pvField = enumeratedRecord->getSubField<PVStructure>(string("value"));
|
||||
if(pvField.get()==NULL) {
|
||||
printf("testEnumerated ERROR did not find field enumerated\n");
|
||||
testFail("testEnumerated ERROR did not find field enumerated\n");
|
||||
return;
|
||||
}
|
||||
result = pvEnumerated.attach(pvField);
|
||||
@@ -213,21 +205,20 @@ static void testEnumerated()
|
||||
string choice = pvEnumerated.getChoice();
|
||||
PVStringArray::const_svector choices = pvEnumerated.getChoices();
|
||||
int32 numChoices = pvEnumerated.getNumberChoices();
|
||||
if(debug) {
|
||||
printf("index %d choice %s choices",(int)index,choice.c_str());
|
||||
for(int i=0; i<numChoices; i++ ) printf(" %s",choices[i].c_str());
|
||||
printf("\n");
|
||||
}
|
||||
testDiag("index %d choice %s choices",(int)index,choice.c_str());
|
||||
for(int i=0; i<numChoices; i++ )
|
||||
testDiag(" %s",choices[i].c_str());
|
||||
|
||||
pvEnumerated.setIndex(2);
|
||||
index = pvEnumerated.getIndex();
|
||||
choice = pvEnumerated.getChoice();
|
||||
if(debug) printf("index %d choice %s\n",(int)index,choice.c_str());
|
||||
printf("testEnumerated PASSED\n");
|
||||
testDiag("index %d choice %s\n",(int)index,choice.c_str());
|
||||
testPass("testEnumerated PASSED\n");
|
||||
}
|
||||
|
||||
MAIN(testProperty)
|
||||
{
|
||||
testPlan(22);
|
||||
testPlan(27);
|
||||
testDiag("Tests property");
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
@@ -239,7 +230,7 @@ MAIN(testProperty)
|
||||
testControl();
|
||||
testDisplay();
|
||||
testEnumerated();
|
||||
if(debug) printRecords();
|
||||
printRecords();
|
||||
return testDone();;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ using namespace epics::pvData;
|
||||
using std::string;
|
||||
using std::tr1::static_pointer_cast;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static FieldCreatePtr fieldCreate;
|
||||
static PVDataCreatePtr pvDataCreate;
|
||||
static StandardFieldPtr standardField;
|
||||
@@ -35,7 +33,7 @@ static void test()
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
if(debug) printf("\ntestBitSetUtil\n");
|
||||
testDiag("\ntestBitSetUtil\n");
|
||||
StringArray fieldNames;
|
||||
PVFieldPtrArray pvFields;
|
||||
fieldNames.reserve(5);
|
||||
@@ -60,28 +58,13 @@ static void test()
|
||||
standardField->scalar(pvDouble,"alarm")));
|
||||
PVStructurePtr pvs = pvDataCreate->createPVStructure(
|
||||
fieldNames,pvFields);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "pvs" << std::endl;
|
||||
oss << *pvs << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
int32 nfields = (int32)pvs->getNumberFields();
|
||||
BitSetPtr bitSet = BitSet::create(nfields);
|
||||
for(int32 i=0; i<nfields; i++) bitSet->set(i);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
BitSetUtil::compress(bitSet,pvs);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
bitSet->clear();
|
||||
PVFieldPtr pvField = pvs->getSubField<PVStructure>("timeStamp");
|
||||
int32 offsetTimeStamp = (int32)pvField->getFieldOffset();
|
||||
@@ -96,21 +79,11 @@ static void test()
|
||||
testOk1(bitSet->get(offsetSeconds)==true);
|
||||
bitSet->set(offsetNano);
|
||||
bitSet->set(offsetUserTag);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
BitSetUtil::compress(bitSet,pvs);
|
||||
testOk1(bitSet->get(offsetSeconds)==false);
|
||||
testOk1(bitSet->get(offsetTimeStamp)==true);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
bitSet->clear();
|
||||
|
||||
pvField = pvs->getSubField<PVStructure>("current");
|
||||
@@ -129,37 +102,17 @@ static void test()
|
||||
bitSet->set(offsetSeverity);
|
||||
bitSet->set(offsetStatus);
|
||||
bitSet->set(offsetMessage);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
BitSetUtil::compress(bitSet,pvs);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
testOk1(bitSet->get(offsetCurrent)==true);
|
||||
bitSet->clear();
|
||||
bitSet->set(offsetSeverity);
|
||||
bitSet->set(offsetStatus);
|
||||
bitSet->set(offsetMessage);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
BitSetUtil::compress(bitSet,pvs);
|
||||
if(debug) {
|
||||
oss.clear();
|
||||
oss << "bitSet" << std::endl;
|
||||
oss << *bitSet << std::endl;
|
||||
std::cout << oss.str();
|
||||
}
|
||||
|
||||
testOk1(bitSet->get(offsetAlarm)==true);
|
||||
bitSet->clear();
|
||||
printf("testBitSetUtil PASSED\n");
|
||||
|
||||
@@ -29,8 +29,6 @@ using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static FieldCreatePtr fieldCreate;
|
||||
static PVDataCreatePtr pvDataCreate;
|
||||
static StandardFieldPtr standardField;
|
||||
@@ -42,8 +40,6 @@ static string allProperties("alarm,timeStamp,display,control,valueAlarm");
|
||||
|
||||
static void testCreatePVStructure()
|
||||
{
|
||||
if(debug)
|
||||
std::cout << std::endl << "testCreatePVStructure" << std::endl;
|
||||
PVStructurePtr pv0 = standardPVField->scalar(
|
||||
pvDouble,alarmTimeStampValueAlarm);
|
||||
PVScalarPtr pv1 = pvDataCreate->createPVScalar(pvString);
|
||||
@@ -57,9 +53,6 @@ static void testCreatePVStructure()
|
||||
pvFields.push_back(pv1);
|
||||
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
|
||||
fieldNames,pvFields);
|
||||
|
||||
if(debug)
|
||||
std::cout << *pvParent << std::endl;
|
||||
|
||||
std::cout << "testCreatePVStructure PASSED" << std::endl;
|
||||
}
|
||||
@@ -91,8 +84,6 @@ static void testPVScalarCommon(string /*fieldName*/,ScalarType stype)
|
||||
} else {
|
||||
convert->fromString(pvScalar,string("10"));
|
||||
}
|
||||
if(debug)
|
||||
std::cout << *pvScalar << std::endl;
|
||||
}
|
||||
|
||||
static void testPVScalarWithProperties(
|
||||
@@ -296,14 +287,10 @@ static void testPVScalarWithProperties(
|
||||
testOk1(severity.get()!=0);
|
||||
severity->put(1);
|
||||
}
|
||||
if(debug)
|
||||
std::cout << *pvStructure << std::endl;
|
||||
}
|
||||
|
||||
static void testPVScalar()
|
||||
{
|
||||
if(debug)
|
||||
std::cout << std::endl << "testScalar" << std::endl;
|
||||
testPVScalarCommon(string("boolean"),pvByte);
|
||||
testPVScalarCommon(string("byte"),pvByte);
|
||||
testPVScalarCommon(string("short"),pvShort);
|
||||
@@ -353,16 +340,12 @@ static void testScalarArrayCommon(string /*fieldName*/,ScalarType stype)
|
||||
values[2] = "2";
|
||||
convert->fromStringArray(scalarArray, 0,3,values,0);
|
||||
}
|
||||
if(debug)
|
||||
std::cout << *pvStructure << std::endl;
|
||||
PVFieldPtr pvField = pvStructure->getSubField<PVInt>("alarm.status");
|
||||
testOk1(pvField.get()!=0);
|
||||
}
|
||||
|
||||
static void testScalarArray()
|
||||
{
|
||||
if(debug)
|
||||
std::cout << std::endl << "testScalarArray" << std::endl;
|
||||
testScalarArrayCommon(string("boolean"),pvBoolean);
|
||||
testScalarArrayCommon(string("byte"),pvByte);
|
||||
testScalarArrayCommon(string("short"),pvShort);
|
||||
@@ -375,10 +358,7 @@ static void testScalarArray()
|
||||
}
|
||||
|
||||
static void testRequest()
|
||||
{
|
||||
if(debug)
|
||||
std::cout << std::endl << "testScalarArray" << std::endl;
|
||||
|
||||
{
|
||||
StringArray nullNames;
|
||||
FieldConstPtrArray nullFields;
|
||||
StringArray optionNames(1);
|
||||
@@ -448,9 +428,6 @@ void testCopyCase(typename T::value_type val, const char* typeName)
|
||||
|
||||
static void testCopy()
|
||||
{
|
||||
if(debug)
|
||||
std::cout << std::endl << "testCopy" << std::endl;
|
||||
|
||||
TEST_COPY(PVBoolean, 1);
|
||||
TEST_COPY(PVByte, 12);
|
||||
TEST_COPY(PVShort, 128);
|
||||
|
||||
@@ -25,16 +25,14 @@ using namespace epics::pvData;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using std::string;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static FieldCreatePtr fieldCreate = getFieldCreate();
|
||||
static StandardFieldPtr standardField = getStandardField();
|
||||
|
||||
static void print(const string& name, FieldConstPtr const & f)
|
||||
{
|
||||
if(debug) {
|
||||
std::cout << std::endl << name << std::endl << f << std::endl;
|
||||
}
|
||||
std::ostringstream strm;
|
||||
strm << std::endl << name << std::endl << f << std::endl;
|
||||
testDiag("%s", strm.str().c_str());
|
||||
}
|
||||
|
||||
MAIN(testStandardField)
|
||||
|
||||
@@ -26,17 +26,15 @@ using namespace epics::pvData;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using std::string;
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
|
||||
static StandardFieldPtr standardField = getStandardField();
|
||||
static StandardPVFieldPtr standardPVField = getStandardPVField();
|
||||
|
||||
static void print(const string& name, PVFieldPtr const & f)
|
||||
{
|
||||
if(debug) {
|
||||
std::cout << std::endl << name << std::endl << f << std::endl;
|
||||
}
|
||||
std::ostringstream strm;
|
||||
strm << std::endl << name << std::endl << f << std::endl;
|
||||
testDiag("%s", strm.str().c_str());
|
||||
}
|
||||
|
||||
MAIN(testStandardPVField)
|
||||
|
||||
Reference in New Issue
Block a user