28 std::stringstream sout;
31 TabularOutputter outputter(sout);
33 outputter.pushFieldSpec(
"very long col name", TO::INT);
34 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
35 outputter.pushFieldSpec(
"col cc", TO::STRING, TO::LEFT, TO::GENERAL, 6);
36 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
37 outputter.pushFieldSpec(
"col e", TO::STRING);
39 outputter.outputHeader();
41 outputter.outputField(1);
42 outputter.outputField(1.2);
43 outputter.outputField(
"s13");
44 outputter.outputField(1.4);
45 outputter.outputField(
"s15");
48 outputter.outputField(2);
49 outputter.outputField(2.2);
50 outputter.outputField(
"s23");
51 outputter.outputField(2.4);
52 outputter.outputField(
"s25");
55 outputter.outputField(3);
56 outputter.outputField(3.2);
57 outputter.outputField(
"s33");
58 outputter.outputField(3.4);
59 outputter.outputField(
"s35");
62 std::stringstream expectedOutput;
65 <<
" very long col name col b col cc col d col e\n"
66 <<
" ------------------ ------------ ------ ------------ -----\n"
67 <<
" 1 1.2000e+00 s13 1.4000e+00 s15\n"
68 <<
" 2 2.2000e+00 s23 2.4000e+00 s25\n"
69 <<
" 3 3.2000e+00 s33 3.4000e+00 s35\n"
86 std::stringstream sout;
89 TabularOutputter outputter(Teuchos::rcpFromRef(sout));
91 outputter.setFieldTypePrecision(TO::DOUBLE, 8);
92 outputter.setFieldTypePrecision(TO::INT, 4);
93 outputter.setFieldTypePrecision(TO::STRING, 5);
95 outputter.pushFieldSpec(
"col a", TO::INT);
96 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
97 outputter.pushFieldSpec(
"col cc", TO::STRING, TO::LEFT, TO::GENERAL, 6);
98 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
99 outputter.pushFieldSpec(
"col e", TO::STRING);
101 outputter.outputHeader();
103 outputter.outputField(1);
104 outputter.outputField(1.2);
105 outputter.outputField(
"s13");
106 outputter.outputField(1.4);
107 outputter.outputField(
"s15");
110 outputter.outputField(2);
111 outputter.outputField(2.2);
112 outputter.outputField(
"s23");
113 outputter.outputField(2.4);
114 outputter.outputField(
"s25");
117 outputter.outputField(3);
118 outputter.outputField(3.2);
119 outputter.outputField(
"s33");
120 outputter.outputField(3.4);
121 outputter.outputField(
"s35");
124 std::stringstream expectedOutput;
127 <<
" col a col b col cc col d col e\n"
128 <<
" ----- ---------------- ------ ---------------- -----\n"
129 <<
" 1 1.20000000e+00 s13 1.40000000e+00 s15\n"
130 <<
" 2 2.20000000e+00 s23 2.40000000e+00 s25\n"
131 <<
" 3 3.20000000e+00 s33 3.40000000e+00 s35\n"
146 std::stringstream sout;
149 TabularOutputter outputter(sout);
151 outputter.pushFieldSpec(
"num loops", TO::INT);
152 outputter.pushFieldSpec(
"vecTime", TO::DOUBLE);
153 outputter.pushFieldSpec(
"dequeTime", TO::DOUBLE);
155 outputter.outputHeader();
157 const int numLoops = 15;
160 outputter.outputField(numLoops);
165 std::vector<int> a(numLoops);
166 std::vector<int> b(numLoops);
175 std::deque<int> a(numLoops);
176 std::deque<int> b(numLoops);
184 std::stringstream expectedOutput;
206 TabularOutputter outputter(out);
220 TabularOutputter outputter(out);
222 outputter.setFieldTypePrecision(TO::DOUBLE, 8);
223 outputter.setFieldTypePrecision(TO::INT, 4);
224 outputter.setFieldTypePrecision(TO::STRING, 3);
226 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
229 outputter.pushFieldSpec(
230 "very long field name", TO::INT, TO::LEFT, TO::GENERAL, 4),
231 TO::InvalidFieldSpecError
242 TabularOutputter outputter(out);
244 outputter.pushFieldSpec(
"col a", TO::INT);
245 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
246 outputter.pushFieldSpec(
"col c", TO::STRING);
247 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
249 TEST_THROW(outputter.outputField(1), TO::MissingHeaderError);
259 TabularOutputter outputter(out);
261 outputter.pushFieldSpec(
"col a", TO::INT);
262 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
263 outputter.pushFieldSpec(
"col c", TO::STRING);
264 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
266 outputter.outputHeader();
268 outputter.outputField(1);
269 outputter.outputField(1.2);
270 outputter.outputField(
"s13");
271 outputter.outputField(1.4);
275 TEST_THROW(outputter.outputField(2), TO::InvalidFieldOutputError);
285 TabularOutputter outputter(out);
287 outputter.pushFieldSpec(
"col a", TO::INT);
288 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
289 outputter.pushFieldSpec(
"col c", TO::STRING);
290 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
292 outputter.outputHeader();
294 outputter.outputField(1);
295 outputter.outputField(1.2);
296 outputter.outputField(
"s13");
302 TEST_THROW(outputter.nextRow(), TO::InvalidFieldOutputError);
312 TabularOutputter outputter(out);
314 outputter.pushFieldSpec(
"col a", TO::INT);
315 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
316 outputter.pushFieldSpec(
"col c", TO::STRING);
317 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
319 outputter.outputHeader();
321 outputter.outputField(1);
322 outputter.outputField(1.2);
323 outputter.outputField(
"s13");
327 outputter.nextRow(
true);
337 std::ostringstream sout;
338 TabularOutputter outputter(sout);
340 TEST_THROW(outputter.outputHeader(), TO::MissingFieldsError);
345 #endif // TEUCHOS_DEBUG
Null reference error exception class.
#define TEST_INEQUALITY_CONST(v1, v2)
Assert the inequality of v1 and constant v2.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails)...
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
Utility class that makes it easy to create formatted tables of output.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
#define TEUCHOS_END_PERF_OUTPUT_TIMER(OUTPUTTER, VARNAME)
End a timer block, output the time field to a TabularOutputter object, and set a variable with the ti...
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_START_PERF_OUTPUT_TIMER(OUTPUTTER, NUMLOOPS)
Start a timer block using a TabularOutputter object .