29 using std::ostringstream;
59 const string myname =
"test_make_tool: ";
60 cout << myname <<
"Starting test" <<
endl;
62 cout << myname <<
"NDEBUG must be off." <<
endl;
65 string line =
"-----------------------------";
68 cout << myname << line <<
endl;
69 string fclfile =
"test_make_tool.fcl";
70 if ( ! useExistingFcl ) {
71 cout << myname <<
"Creating top-level FCL." <<
endl;
72 ofstream
fout(fclfile.c_str());
75 fout <<
" tool_type: TestTool" <<
endl;
76 fout <<
" Label: \"Tool 1\"" <<
endl;
79 fout <<
" tool_type: TestTool" <<
endl;
80 fout <<
" Label: \"Tool 2\"" <<
endl;
85 cout << myname <<
"Using existing top-level FCL." <<
endl;
95 cout << myname << line <<
endl;
96 cout <<
"Retrieve with the correct interface type." <<
endl;
97 std::unique_ptr<ITestTool> pt1 = art::make_tool<ITestTool>(pstool1);
98 cout << myname <<
"Tool pointer: " << pt1.get() <<
endl;
99 cout << myname <<
"Tool type: " << pt1->
mytype() <<
endl;
100 assert( pt1->
mytype() ==
"TestTool" );
101 cout << myname <<
"Tool label: " << pt1->
label() <<
endl;
102 assert( pt1->
label() ==
"Tool 1" );
104 cout << myname << line <<
endl;
105 cout <<
"Retrieve with the incorrect interface type." <<
endl;
106 bool exceptionRaised =
false;
107 bool nullReturn =
false;
108 std::unique_ptr<INotTestTool> pt2;
110 pt2 = art::make_tool<INotTestTool>(pstool2);
112 exceptionRaised =
true;
113 nullReturn = pt2 ==
nullptr;
117 cout << myname <<
"Tool retrieval succeeded. This is not good." <<
endl;
118 cout << myname <<
"Tool pointer: " << pt2.get() <<
endl;
120 cout << myname <<
"Tool type: " << pt2->
mytype() <<
endl;
122 cout << myname <<
"Tool label: " << pt2->
label() <<
endl;
123 assert( pt2->
label() ==
"Tool 2" );
125 cout << myname <<
"Trying to fetch extra label..." <<
endl;
126 cout << myname <<
"Tool extra label: " << pt2->
extraLabel() <<
endl;
129 cout << myname <<
"Tool retrieval failed. As it should." <<
endl;
130 if ( exceptionRaised ) cout << myname <<
" Exception was raised." <<
endl;
131 if ( nullReturn ) cout << myname <<
" Tool pointer was null." <<
endl;
134 cout << myname << line <<
endl;
135 cout << myname <<
"Done." <<
endl;
141 int main(
int narg,
char** carg) {
142 bool doCrash = narg > 1;
143 bool keepFcl = narg > 2;
static ParameterSet make(intermediate_table const &tbl)
Q_EXPORT QTSManip setprecision(int p)
T get(std::string const &key) const
Q_EXPORT QTSManip setw(int w)
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)