27 const string myname =
"test_Tpc2dRoi: ";
29 cout << myname <<
"NDEBUG must be off." <<
endl;
32 string myline = myname +
"-----------------------------";
34 cout << myline <<
endl;
35 cout << myname <<
"Checking default roi." <<
endl;
43 cout << myline <<
endl;
44 cout << myname <<
"Checking finite roi." <<
endl;
47 Index ndat = ncha*nsam;
51 assert( roi1.
data().
size() == ndat );
57 cout << myline <<
endl;
58 cout << myname <<
"Set values." <<
endl;
60 Index& kcha = idxs[0];
61 Index& ksam = idxs[1];
64 for ( kcha=0; kcha<ncha; ++kcha ) {
65 for ( ksam=0; ksam<nsam; ++ksam ) {
66 float val = nsam*kcha + ksam + 1;
69 float chkval = roi1.
data().
value(idxs, &ichk);
70 assert( chkval == val );
74 cout << myname <<
"Test count: " << ntst <<
endl;
76 cout << myline <<
endl;
77 cout << myname <<
"Retrieve values." <<
endl;
80 for ( kcha=0; kcha<ncha; ++kcha ) {
81 for ( ksam=0; ksam<nsam; ++ksam ) {
82 float expval = nsam*kcha + ksam + 1;
83 float chkval1 = roi1.
data().
value(idxs, &ichk);
85 assert( chkval1 == expval );
86 Index icha = icha0 + kcha;
87 Index isam = isam0 + ksam;
88 float chkval2 = roi1.
value(icha, isam);
89 assert( chkval2 == expval );
93 cout << myname <<
"Test count: " << ntst <<
endl;
95 cout << myline <<
endl;
96 cout << myname <<
"All tests passed." <<
endl;
104 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
float value(Index icha, LongIndex itck, float valdef=0.0) const
std::array< Index, 2 > IndexArray
Index size(Index idim) const
Float value(const IndexArray &isams, Index *pchk=nullptr) const
Index channelOffset() const
int main(int argc, char *argv[])
const DataArray & data() const
Index channelSize() const
Index setValue(const IndexArray &isams, Float val, Index *pchk=nullptr)
LongIndex sampleOffset() const
QTextStream & endl(QTextStream &s)