String -> std::string, toString methods removed

This commit is contained in:
Matej Sekoranja
2014-06-19 14:27:48 +02:00
parent 6ec207141f
commit c6eed12139
82 changed files with 1606 additions and 1651 deletions

View File

@@ -14,6 +14,7 @@
#include <pv/createRequest.h>
using namespace epics::pvData;
using std::string;
using std::cout;
using std::endl;
@@ -23,8 +24,8 @@ void testCreateRequest() {
printf("testCreateRequest... \n");
CreateRequest::shared_pointer createRequest = CreateRequest::create();
String out;
String request = "";
string out;
string request = "";
if(debug) { cout << "request " << request <<endl;}
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(debug) { cout<< createRequest->getMessage() << endl;}
@@ -43,7 +44,7 @@ void testCreateRequest() {
testOk1(pvRequest!=NULL);
if(debug) { cout << pvRequest->dumpValue(cout) << endl;}
PVStringPtr pvString = pvRequest->getSubField<PVString>("record.a");
String sval = pvString->get();
string sval = pvString->get();
testOk(sval.compare("b")==0,"record.a = b");
pvString = pvRequest->getSubField<PVString>("record.x");
sval = pvString->get();
@@ -131,7 +132,7 @@ void testCreateRequest() {
request = "alarm,timeStamp,power.value";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << endl << String("request") <<endl << request <<endl;}
if(debug) { cout << endl << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -144,7 +145,7 @@ void testCreateRequest() {
request = "record[process=true]field(alarm,timeStamp,power.value)";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << endl << String("request") <<endl << request <<endl;}
if(debug) { cout << endl << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -160,7 +161,7 @@ void testCreateRequest() {
request = "record[process=true]field(alarm,timeStamp[algorithm=onChange,causeMonitor=false],power{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -183,7 +184,7 @@ void testCreateRequest() {
request = "record[int=2,float=3.14159]field(alarm,timeStamp[shareData=true],power.value)";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -202,12 +203,12 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -224,12 +225,12 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("field(alarm,timeStamp,supply{")
request = string("field(alarm,timeStamp,supply{")
+ "0{voltage.value,current.value,power.value},"
+ "1{voltage.value,current.value,power.value}"
+ "})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -245,7 +246,7 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
@@ -253,7 +254,7 @@ void testCreateRequest() {
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}"
+ ")";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -288,13 +289,13 @@ void testCreateRequest() {
request = "a{b{c{d}}}";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
testOk1(pvRequest!=NULL);
testOk1(pvRequest->getSubField("field.a.b.c.d")!=NULL);
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
@@ -302,14 +303,14 @@ void testCreateRequest() {
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}"
+ ")";
if(debug) { cout << endl << "Error Expected for next call!!" << endl;}
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
pvRequest = createRequest->createRequest(request);
assert(pvRequest.get()==NULL);
if(debug) {cout << "reason " << createRequest->getMessage() << endl;}
testPass("request %s",request.c_str());
request = "record[process=true,power.value";
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(debug) { cout << endl << "Error Expected for next call!!" << endl;}
pvRequest = createRequest->createRequest(request);
assert(pvRequest.get()==NULL);

View File

@@ -35,8 +35,8 @@ using namespace epics::pvData;
static bool debug = true;
static void testPVScalar(
String const & valueNameMaster,
String const & valueNameCopy,
string const & valueNameMaster,
string const & valueNameCopy,
PVStructurePtr const & pvMaster,
PVCopyPtr const & pvCopy)
{
@@ -45,7 +45,6 @@ static void testPVScalar(
PVScalarPtr pvValueMaster;
PVScalarPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
ConvertPtr convert = getConvert();
@@ -53,8 +52,7 @@ static void testPVScalar(
pvValueMaster = static_pointer_cast<PVScalar>(pvField);
convert->fromDouble(pvValueMaster,.04);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
if(debug) { cout << "structure from copy" << endl << builder << endl; }
if(debug) { cout << "structure from copy" << endl << *structure << endl; }
pvStructureCopy = pvCopy->createPVStructure();
pvField = pvStructureCopy->getSubField(valueNameCopy);
pvValueCopy = static_pointer_cast<PVScalar>(pvField);
@@ -68,24 +66,20 @@ static void testPVScalar(
testOk1(convert->toDouble(pvValueCopy)==.06);
testOk1(bitSet->get(pvValueCopy->getFieldOffset()));
if(debug) { cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy); }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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 " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->clear();
convert->fromDouble(pvValueMaster,1.0);
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << "before updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->set(0);
testOk1(convert->toDouble(pvValueCopy)==0.06);
@@ -94,14 +88,14 @@ static void testPVScalar(
if(debug) { cout << "after updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
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 " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
testOk1(convert->toDouble(pvValueMaster)==1.0);
pvCopy->updateMaster(pvStructureCopy,bitSet);
@@ -109,14 +103,14 @@ static void testPVScalar(
if(debug) { cout << "after updateMaster"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
}
static void testPVScalarArray(
ScalarType scalarType,
String const & valueNameMaster,
String const & valueNameCopy,
string const & valueNameMaster,
string const & valueNameCopy,
PVStructurePtr const & pvMaster,
PVCopyPtr const & pvCopy)
{
@@ -124,7 +118,6 @@ static void testPVScalarArray(
PVScalarArrayPtr pvValueMaster;
PVScalarArrayPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
size_t n = 5;
shared_vector<double> values(n);
@@ -135,14 +128,12 @@ static void testPVScalarArray(
const shared_vector<const double> xxx(freeze(values));
pvValueMaster->putFrom(xxx);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
if(debug) { cout << "structure from copy" << endl << builder << endl;}
if(debug) { cout << "structure from copy" << endl << *structure << endl;}
pvStructureCopy = pvCopy->createPVStructure();
pvValueCopy = pvStructureCopy->getScalarArrayField(valueNameCopy,scalarType);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << "after initCopy pvValueCopy " << builder << endl; }
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;
@@ -153,35 +144,24 @@ static void testPVScalarArray(
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
pvValueCopy->getAs(cvalues);
testOk1(cvalues[0]==0.06);
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << "after put(i+ .06) pvValueCopy " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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(); }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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);
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << "before updateCopyFromBitSet"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
if(debug) { cout << " bitSet " << builder; }
builder.clear();
bitSet->toString(&builder);
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);
@@ -190,13 +170,9 @@ static void testPVScalarArray(
pvValueCopy->getAs(cvalues);
testOk1(cvalues[0]==1.0);
if(debug) { cout << "after updateCopyFromBitSet"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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;
@@ -204,27 +180,19 @@ static void testPVScalarArray(
pvValueMaster->putFrom(ttt);
bitSet->set(0);
if(debug) { cout << "before updateMaster"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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 << "after updateMaster"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
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; }
}
@@ -232,12 +200,12 @@ static void scalarTest()
{
if(debug) { cout << endl << endl << "****scalarTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String valueNameMaster;
String valueNameCopy;
string valueNameMaster;
string valueNameCopy;
StandardPVFieldPtr standardPVField = getStandardPVField();
pvMaster = standardPVField->scalar(pvDouble,"alarm,timeStamp,display");
@@ -272,12 +240,12 @@ static void arrayTest()
{
if(debug) { cout << endl << endl << "****arrayTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String valueNameMaster;
String valueNameCopy;
string valueNameMaster;
string valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
StandardPVFieldPtr standardPVField = getStandardPVField();
@@ -322,7 +290,7 @@ static PVStructurePtr createPowerSupply()
powerSupply.push_back(standardField->alarm());
names.push_back("timeStamp");
powerSupply.push_back(standardField->timeStamp());
String properties("alarm,display");
string properties("alarm,display");
names.push_back("voltage");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("power");
@@ -339,13 +307,13 @@ static void powerSupplyTest()
{
if(debug) { cout << endl << endl << "****powerSupplyTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String builder;
String valueNameMaster;
String valueNameCopy;
string builder;
string valueNameMaster;
string valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvMaster = createPowerSupply();

View File

@@ -12,12 +12,22 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <sstream>
#include <pv/bitSet.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace epics::pvData;
using std::string;
static string toString(BitSet& bitSet)
{
std::ostringstream oss;
oss << bitSet;
return oss.str();
}
static void testGetSetClearFlip()
{
@@ -28,7 +38,7 @@ static void testGetSetClearFlip()
testOk1(b1->isEmpty());
testOk1(b1->cardinality() == 0);
// to string check
std::string str; b1->toString(&str);
string str = toString(*b1);
testOk1(str == "{}");
// one
@@ -37,7 +47,7 @@ static void testGetSetClearFlip()
testOk1(!b1->isEmpty());
testOk1(b1->cardinality() == 1);
// to string check
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3}");
// grow
@@ -45,34 +55,34 @@ static void testGetSetClearFlip()
b1->set(67);
b1->set(68);
testOk1(b1->cardinality() == 4);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 66, 67, 68}");
// clear one
b1->clear(67);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 66, 68}");
// flip
b1->flip(66);
b1->flip(130);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 68, 130}");
// flip
b1->set(130, false);
b1->set(4, true);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 4, 68}");
// clear all
b1->clear();
testOk1(b1->isEmpty());
testOk1(b1->cardinality() == 0);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{}");
delete b1;
@@ -101,11 +111,11 @@ static void testOperators()
b2.set(106);
b2.set(105);
b1 |= b2;
std::string str; b1.toString(&str);
string str = toString(b1);
testOk1(str == "{1, 65, 105, 106}");
b1.clear();
b1 |= b2;
str.clear(); b1.toString(&str);
str = toString(b1);
testOk1(str == "{1, 65, 105, 106}");
// AND test
@@ -134,7 +144,7 @@ static void testOperators()
b2.clear(); b2.set(66); b2.set(128);
BitSet b3; b3.set(128); b3.set(520);
b1.or_and(b2, b3);
str.clear(); b1.toString(&str);
str = toString(b1);
testOk1(str == "{2, 128}");
}

View File

@@ -21,6 +21,7 @@
#include <pv/pvIntrospect.h>
using namespace epics::pvData;
using std::string;
using std::cout;
void testBasicOperations() {
@@ -197,7 +198,7 @@ void testBasicOperations() {
testOk1(buff->getPosition()==6);
testOk1(strncmp(&src[2],&dst[2],6)==0);
cout<<" First 10 characters of destination: >>"<<String(dst, 10)<<"<<\n";
cout<<" First 10 characters of destination: >>"<<string(dst, 10)<<"<<\n";
delete buff;

View File

@@ -21,6 +21,7 @@
#include <epicsAssert.h>
using namespace epics::pvData;
using std::string;
using std::cout;
using std::endl;
@@ -28,8 +29,8 @@ static StandardPVFieldPtr standardPVField = getStandardPVField();
void test()
{
String buffer;
String properties("alarm,timeStamp,display");
string buffer;
string properties("alarm,timeStamp,display");
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,properties);
PVDoublePtr pvValue = pvStructure->getDoubleField("value");
uint32 valueOffset = (uint32) pvValue->getFieldOffset();

View File

@@ -51,6 +51,7 @@
#define DOUBLE_MIN_VALUE std::numeric_limits<double>::min()
using namespace epics::pvData;
using std::string;
namespace {
@@ -135,12 +136,10 @@ void serializationTest(PVFieldPtr const & field) {
testPass("Serialization round trip OK");
else {
testFail("Serialization round trip did not match!");
std::string buf;
field->toString(&buf);
testDiag("Expected: %s", buf.c_str());
buf.clear();
deserializedField->toString(&buf);
testDiag("Found: %s", buf.c_str());
std::ostringstream oss;
oss << "Expected: " << *field << std::endl;
oss << "Found : " << *deserializedField << std::endl;
testDiag("Found: %s", oss.str().c_str());
}
}
@@ -300,7 +299,7 @@ void testScalar() {
serializationTest(pvString);
// huge string test
pvString->put(String(10000, 'a'));
pvString->put(string(10000, 'a'));
serializationTest(pvString);
}
@@ -347,7 +346,7 @@ static const float fdata[] = { (float)0.0, (float)1.1, (float)2.3, (float)-1.4,
FLOAT_MAX_VALUE, FLOAT_MAX_VALUE-(float)123456.789,
FLOAT_MIN_VALUE+(float)1.1, FLOAT_MIN_VALUE };
static const String sdata[] = {
static const string sdata[] = {
"",
"a",
"a b",
@@ -355,7 +354,7 @@ static const String sdata[] = {
"test",
"smile",
"this is a little longer string... maybe a little but longer... this makes test better",
String(10000, 'b')
string(10000, 'b')
};
void testArray() {
@@ -701,10 +700,10 @@ void testIntrospectionSerialization()
}
void testStringCopy() {
String s1 = "abc";
String s2 = s1;
string s1 = "abc";
string s2 = s1;
if (s1.c_str() != s2.c_str())
testDiag("implementation of epics::pvData::String assignment operator does not share content");
testDiag("implementation of string assignment operator does not share content");
}
} // end namespace

View File

@@ -18,6 +18,8 @@
#include "pv/sharedVector.h"
using std::string;
static void testEmpty()
{
testDiag("Test empty vector");
@@ -376,7 +378,7 @@ static void testNonPOD()
{
testDiag("Test vector of non-POD types");
epics::pvData::shared_vector<std::string> strings(6);
epics::pvData::shared_vector<string> strings(6);
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
testOk1(strings[0].empty());
@@ -406,7 +408,7 @@ static void testVectorConvert()
epics::pvData::shared_vector<int> ints(6, 42), moreints;
epics::pvData::shared_vector<float> floats;
epics::pvData::shared_vector<std::string> strings;
epics::pvData::shared_vector<string> strings;
epics::pvData::shared_vector<void> voids;
testOk1(ints.unique());
@@ -435,7 +437,7 @@ static void testVectorConvert()
// convert from void uses shared_vector<void>::original_type()
// to find that the actual type is 'int'.
// returns a new vector
strings = epics::pvData::shared_vector_convert<std::string>(voids);
strings = epics::pvData::shared_vector_convert<string>(voids);
voids.clear();

View File

@@ -27,8 +27,9 @@
#include <pv/timeFunction.h>
using namespace epics::pvData;
using std::string;
static String actionName("action");
static string actionName("action");
class Action;
typedef std::tr1::shared_ptr<Action> ActionPtr;
@@ -101,7 +102,7 @@ private:
typedef std::tr1::shared_ptr<Basic> BasicPtr;
static void testBasic() {
ExecutorPtr executor(new Executor(String("basic"),middlePriority));
ExecutorPtr executor(new Executor(string("basic"),middlePriority));
BasicPtr basic( new Basic(executor));
basic->run();
printf("testBasic PASSED\n");
@@ -130,7 +131,7 @@ typedef std::tr1::shared_ptr<MyFunc> MyFuncPtr;
#ifdef TESTTHREADCONTEXT
static void testThreadContext() {
ExecutorPtr executor(new Executor(String("basic"),middlePriority));
ExecutorPtr executor(new Executor(string("basic"),middlePriority));
BasicPtr basic(new Basic(executor));
MyFuncPtr myFunc(new MyFunc(basic));
TimeFunctionPtr timeFunction(new TimeFunction(myFunc));

View File

@@ -15,6 +15,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <iostream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -25,6 +26,7 @@
#include <pv/thread.h>
using namespace epics::pvData;
using std::string;
static TimeStamp currentTimeStamp;
static double oneDelay = 4.0;
@@ -39,7 +41,7 @@ typedef std::tr1::shared_ptr<MyCallback> MyCallbackPtr;
class MyCallback : public TimerCallback {
public:
POINTER_DEFINITIONS(MyCallback);
MyCallback(String name,EventPtr const & wait)
MyCallback(string name,EventPtr const & wait)
: name(name),
wait(wait)
{
@@ -58,7 +60,7 @@ public:
}
TimeStamp &getTimeStamp() { return timeStamp;}
private:
String name;
string name;
EventPtr wait;
TimeStamp timeStamp;
};
@@ -69,13 +71,13 @@ static void testBasic()
printf("\n\ntestBasic oneDelay %lf twoDelay %lf threeDaley %lf\n",
oneDelay,twoDelay,threeDelay);
}
String one("one");
String two("two");
String three("three");
string one("one");
string two("two");
string three("three");
EventPtr eventOne(new Event());
EventPtr eventTwo(new Event());
EventPtr eventThree(new Event());
TimerPtr timer(new Timer(String("timer"),middlePriority));
TimerPtr timer(new Timer(string("timer"),middlePriority));
MyCallbackPtr callbackOne(new MyCallback(one,eventOne));
MyCallbackPtr callbackTwo(new MyCallback(two,eventTwo));
MyCallbackPtr callbackThree(new MyCallback(three,eventThree));
@@ -91,9 +93,8 @@ static void testBasic()
if(twoDelay>.1) testOk1(timer->isScheduled(callbackTwo));
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
if(debug) {
String builder;
timer->toString(&builder);
printf("timerQueue\n%s",builder.c_str());
std::cout << "timerQueue" << std::endl;
std::cout << *timer;
}
eventOne->wait();
eventTwo->wait();
@@ -137,13 +138,13 @@ static void testCancel()
printf("\n\ntestCancel oneDelay %lf twoDelay %lf threeDaley %lf\n",
oneDelay,twoDelay,threeDelay);
}
String one("one");
String two("two");
String three("three");
string one("one");
string two("two");
string three("three");
EventPtr eventOne(new Event());
EventPtr eventTwo(new Event());
EventPtr eventThree(new Event());
TimerPtr timer(new Timer(String("timer"),middlePriority));
TimerPtr timer(new Timer(string("timer"),middlePriority));
MyCallbackPtr callbackOne(new MyCallback(one,eventOne));
MyCallbackPtr callbackTwo(new MyCallback(two,eventTwo));
MyCallbackPtr callbackThree(new MyCallback(three,eventThree));
@@ -160,9 +161,8 @@ static void testCancel()
testOk1(!timer->isScheduled(callbackTwo));
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
if(debug) {
String builder;
timer->toString(&builder);
printf("timerQueue\n%s",builder.c_str());
std::cout << "timerQueue" << std::endl;
std::cout << *timer;
}
eventOne->wait();
eventThree->wait();

View File

@@ -27,7 +27,7 @@
#include "pv/typeCast.h"
using epics::pvData::String;
using std::string;
namespace {
@@ -131,11 +131,11 @@ try {
uint64_t xuint64=0;
float xfloat=0.0;
double xdouble=0.0;
epics::pvData::String xString("0");
string xstring("0");
typedef float float_t;
typedef double double_t;
typedef epics::pvData::String String_t;
typedef string string_t;
// force all possibilities to be compiled
#define CHECK(M, N) x## M = ::epics::pvData::castUnsafe<M ##_t>(x## N); \
@@ -151,7 +151,7 @@ try {
CHECK(int8, uint64);
CHECK(int8, float);
CHECK(int8, double);
CHECK(int8, String);
CHECK(int8, string);
CHECK(uint8, int8);
CHECK(uint8, uint8);
@@ -163,7 +163,7 @@ try {
CHECK(uint8, uint64);
CHECK(uint8, float);
CHECK(uint8, double);
CHECK(uint8, String);
CHECK(uint8, string);
CHECK(int16, int8);
CHECK(int16, uint8);
@@ -175,7 +175,7 @@ try {
CHECK(int16, uint64);
CHECK(int16, float);
CHECK(int16, double);
CHECK(int16, String);
CHECK(int16, string);
CHECK(uint16, int8);
CHECK(uint16, uint8);
@@ -187,7 +187,7 @@ try {
CHECK(uint16, uint64);
CHECK(uint16, float);
CHECK(uint16, double);
CHECK(uint16, String);
CHECK(uint16, string);
CHECK(int32, int8);
CHECK(int32, uint8);
@@ -199,7 +199,7 @@ try {
CHECK(int32, uint64);
CHECK(int32, float);
CHECK(int32, double);
CHECK(int32, String);
CHECK(int32, string);
CHECK(uint32, int8);
CHECK(uint32, uint8);
@@ -211,7 +211,7 @@ try {
CHECK(uint32, uint64);
CHECK(uint32, float);
CHECK(uint32, double);
CHECK(uint32, String);
CHECK(uint32, string);
CHECK(int64, int8);
CHECK(int64, uint8);
@@ -223,7 +223,7 @@ try {
CHECK(int64, uint64);
CHECK(int64, float);
CHECK(int64, double);
//CHECK(int64, String);
//CHECK(int64, string);
CHECK(uint64, int8);
CHECK(uint64, uint8);
@@ -235,7 +235,7 @@ try {
CHECK(uint64, uint64);
CHECK(uint64, float);
CHECK(uint64, double);
//CHECK(uint64, String);
//CHECK(uint64, string);
CHECK(float, int8);
CHECK(float, uint8);
@@ -247,7 +247,7 @@ try {
CHECK(float, uint64);
CHECK(float, float);
CHECK(float, double);
CHECK(float, String);
CHECK(float, string);
CHECK(double, int8);
CHECK(double, uint8);
@@ -259,19 +259,19 @@ try {
CHECK(double, uint64);
CHECK(double, float);
CHECK(double, double);
CHECK(double, String);
CHECK(double, string);
CHECK(String, int8);
CHECK(String, uint8);
CHECK(String, int16);
CHECK(String, uint16);
CHECK(String, int32);
CHECK(String, uint32);
CHECK(String, int64);
CHECK(String, uint64);
CHECK(String, float);
CHECK(String, double);
CHECK(String, String);
CHECK(string, int8);
CHECK(string, uint8);
CHECK(string, int16);
CHECK(string, uint16);
CHECK(string, int32);
CHECK(string, uint32);
CHECK(string, int64);
CHECK(string, uint64);
CHECK(string, float);
CHECK(string, double);
CHECK(string, string);
#undef CHECK
testDiag("Integer signed <=> unsigned");
@@ -309,91 +309,91 @@ try {
TEST(int32_t, -2, float, -2.5f);
TEST(int32_t, -2, float, -2.7f);
testDiag("String Printing/parsing");
testDiag("string Printing/parsing");
TEST2(String, "1", int32_t, 1);
TEST2(String, "-1", int32_t, -1);
TEST2(String, "1", int8_t, 1);
TEST2(String, "-1", int8_t, -1);
TEST2(String, "1", uint8_t, 1);
TEST2(string, "1", int32_t, 1);
TEST2(string, "-1", int32_t, -1);
TEST2(string, "1", int8_t, 1);
TEST2(string, "-1", int8_t, -1);
TEST2(string, "1", uint8_t, 1);
TEST2(String, "127", int32_t, std::numeric_limits<int8_t>::max());
TEST2(String, "-128", int32_t, std::numeric_limits<int8_t>::min());
TEST2(String, "255", int32_t, std::numeric_limits<uint8_t>::max());
TEST2(string, "127", int32_t, std::numeric_limits<int8_t>::max());
TEST2(string, "-128", int32_t, std::numeric_limits<int8_t>::min());
TEST2(string, "255", int32_t, std::numeric_limits<uint8_t>::max());
TEST2(String, "32767", int32_t, std::numeric_limits<int16_t>::max());
TEST2(String, "-32768", int32_t, std::numeric_limits<int16_t>::min());
TEST2(String, "65535", int32_t, std::numeric_limits<uint16_t>::max());
TEST2(string, "32767", int32_t, std::numeric_limits<int16_t>::max());
TEST2(string, "-32768", int32_t, std::numeric_limits<int16_t>::min());
TEST2(string, "65535", int32_t, std::numeric_limits<uint16_t>::max());
TEST2(String, "2147483647", int32_t, std::numeric_limits<int32_t>::max());
TEST2(String, "-2147483648", int32_t, std::numeric_limits<int32_t>::min());
TEST2(String, "4294967295", uint32_t, std::numeric_limits<uint32_t>::max());
TEST2(string, "2147483647", int32_t, std::numeric_limits<int32_t>::max());
TEST2(string, "-2147483648", int32_t, std::numeric_limits<int32_t>::min());
TEST2(string, "4294967295", uint32_t, std::numeric_limits<uint32_t>::max());
TEST2(String, "9223372036854775807", int64_t, std::numeric_limits<int64_t>::max());
TEST2(String, "-9223372036854775808", int64_t, std::numeric_limits<int64_t>::min());
TEST2(String, "18446744073709551615", uint64_t, std::numeric_limits<uint64_t>::max());
TEST2(string, "9223372036854775807", int64_t, std::numeric_limits<int64_t>::max());
TEST2(string, "-9223372036854775808", int64_t, std::numeric_limits<int64_t>::min());
TEST2(string, "18446744073709551615", uint64_t, std::numeric_limits<uint64_t>::max());
TEST2(String, "1.1", double, 1.1);
TEST2(String, "1.1e+100", double, 1.1e100);
TEST2(String, "1.1e-100", double, 1.1e-100);
TEST2(string, "1.1", double, 1.1);
TEST2(string, "1.1e+100", double, 1.1e100);
TEST2(string, "1.1e-100", double, 1.1e-100);
TEST(double, 1.1e100, String, "1.1E+100");
TEST(double, 1.1e100, string, "1.1E+100");
// any non-zero value is true
TEST(String, "true", epics::pvData::boolean, 100);
TEST(string, "true", epics::pvData::boolean, 100);
TEST2(String, "true", epics::pvData::boolean, 1);
TEST2(String, "false", epics::pvData::boolean, 0);
TEST2(string, "true", epics::pvData::boolean, 1);
TEST2(string, "false", epics::pvData::boolean, 0);
// Case insensitive
TEST(epics::pvData::boolean, 1, String, "True");
TEST(epics::pvData::boolean, 0, String, "False");
TEST(epics::pvData::boolean, 1, String, "TRUE");
TEST(epics::pvData::boolean, 0, String, "FALSE");
TEST(epics::pvData::boolean, 1, string, "True");
TEST(epics::pvData::boolean, 0, string, "False");
TEST(epics::pvData::boolean, 1, string, "TRUE");
TEST(epics::pvData::boolean, 0, string, "FALSE");
testDiag("String Parsing");
testDiag("string Parsing");
TEST(int32_t, 15, String, "0xf");
TEST(int32_t, 15, String, "0xF");
TEST(int32_t, -15, String, "-0xF");
TEST(int32_t, 16, String, "0x10");
TEST(int32_t, -16, String, "-0x10");
TEST(int32_t, 15, string, "0xf");
TEST(int32_t, 15, string, "0xF");
TEST(int32_t, -15, string, "-0xF");
TEST(int32_t, 16, string, "0x10");
TEST(int32_t, -16, string, "-0x10");
TEST(int32_t, 7, String, "07");
TEST(int32_t, 8, String, "010");
TEST(int32_t, -7, String, "-07");
TEST(int32_t, -8, String, "-010");
TEST(int32_t, 7, string, "07");
TEST(int32_t, 8, string, "010");
TEST(int32_t, -7, string, "-07");
TEST(int32_t, -8, string, "-010");
TEST(int64_t, 15, String, "0xf");
TEST(int64_t, 15, String, "0xF");
TEST(int64_t, -15, String, "-0xF");
TEST(int64_t, 16, String, "0x10");
TEST(int64_t, -16, String, "-0x10");
TEST(int64_t, 15, string, "0xf");
TEST(int64_t, 15, string, "0xF");
TEST(int64_t, -15, string, "-0xF");
TEST(int64_t, 16, string, "0x10");
TEST(int64_t, -16, string, "-0x10");
TEST(int64_t, 7, String, "07");
TEST(int64_t, 8, String, "010");
TEST(int64_t, -7, String, "-07");
TEST(int64_t, -8, String, "-010");
TEST(int64_t, 7, string, "07");
TEST(int64_t, 8, string, "010");
TEST(int64_t, -7, string, "-07");
TEST(int64_t, -8, string, "-010");
testDiag("String parsing errors");
testDiag("string parsing errors");
FAIL(int32_t, String, "hello!");
FAIL(int32_t, String, "42 is the answer");
FAIL(int64_t, String, "hello!");
FAIL(int64_t, String, "42 is the answer");
FAIL(double, String, "hello!");
FAIL(double, String, "42 is the answer");
FAIL(int32_t, string, "hello!");
FAIL(int32_t, string, "42 is the answer");
FAIL(int64_t, string, "hello!");
FAIL(int64_t, string, "42 is the answer");
FAIL(double, string, "hello!");
FAIL(double, string, "42 is the answer");
FAIL(int8_t, String, "1000");
FAIL(int8_t, String, "-1000");
FAIL(int8_t, string, "1000");
FAIL(int8_t, string, "-1000");
FAIL(double, String, "1e+10000000");
FAIL(double, string, "1e+10000000");
FAIL(epics::pvData::boolean, String, "hello");
FAIL(epics::pvData::boolean, String, "1");
FAIL(epics::pvData::boolean, String, "0");
FAIL(epics::pvData::boolean, String, "T");
FAIL(epics::pvData::boolean, String, "F");
FAIL(epics::pvData::boolean, string, "hello");
FAIL(epics::pvData::boolean, string, "1");
FAIL(epics::pvData::boolean, string, "0");
FAIL(epics::pvData::boolean, string, "T");
FAIL(epics::pvData::boolean, string, "F");
testDiag("Floating point overflows");
@@ -406,10 +406,10 @@ try {
testOk(isnan( xfloat ), "Test cast double NAN to float NAN yields: %f", xfloat);
{
std::string result[3];
string result[3];
const int32_t in[3] = { 1234, 506001, 42424242 };
testDiag("Test vcast int32 -> String");
testDiag("Test vcast int32 -> string");
epics::pvData::castUnsafeV(3, epics::pvData::pvString, (void*)result,
epics::pvData::pvInt, (void*)in);
testDiag("Yields %s %s %s", result[0].c_str(), result[1].c_str(), result[2].c_str());

View File

@@ -33,6 +33,7 @@
#include <pv/pvTimeStamp.h>
using namespace epics::pvData;
using std::string;
static bool debug = false;
@@ -41,9 +42,8 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder;
static String alarmTimeStamp("alarm,timeStamp");
static String allProperties("alarm,timeStamp,display,control");
static string alarmTimeStamp("alarm,timeStamp");
static string allProperties("alarm,timeStamp,display,control");
static PVStructurePtr doubleRecord;
static PVStructurePtr enumeratedRecord;
@@ -51,11 +51,8 @@ static PVStructurePtr enumeratedRecord;
static void createRecords()
{
doubleRecord = standardPVField->scalar(pvDouble,allProperties);
if(debug) {
builder.clear();
doubleRecord->toString(&builder);
printf("doubleRecord\n%s\n",builder.c_str());
}
if(debug)
std::cout << "doubleRecord" << std::endl << *doubleRecord << std::endl;
StringArray choices;
choices.reserve(4);
choices.push_back("1");
@@ -63,23 +60,14 @@ static void createRecords()
choices.push_back("3");
choices.push_back("4");
enumeratedRecord = standardPVField->enumerated(choices,alarmTimeStamp);
if(debug) {
builder.clear();
enumeratedRecord->toString(&builder);
printf("enumeratedRecord\n%s\n",builder.c_str());
}
if(debug)
std::cout << "enumeratedRecord" << std::endl << *doubleRecord << std::endl;
}
static void printRecords()
{
printf("doubleRecord\n");
builder.clear();
doubleRecord->toString(&builder);
printf("%s\n",builder.c_str());
printf("enumeratedRecord\n");
builder.clear();
enumeratedRecord->toString(&builder);
printf("%s\n",builder.c_str());
std::cout << "doubleRecord" << std::endl << *doubleRecord << std::endl;
std::cout << "enumeratedRecord" << std::endl << *doubleRecord << std::endl;
}
static void testAlarm()
@@ -88,7 +76,7 @@ static void testAlarm()
Alarm alarm;
PVAlarm pvAlarm;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("alarm"));
PVFieldPtr pvField = doubleRecord->getSubField(string("alarm"));
if(pvField.get()==NULL) {
printf("testAlarm ERROR did not find field alarm\n");
return;
@@ -96,7 +84,7 @@ static void testAlarm()
result = pvAlarm.attach(pvField);
testOk1(result);
Alarm al;
al.setMessage(String("testMessage"));
al.setMessage(string("testMessage"));
al.setSeverity(majorAlarm);
al.setStatus(clientStatus);
result = pvAlarm.set(al);
@@ -105,9 +93,9 @@ static void testAlarm()
testOk1(al.getMessage().compare(alarm.getMessage())==0);
testOk1(al.getSeverity()==alarm.getSeverity());
testOk1(al.getStatus()==alarm.getStatus());
String message = alarm.getMessage();
String severity = (*AlarmSeverityFunc::getSeverityNames())[alarm.getSeverity()];
String status = (*AlarmStatusFunc::getStatusNames())[alarm.getStatus()];
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());
@@ -121,7 +109,7 @@ static void testTimeStamp()
TimeStamp timeStamp;
PVTimeStamp pvTimeStamp;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("timeStamp"));
PVFieldPtr pvField = doubleRecord->getSubField(string("timeStamp"));
if(pvField.get()==NULL) {
printf("testTimeStamp ERROR did not find field timeStamp\n");
return;
@@ -161,7 +149,7 @@ static void testControl()
Control control;
PVControl pvControl;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("control"));
PVFieldPtr pvField = doubleRecord->getSubField(string("control"));
if(pvField.get()==NULL) {
printf("testControl ERROR did not find field control\n");
return;
@@ -188,7 +176,7 @@ static void testDisplay()
Display display;
PVDisplay pvDisplay;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("display"));
PVFieldPtr pvField = doubleRecord->getSubField(string("display"));
if(pvField.get()==NULL) {
printf("testDisplay ERROR did not find field display\n");
return;
@@ -198,9 +186,9 @@ static void testDisplay()
Display dy;
dy.setLow(-10.0);
dy.setHigh(-1.0);
dy.setDescription(String("testDescription"));
dy.setFormat(String("%f10.0"));
dy.setUnits(String("volts"));
dy.setDescription(string("testDescription"));
dy.setFormat(string("%f10.0"));
dy.setUnits(string("volts"));
result = pvDisplay.set(dy);
testOk1(result);
pvDisplay.get(display);
@@ -220,7 +208,7 @@ static void testEnumerated()
if(debug) printf("testEnumerated\n");
PVEnumerated pvEnumerated;
bool result;
PVFieldPtr pvField = enumeratedRecord->getSubField(String("value"));
PVFieldPtr pvField = enumeratedRecord->getSubField(string("value"));
if(pvField.get()==NULL) {
printf("testEnumerated ERROR did not find field enumerated\n");
return;
@@ -228,7 +216,7 @@ static void testEnumerated()
result = pvEnumerated.attach(pvField);
testOk1(result);
int32 index = pvEnumerated.getIndex();
String choice = pvEnumerated.getChoice();
string choice = pvEnumerated.getChoice();
PVStringArray::const_svector choices = pvEnumerated.getChoices();
int32 numChoices = pvEnumerated.getNumberChoices();
if(debug) {

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -22,6 +23,7 @@
#include <pv/standardPVField.h>
using namespace epics::pvData;
using std::string;
using std::tr1::static_pointer_cast;
static bool debug = false;
@@ -31,10 +33,11 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder("");
static void test()
{
std::ostringstream oss;
if(debug) printf("\ntestBitSetUtil\n");
StringArray fieldNames;
PVFieldPtrArray pvFields;
@@ -60,19 +63,28 @@ static void test()
standardField->scalar(pvDouble,"alarm")));
PVStructurePtr pvs = pvDataCreate->createPVStructure(
fieldNames,pvFields);
builder.clear();
pvs->toString(&builder);
if(debug) printf("pvs\n%s\n",builder.c_str());
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);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
bitSet->clear();
PVFieldPtr pvField = pvs->getSubField("timeStamp");
int32 offsetTimeStamp = (int32)pvField->getFieldOffset();
@@ -87,15 +99,21 @@ static void test()
testOk1(bitSet->get(offsetSeconds)==true);
bitSet->set(offsetNano);
bitSet->set(offsetUserTag);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
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);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
bitSet->clear();
pvField = pvs->getSubField("current");
@@ -114,25 +132,37 @@ static void test()
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
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);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
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");

View File

@@ -31,7 +31,7 @@ void test_structure()
FieldBuilderPtr fb = fieldCreate->createFieldBuilder();
// test with simple (non-nested) structure
std::string ID = "testStructureID";
string ID = "testStructureID";
StructureConstPtr s = fb->setId(ID)->
add("double", pvDouble)->
addArray("intArray", pvInt)->
@@ -116,7 +116,7 @@ void test_nestedStructure()
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
addNestedStructure("nested")->
@@ -172,7 +172,7 @@ void test_nestedStructureArray()
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
addNestedStructureArray("nested")->

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -21,6 +22,7 @@
#include <pv/standardField.h>
using namespace epics::pvData;
using std::string;
static FieldCreatePtr fieldCreate;
static PVDataCreatePtr pvDataCreate;
@@ -29,13 +31,14 @@ static StandardFieldPtr standardField;
static void testScalarCommon(ScalarType stype,
bool isInteger,bool isNumeric,bool isPrimitive)
{
String builder;
ScalarConstPtr pscalar = fieldCreate->createScalar(stype);
Type type = pscalar->getType();
testOk1(type==scalar);
builder.clear();
TypeFunc::toString(&builder,type);
testOk1(builder.compare("scalar")==0);
std::ostringstream oss;
oss << type;
testOk1(oss.str().compare("scalar")==0);
ScalarType scalarType = pscalar->getScalarType();
testOk1(scalarType==stype);
testOk1(ScalarTypeFunc::isInteger(scalarType)==isInteger);
@@ -58,13 +61,14 @@ static void testScalar() {
static void testScalarArrayCommon(ScalarType stype,
bool isInteger,bool isNumeric,bool isPrimitive)
{
String builder;
ScalarArrayConstPtr pscalar = fieldCreate->createScalarArray(stype);
Type type = pscalar->getType();
testOk1(type==scalarArray);
builder.clear();
TypeFunc::toString(&builder,type);
testOk1(builder.compare("scalarArray")==0);
std::ostringstream oss;
oss << type;
testOk1(oss.str().compare("scalarArray")==0);
ScalarType scalarType = pscalar->getElementType();
testOk1(scalarType==stype);
testOk1(ScalarTypeFunc::isInteger(scalarType)==isInteger);
@@ -246,7 +250,7 @@ static void testMapping()
OP(uint64, pvULong)
OP(float, pvFloat)
OP(double, pvDouble)
OP(String, pvString)
OP(string, pvString)
#undef OP
testOk1((ScalarType)ScalarTypeID<PVField>::value==(ScalarType)-1);

View File

@@ -11,11 +11,13 @@
#include <pv/pvData.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/status.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace epics::pvData;
using std::string;
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardFieldPtr standardField = getStandardField();
@@ -37,12 +39,12 @@ MAIN(testOperators)
testOk1(testDV == dv);
const std::string testSV = "test message";
const string testSV = "test message";
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
*pvMessage <<= testSV;
std::string sv;
string sv;
*pvMessage >>= sv;
testOk1(testSV == sv);
@@ -54,6 +56,10 @@ MAIN(testOperators)
std::cout << *pvMessage << std::endl;
std::cout << *pvStructure << std::endl;
std::cout << *pvStructure->getStructure() << std::endl;
std::cout << Status::Ok << std::endl;
std::cout << Status::STATUSTYPE_OK << std::endl;
StringArray choices;
choices.reserve(3);

View File

@@ -24,6 +24,7 @@
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::string;
using std::cout;
using std::endl;
@@ -34,14 +35,14 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder("");
static String alarmTimeStamp("alarm,timeStamp");
static String alarmTimeStampValueAlarm("alarm,timeStamp,valueAlarm");
static String allProperties("alarm,timeStamp,display,control,valueAlarm");
static string alarmTimeStamp("alarm,timeStamp");
static string alarmTimeStampValueAlarm("alarm,timeStamp,valueAlarm");
static string allProperties("alarm,timeStamp,display,control,valueAlarm");
static void testCreatePVStructure()
{
if(debug) printf("\ntestCreatePVStructure\n");
if(debug)
std::cout << std::endl << "testCreatePVStructure" << std::endl;
PVStructurePtr pv0 = standardPVField->scalar(
pvDouble,alarmTimeStampValueAlarm);
PVScalarPtr pv1 = pvDataCreate->createPVScalar(pvString);
@@ -55,27 +56,27 @@ static void testCreatePVStructure()
pvFields.push_back(pv1);
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
fieldNames,pvFields);
builder.clear();
pvParent->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
printf("testCreatePVStructure PASSED\n");
if(debug)
std::cout << *pvParent << std::endl;
std::cout << "testCreatePVStructure PASSED" << std::endl;
}
static void testPVScalarCommon(String /*fieldName*/,ScalarType stype)
static void testPVScalarCommon(string /*fieldName*/,ScalarType stype)
{
PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype);
if(stype==pvBoolean) {
convert->fromString(pvScalar,String("true"));
convert->fromString(pvScalar,string("true"));
} else {
convert->fromString(pvScalar,String("10"));
convert->fromString(pvScalar,string("10"));
}
builder.clear();
pvScalar->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvScalar << std::endl;
}
static void testPVScalarWithProperties(
String /*fieldName*/,ScalarType stype)
string /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure;
bool hasValueAlarm = false;
@@ -190,137 +191,138 @@ static void testPVScalarWithProperties(
pvStructure = standardPVField->scalar(
stype,alarmTimeStamp);
PVStringPtr pvField = pvStructure->getStringField("value");
pvField->put(String("this is a string"));
pvField->put(string("this is a string"));
break;
}
}
PVLongPtr seconds = pvStructure->getLongField(
String("timeStamp.secondsPastEpoch"));
string("timeStamp.secondsPastEpoch"));
testOk1(seconds!=0);
seconds->put(123456789);
PVIntPtr nano = pvStructure->getIntField(String("timeStamp.nanoSeconds"));
PVIntPtr nano = pvStructure->getIntField(string("timeStamp.nanoSeconds"));
testOk1(nano!=0);
nano->put(1000000);
PVIntPtr severity = pvStructure->getIntField(String("alarm.severity"));
PVIntPtr severity = pvStructure->getIntField(string("alarm.severity"));
testOk1(severity!=0);
severity->put(2);
PVStringPtr message = pvStructure->getStringField(String("alarm.message"));
PVStringPtr message = pvStructure->getStringField(string("alarm.message"));
testOk1(message!=0);
message->put(String("messageForAlarm"));
message->put(string("messageForAlarm"));
if(hasDisplayControl) {
PVStringPtr desc = pvStructure->getStringField(
String("display.description"));
string("display.description"));
testOk1(desc!=0);
desc->put(String("this is a description"));
desc->put(string("this is a description"));
PVStringPtr format = pvStructure->getStringField(
String("display.format"));
string("display.format"));
testOk1(format!=0);
format->put(String("f10.2"));
format->put(string("f10.2"));
PVStringPtr units = pvStructure->getStringField(
String("display.units"));
string("display.units"));
testOk1(units!=0);
units->put(String("SomeUnits"));
units->put(string("SomeUnits"));
PVDoublePtr limit = pvStructure->getDoubleField(
String("display.limitLow"));
string("display.limitLow"));
testOk1(limit!=0);
limit->put(0.0);
limit = pvStructure->getDoubleField(
String("display.limitHigh"));
string("display.limitHigh"));
testOk1(limit!=0);
limit->put(10.0);
limit = pvStructure->getDoubleField(
String("control.limitLow"));
string("control.limitLow"));
testOk1(limit!=0);
limit->put(1.0);
limit = pvStructure->getDoubleField(
String("control.limitHigh"));
string("control.limitHigh"));
testOk1(limit!=0);
limit->put(9.0);
}
if(hasValueAlarm) {
PVFieldPtr pvField = pvStructure->getSubField(
String("valueAlarm.active"));
string("valueAlarm.active"));
PVBooleanPtr pvBoolean = static_pointer_cast<PVBoolean>(pvField);
pvBoolean->put(true);
pvField = pvStructure->getSubField(
String("valueAlarm.lowAlarmLimit"));
string("valueAlarm.lowAlarmLimit"));
PVScalarPtr pvtemp = static_pointer_cast<PVScalar>(pvField);
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,1.0);
pvField = pvStructure->getSubField(
String("valueAlarm.highAlarmLimit"));
string("valueAlarm.highAlarmLimit"));
pvtemp = static_pointer_cast<PVScalar>(pvField);
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,9.0);
severity = pvStructure->getIntField(
String("valueAlarm.lowAlarmSeverity"));
string("valueAlarm.lowAlarmSeverity"));
testOk1(severity!=0);
severity->put(2);
severity = pvStructure->getIntField(
String("valueAlarm.highAlarmSeverity"));
string("valueAlarm.highAlarmSeverity"));
testOk1(severity!=0);
severity->put(2);
PVBooleanPtr active = pvStructure->getBooleanField(
String("valueAlarm.active"));
string("valueAlarm.active"));
testOk1(active!=0);
active->put(true);
}
if(hasBooleanAlarm) {
PVFieldPtr pvField = pvStructure->getSubField(
String("valueAlarm.active"));
string("valueAlarm.active"));
PVBooleanPtr pvBoolean = static_pointer_cast<PVBoolean>(pvField);
pvBoolean->put(true);
severity = pvStructure->getIntField(
String("valueAlarm.falseSeverity"));
string("valueAlarm.falseSeverity"));
testOk1(severity!=0);
severity->put(0);
severity = pvStructure->getIntField(
String("valueAlarm.trueSeverity"));
string("valueAlarm.trueSeverity"));
testOk1(severity!=0);
severity->put(2);
severity = pvStructure->getIntField(
String("valueAlarm.changeStateSeverity"));
string("valueAlarm.changeStateSeverity"));
testOk1(severity!=0);
severity->put(1);
}
builder.clear();
pvStructure->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvStructure << std::endl;
}
static void testPVScalar()
{
if(debug) printf("\ntestScalar\n");
testPVScalarCommon(String("boolean"),pvByte);
testPVScalarCommon(String("byte"),pvByte);
testPVScalarCommon(String("short"),pvShort);
testPVScalarCommon(String("int"),pvInt);
testPVScalarCommon(String("long"),pvLong);
testPVScalarCommon(String("ubyte"),pvUByte);
testPVScalarCommon(String("ushort"),pvUShort);
testPVScalarCommon(String("uint"),pvUInt);
testPVScalarCommon(String("ulong"),pvULong);
testPVScalarCommon(String("float"),pvFloat);
testPVScalarCommon(String("double"),pvDouble);
testPVScalarCommon(String("string"),pvString);
if(debug)
std::cout << std::endl << "testScalar" << std::endl;
testPVScalarCommon(string("boolean"),pvByte);
testPVScalarCommon(string("byte"),pvByte);
testPVScalarCommon(string("short"),pvShort);
testPVScalarCommon(string("int"),pvInt);
testPVScalarCommon(string("long"),pvLong);
testPVScalarCommon(string("ubyte"),pvUByte);
testPVScalarCommon(string("ushort"),pvUShort);
testPVScalarCommon(string("uint"),pvUInt);
testPVScalarCommon(string("ulong"),pvULong);
testPVScalarCommon(string("float"),pvFloat);
testPVScalarCommon(string("double"),pvDouble);
testPVScalarCommon(string("string"),pvString);
testPVScalarWithProperties(String("boolean"),pvBoolean);
testPVScalarWithProperties(String("byte"),pvByte);
testPVScalarWithProperties(String("short"),pvShort);
testPVScalarWithProperties(String("int"),pvInt);
testPVScalarWithProperties(String("long"),pvLong);
testPVScalarWithProperties(String("ubyte"),pvUByte);
testPVScalarWithProperties(String("ushort"),pvUShort);
testPVScalarWithProperties(String("uint"),pvUInt);
testPVScalarWithProperties(String("ulong"),pvULong);
testPVScalarWithProperties(String("float"),pvFloat);
testPVScalarWithProperties(String("double"),pvDouble);
testPVScalarWithProperties(String("string"),pvString);
printf("testScalar PASSED\n");
testPVScalarWithProperties(string("boolean"),pvBoolean);
testPVScalarWithProperties(string("byte"),pvByte);
testPVScalarWithProperties(string("short"),pvShort);
testPVScalarWithProperties(string("int"),pvInt);
testPVScalarWithProperties(string("long"),pvLong);
testPVScalarWithProperties(string("ubyte"),pvUByte);
testPVScalarWithProperties(string("ushort"),pvUShort);
testPVScalarWithProperties(string("uint"),pvUInt);
testPVScalarWithProperties(string("ulong"),pvULong);
testPVScalarWithProperties(string("float"),pvFloat);
testPVScalarWithProperties(string("double"),pvDouble);
testPVScalarWithProperties(string("string"),pvString);
std::cout << "testPVScalar PASSED" << std::endl;
}
static void testScalarArrayCommon(String /*fieldName*/,ScalarType stype)
static void testScalarArrayCommon(string /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure = standardPVField->scalarArray(
stype,alarmTimeStamp);
@@ -340,30 +342,32 @@ static void testScalarArrayCommon(String /*fieldName*/,ScalarType stype)
values[2] = "2";
convert->fromStringArray(scalarArray, 0,3,values,0);
}
builder.clear();
pvStructure->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvStructure << std::endl;
PVFieldPtr pvField = pvStructure->getSubField("alarm.status");
testOk1(pvField!=NULL);
}
static void testScalarArray()
{
if(debug) printf("\ntestScalarArray\n");
testScalarArrayCommon(String("boolean"),pvBoolean);
testScalarArrayCommon(String("byte"),pvByte);
testScalarArrayCommon(String("short"),pvShort);
testScalarArrayCommon(String("int"),pvInt);
testScalarArrayCommon(String("long"),pvLong);
testScalarArrayCommon(String("float"),pvFloat);
testScalarArrayCommon(String("double"),pvDouble);
testScalarArrayCommon(String("string"),pvString);
printf("testScalarArray PASSED\n");
if(debug)
std::cout << std::endl << "testScalarArray" << std::endl;
testScalarArrayCommon(string("boolean"),pvBoolean);
testScalarArrayCommon(string("byte"),pvByte);
testScalarArrayCommon(string("short"),pvShort);
testScalarArrayCommon(string("int"),pvInt);
testScalarArrayCommon(string("long"),pvLong);
testScalarArrayCommon(string("float"),pvFloat);
testScalarArrayCommon(string("double"),pvDouble);
testScalarArrayCommon(string("string"),pvString);
std::cout << "testScalarArray PASSED" << std::endl;
}
static void testRequest()
{
if(debug) printf("\ntestScalarArray\n");
if(debug)
std::cout << std::endl << "testScalarArray" << std::endl;
StringArray nullNames;
FieldConstPtrArray nullFields;
StringArray optionNames(1);
@@ -388,35 +392,22 @@ static void testRequest()
topFields[1] = fieldCreate->createStructure(fieldNames,fieldFields);
StructureConstPtr topStructure = fieldCreate->createStructure(
topNames,topFields);
String buffer;
topStructure->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *topStructure << endl;
PVStructurePtr pvTop = pvDataCreate->createPVStructure(topStructure);
buffer.clear();
pvTop->toString(&buffer);
cout << buffer.c_str() << endl;
buffer.clear();
pvTop->getStructure()->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *pvTop << endl;
cout << *pvTop->getStructure() << endl;
PVStructurePtr xxx = pvTop->getSubField<PVStructure>("record");
buffer.clear();
xxx->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *xxx << endl;
xxx = pvTop->getSubField<PVStructure>("field");
buffer.clear();
xxx->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *xxx << endl;
PVStringPtr pvString = pvTop->getSubField<PVString>("record._options.process");
pvString->put("true");
buffer.clear();
pvTop->toString(&buffer);
cout << buffer.c_str() << endl;
cout << pvTop->dumpValue(cout) << endl;
cout << *pvTop << endl;
String subName("record._options.process");
string subName("record._options.process");
PVFieldPtr pvField = pvTop->getSubField(subName);
String fieldName = pvField->getFieldName();
String fullName = pvField->getFullName();
string fieldName = pvField->getFieldName();
string fullName = pvField->getFullName();
cout << "fieldName " << fieldName << " fullName " << fullName << endl;
testOk1(fieldName.compare("process")==0);

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -23,16 +24,18 @@
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 String builder("");
static void print(String name)
static void print(const string& name, FieldConstPtr const & f)
{
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
if(debug) {
std::cout << std::endl << name << std::endl << *f << std::endl;
}
}
MAIN(testStandardField)
@@ -40,19 +43,13 @@ MAIN(testStandardField)
testPlan(1);
StructureConstPtr doubleValue = standardField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");
builder.clear();
doubleValue->toString(&builder);
print("doubleValue");
print("doubleValue", doubleValue);
StructureConstPtr stringArrayValue = standardField->scalarArray(pvString,
"alarm,timeStamp");
builder.clear();
stringArrayValue->toString(&builder);
print("stringArrayValue");
print("stringArrayValue", stringArrayValue);
StructureConstPtr enumeratedValue = standardField->enumerated(
"alarm,timeStamp,valueAlarm");
builder.clear();
enumeratedValue->toString(&builder);
print("enumeratedValue");
print("enumeratedValue", enumeratedValue);
FieldConstPtrArray fields;
fields.reserve(2);
fields.push_back(fieldCreate->createScalar(pvDouble));
@@ -63,9 +60,7 @@ MAIN(testStandardField)
fieldNames.push_back("arrayValue");
StructureConstPtr structure = fieldCreate->createStructure(fieldNames, fields);
StructureConstPtr structureArrayValue = standardField->structureArray(structure, "alarm,timeStamp");
builder.clear();
structureArrayValue->toString(&builder);
print("structureArrayValue");
print("structureArrayValue", structureArrayValue);
StructureConstPtr punion = standardField->regUnion(
fieldCreate->createFieldBuilder()->
@@ -74,9 +69,7 @@ MAIN(testStandardField)
add("timeStamp",standardField->timeStamp())->
createUnion(),
"alarm,timeStamp");
builder.clear();
punion->toString(&builder);
print("unionValue");
print("unionValue", punion);
testPass("testStandardField");
return testDone();
}

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -24,17 +25,19 @@
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 String builder("");
static void print(String name)
static void print(const string& name, PVFieldPtr const & f)
{
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
if(debug) {
std::cout << std::endl << name << std::endl << *f << std::endl;
}
}
MAIN(testStandardPVField)
@@ -48,26 +51,18 @@ MAIN(testStandardPVField)
pvSeverity->put(2);
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
pvMessage->put("test message");
builder.clear();
pvStructure->toString(&builder);
print("scalarTest");
print("scalarTest", pvStructure);
pvStructure = standardPVField->scalar(pvBoolean,"alarm,timeStamp,valueAlarm");
builder.clear();
pvStructure->toString(&builder);
print("booleanTest");
print("booleanTest", pvStructure);
StringArray choices;
choices.reserve(3);
choices.push_back("one");
choices.push_back("two");
choices.push_back("three");
pvStructure = standardPVField->enumerated(choices, "alarm,timeStamp,valueAlarm");
builder.clear();
pvStructure->toString(&builder);
print("enumeratedTest");
print("enumeratedTest", pvStructure);
pvStructure = standardPVField->scalarArray(pvBoolean,"alarm,timeStamp");
builder.clear();
pvStructure->toString(&builder);
print("scalarArrayTest");
print("scalarArrayTest", pvStructure);
StructureConstPtr structure = standardField->scalar(pvDouble, "alarm,timeStamp");
pvStructure = standardPVField->structureArray(structure,"alarm,timeStamp");
size_t num = 2;
@@ -78,9 +73,7 @@ MAIN(testStandardPVField)
}
PVStructureArrayPtr pvStructureArray = pvStructure->getStructureArrayField("value");
pvStructureArray->replace(freeze(pvStructures));
builder.clear();
pvStructure->toString(&builder);
print("structureArrayTest");
print("structureArrayTest", pvStructure);
testPass("testStandardPVField");
return testDone();
}