25 using ToolPtr = std::unique_ptr<AdcSimulator>;
30 template<
class T1,
class T2>
33 cout <<
msg <<
": " << x1 <<
" != " << x2 <<
endl;
39 Count countActual = ptool->count(vin);
40 cout <<
" ADC(" << vin <<
") = " << countActual <<
endl;
47 const string myname =
"test_IdealAdcSimulator: ";
49 cout << myname <<
"NDEBUG must be off." <<
endl;
52 string line =
"-----------------------------";
54 cout << myname << line <<
endl;
55 string fclfile =
"test_IdealAdcSimulator.fcl";
56 if ( ! useExistingFcl ) {
57 cout << myname <<
"Creating top-level FCL." <<
endl;
58 ofstream
fout(fclfile.c_str());
60 fout <<
" tool_type: IdealAdcSimulator" <<
endl;
66 cout << myname <<
"Using existing top-level FCL." <<
endl;
70 cout << myname << line <<
endl;
71 cout << myname <<
"Creating parameter set." <<
endl;
77 cout << myname << line <<
endl;
78 cout << myname <<
"Checking tool type." <<
endl;
80 cout <<
"Tool type: " << psTool.
get<
string>(
"tool_type") << endl;
81 assert( psTool.
get<
string>(
"tool_type") ==
"IdealAdcSimulator" );
83 cout << myname << line <<
endl;
84 cout << myname <<
"Instantiate tool." <<
endl;
85 std::unique_ptr<AdcSimulator> ptool = art::make_tool<AdcSimulator>(psTool);
86 assert( ptool !=
nullptr );
88 cout <<
"ADC count is " << ptool->
count(vin) <<
endl;
103 cout << myname << line <<
endl;
104 cout << myname <<
"Done." <<
endl;
111 bool useExistingFcl =
false;
113 string sarg(argv[1]);
114 if ( sarg ==
"-h" ) {
115 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
116 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
119 useExistingFcl = sarg ==
"true" || sarg ==
"1";
void msg(const char *fmt,...)
static ParameterSet make(intermediate_table const &tbl)
int main(int argc, char *argv[])
void checkCount(const ToolPtr &ptool, double vin, Count countExpected)
T get(std::string const &key) const
int test_IdealAdcSimulator(bool useExistingFcl)
AdcSimulator::Count Count
void checkEqual(T1 x1, T2 x2, string msg="Assert failed")
virtual Count count(double vin, Channel chan=0, Tick tick=0) const =0
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)