Simple_t.cc
Go to the documentation of this file.
1 #include "cetlib_except/exception.h"
2 
3 #include <cassert>
4 #include <iomanip>
5 #include <iostream>
6 #include <string>
7 
8 int
9 main()
10 {
11  cet::exception e("BadJuju");
12 
13  char array[] = "blue";
14  char* ptr = array;
15 
16  e << "arghargharghargharghargh " << 3 << ' ' << 1.5 << std::endl
17  << std::string(" boo") << ' ' << array << ' ' << ptr;
18 
19  std::string expected = "---- BadJuju BEGIN\n"
20  " arghargharghargharghargh 3 1.5\n boo blue blue\n"
21  "---- BadJuju END\n";
22 
23  std::string result(e.explain_self());
24  assert(result == expected);
25 
26  // Check to see that the following items compile; their modification
27  // of the output is tested elsewhere.
28  e << std::setprecision(3);
29  e << std::scientific;
30 
31  cet::exception e2("RealBadStuff", "A");
32  e2 << "B";
33  std::string res2("---- RealBadStuff BEGIN\n A B\n---- RealBadStuff END\n");
34  assert(e2.explain_self() == res2);
35 
36  cet::exception e3("RealBadStuff", "A ");
37  e3 << "B";
38  std::string res3("---- RealBadStuff BEGIN\n A B\n---- RealBadStuff END\n");
39  assert(e3.explain_self() == res3);
40 }
static QCString result
const char expected[]
Definition: Exception_t.cc:22
std::string string
Definition: nybbler.cc:12
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
const double e
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
int main()
Definition: Simple_t.cc:9
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)