23 using std::istringstream;
30 string myname =
"isequal: ";
31 if ( fabs(lhs - rhs) < 1.
e-10 )
return true;
32 cout << myname << lhs <<
" != " << rhs <<
endl;
37 const string myname =
"test_FclFloatArray: ";
39 cout << myname <<
"NDEBUG must be off." <<
endl;
42 string line =
"-----------------------------";
44 cout << myname << line <<
endl;
45 string fclfile =
"test_FclFloatArray.fcl";
47 if ( ! useExistingFcl ) {
48 cout << myname <<
"Creating top-level FCL." <<
endl;
49 ofstream
fout(fclfile.c_str());
52 fout <<
" tool_type: FclFloatArray" <<
endl;
58 fout <<
" Values: [ 0, 1.01, 2.02, 3.03, 4.04, 5.05, 6.06, 7.07, 8.08, 9.09," <<
endl;
59 fout <<
" 10.10, 11.11, 12.12, 13.13, 14.14, 15.15 ]" <<
endl;
64 cout << myname <<
"Using existing top-level FCL." <<
endl;
67 cout << myname << line <<
endl;
68 cout << myname <<
"Fetching tool manager." <<
endl;
70 assert ( ptm !=
nullptr );
75 cout << myname << line <<
endl;
76 cout << myname <<
"Fetching tool." <<
endl;
78 assert( pto !=
nullptr );
80 cout << myname << line <<
endl;
81 cout <<
"Check tool params." <<
endl;
83 assert( pto->offset() == ioff );
84 assert( pto->label() ==
"myvals" );
85 assert( pto->size() == nval );
86 assert( pto->offset() == ioff );
88 cout << myname << line <<
endl;
89 cout <<
"Check fill." <<
endl;
92 assert( pto->fill(fvals, fval) == 0 );
93 assert( fvals.size() == nval + ioff );
94 for (
Index ival=0; ival<ioff; ++ival ) {
95 assert( fvals[ival] == fval );
98 cout << myname << line <<
endl;
99 cout <<
"Check values." <<
endl;
100 for (
Index ival=0; ival<nval; ++ival ) {
101 assert( pto->values()[ival] == fvals[ioff+ival] );
102 assert(
isequal(pto->values()[ival], 1.01*ival) );
105 cout << myname << line <<
endl;
106 cout << myname <<
"Done." <<
endl;
113 bool useExistingFcl =
false;
115 string sarg(argv[1]);
116 if ( sarg ==
"-h" ) {
117 cout <<
"Usage: " << argv[0] <<
" [keepFCL] [RUN]" <<
endl;
118 cout <<
" If keepFCL = true, existing FCL file is used." <<
endl;
119 cout <<
" If RUN is nonzero, the data for that run are displayed." <<
endl;
122 useExistingFcl = sarg ==
"true" || sarg ==
"1";
bool isequal(float lhs, float rhs)
int test_FclFloatArray(bool useExistingFcl=false)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)
int main(int argc, char *argv[])