28 const string myname =
"test_AdcChannelData: ";
30 cout << myname <<
"NDEBUG must be off." <<
endl;
33 string line = myname +
"-----------------------------";
37 cout <<
"Checking fill." <<
endl;
39 for (
int i=0; i<20; ++i ) acdtop.
raw.push_back(i);
40 assert( acdtop.
channel() == 12345 );
41 assert( acdtop.
fembID() == 101 );
42 assert( acdtop.
raw.size() == 20 );
44 cout <<
"Checking copy." <<
endl;
46 assert( acdtopCopy.
channel() == 12345 );
47 assert( acdtopCopy.
fembID() == 101 );
48 assert( acdtopCopy.
raw.size() == 0 );
51 cout <<
"Checking assignment." <<
endl;
54 assert( acdtopAssg.
channel == 12345 );
55 assert( acdtopAssg.
fembID == 101 );
56 assert( acdtopAssg.
raw.size() == 20 );
60 cout << myname <<
"Add view1." <<
endl;
63 assert ( acdtop.
hasView(
"view1") );
64 assert ( ! acdtop.
hasView(
"view1/view2") );
67 for ( ient1=0; ient1<4; ++ient1 ) view1.push_back(acdtop);
70 assert( acd1.channel() == acdtop.
channel());
71 acd1.setMetadata(
"viewIndex1", ient1);
76 cout << myname <<
"Check view1." <<
endl;
79 for ( ient1=0; ient1<nent1; ++ient1 ) {
81 assert( pacd1 !=
nullptr );
85 assert( acd1.
getMetadata(
"viewIndex1", 99) == ient1 );
87 assert( pacdm !=
nullptr );
91 assert( acdm.
getMetadata(
"viewIndex1", 99) == ient1 );
95 cout << myname <<
"Add view2." <<
endl;
97 vector<Index> nent2s = { 1, 2, 2, 3 };
102 for (
Index ient1=0; ient1<nent1; ++ient1 ) {
105 Index nent2 = nent2s[ient1];
107 for ( ient2=0; ient2<nent2; ++ient2 ) {
108 view2.push_back(acdtop);
113 ient1s.push_back(ient1);
114 ient2s.push_back(ient2);
117 assert ( acd1.
hasView(
"view2") );
119 assert( ient12 = nent12 );
121 assert ( acdtop.
hasView(
"view1") );
122 assert ( acdtop.
hasView(
"view1/view2") );
123 assert( ient12 = nent12 );
125 cout << line <<
endl;
126 cout << myname <<
"Check view2." <<
endl;
128 for ( ient1=0; ient1<nent1; ++ient1 ) {
130 assert( pacd1 !=
nullptr );
133 for ( ient2=0; ient2<nent2; ++ient2 ) {
134 cout << myname <<
" " << ient1 <<
" " << ient2 <<
" " << ient12 <<
endl;
136 assert( pacd2 !=
nullptr );
138 assert( acd2.
channel() == 12345 );
139 assert( acd2.
fembID() == 101 );
142 assert( acd2.
getMetadata(
"viewIndex12") == ient12 );
147 cout << line <<
endl;
148 cout << myname <<
"Check view12." <<
endl;
149 assert( acdtop.
viewSize(
"view1/view2") == nent12 );
150 for ( ient12=0; ient12<nent12; ++ient12 ) {
152 assert( pacd12 !=
nullptr );
154 ient1 = ient1s[ient12];
155 ient2 = ient2s[ient12];
156 cout << myname <<
" " << ient1 <<
" " << ient2 <<
" " << ient12 <<
endl;
157 assert( acd12.
channel() == 12345 );
158 assert( acd12.
fembID() == 101 );
159 assert( acd12.
getMetadata(
"viewIndex1") == ient1 );
160 assert( acd12.
getMetadata(
"viewIndex2") == ient2 );
161 assert( acd12.
getMetadata(
"viewIndex12") == ient12 );
164 cout << line <<
endl;
165 cout << myname <<
"Check mutable view12." <<
endl;
166 assert( acdtop.
viewSize(
"view1/view2") == nent12 );
167 for ( ient12=0; ient12<nent12; ++ient12 ) {
169 assert( pacd12 !=
nullptr );
171 ient1 = ient1s[ient12];
172 ient2 = ient2s[ient12];
173 cout << myname <<
" " << ient1 <<
" " << ient2 <<
" " << ient12;
179 assert( acd12.
channel() == 12345 );
180 assert( acd12.
fembID() == 101 );
184 assert( acd12.
getMetadata(
"viewIndex1") == ient1 );
185 assert( acd12.
getMetadata(
"viewIndex2") == ient2 );
186 assert( acd12.
getMetadata(
"viewIndex12") == ient12 );
189 cout << line <<
endl;
190 cout << myname <<
"All tests passed." <<
endl;
198 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
int test_AdcChannelData()
std::vector< AdcChannelData > View
AdcChannelData::View View
void setChannelInfo(ChannelInfoPtr pchi)
bool hasMetadata(Name mname) const
float getMetadata(Name mname, float def=0.0) const
int main(int argc, char *argv[])
AdcChannelData * mutableViewEntry(Name vpnam, AdcIndex ient)
void line(double t, double *p, double &x, double &y, double &z)
const AdcChannelData * viewEntry(Name vpnam, AdcIndex ient) const
View & updateView(Name vnam)
void setMetadata(Name mname, float val)
bool hasView(Name vnam) const
QTextStream & endl(QTextStream &s)