62 std::stringstream sout;
65 TabularOutputter outputter(sout);
67 outputter.pushFieldSpec(
"very long col name", TO::INT);
68 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
69 outputter.pushFieldSpec(
"col cc", TO::STRING, TO::LEFT, TO::GENERAL, 6);
70 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
71 outputter.pushFieldSpec(
"col e", TO::STRING);
73 outputter.outputHeader();
75 outputter.outputField(1);
76 outputter.outputField(1.2);
77 outputter.outputField(
"s13");
78 outputter.outputField(1.4);
79 outputter.outputField(
"s15");
82 outputter.outputField(2);
83 outputter.outputField(2.2);
84 outputter.outputField(
"s23");
85 outputter.outputField(2.4);
86 outputter.outputField(
"s25");
89 outputter.outputField(3);
90 outputter.outputField(3.2);
91 outputter.outputField(
"s33");
92 outputter.outputField(3.4);
93 outputter.outputField(
"s35");
96 std::stringstream expectedOutput;
99 <<
" very long col name col b col cc col d col e\n"
100 <<
" ------------------ ------------ ------ ------------ -----\n"
101 <<
" 1 1.2000e+00 s13 1.4000e+00 s15\n"
102 <<
" 2 2.2000e+00 s23 2.4000e+00 s25\n"
103 <<
" 3 3.2000e+00 s33 3.4000e+00 s35\n"
120 std::stringstream sout;
123 TabularOutputter outputter(Teuchos::rcpFromRef(sout));
125 outputter.setFieldTypePrecision(TO::DOUBLE, 8);
126 outputter.setFieldTypePrecision(TO::INT, 4);
127 outputter.setFieldTypePrecision(TO::STRING, 5);
129 outputter.pushFieldSpec(
"col a", TO::INT);
130 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
131 outputter.pushFieldSpec(
"col cc", TO::STRING, TO::LEFT, TO::GENERAL, 6);
132 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
133 outputter.pushFieldSpec(
"col e", TO::STRING);
135 outputter.outputHeader();
137 outputter.outputField(1);
138 outputter.outputField(1.2);
139 outputter.outputField(
"s13");
140 outputter.outputField(1.4);
141 outputter.outputField(
"s15");
144 outputter.outputField(2);
145 outputter.outputField(2.2);
146 outputter.outputField(
"s23");
147 outputter.outputField(2.4);
148 outputter.outputField(
"s25");
151 outputter.outputField(3);
152 outputter.outputField(3.2);
153 outputter.outputField(
"s33");
154 outputter.outputField(3.4);
155 outputter.outputField(
"s35");
158 std::stringstream expectedOutput;
161 <<
" col a col b col cc col d col e\n"
162 <<
" ----- ---------------- ------ ---------------- -----\n"
163 <<
" 1 1.20000000e+00 s13 1.40000000e+00 s15\n"
164 <<
" 2 2.20000000e+00 s23 2.40000000e+00 s25\n"
165 <<
" 3 3.20000000e+00 s33 3.40000000e+00 s35\n"
180 std::stringstream sout;
183 TabularOutputter outputter(sout);
185 outputter.pushFieldSpec(
"num loops", TO::INT);
186 outputter.pushFieldSpec(
"vecTime", TO::DOUBLE);
187 outputter.pushFieldSpec(
"dequeTime", TO::DOUBLE);
189 outputter.outputHeader();
191 const int numLoops = 15;
194 outputter.outputField(numLoops);
199 std::vector<int> a(numLoops);
200 std::vector<int> b(numLoops);
209 std::deque<int> a(numLoops);
210 std::deque<int> b(numLoops);
218 std::stringstream expectedOutput;
240 TabularOutputter outputter(out);
254 TabularOutputter outputter(out);
256 outputter.setFieldTypePrecision(TO::DOUBLE, 8);
257 outputter.setFieldTypePrecision(TO::INT, 4);
258 outputter.setFieldTypePrecision(TO::STRING, 3);
260 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
263 outputter.pushFieldSpec(
264 "very long field name", TO::INT, TO::LEFT, TO::GENERAL, 4),
265 TO::InvalidFieldSpecError
276 TabularOutputter outputter(out);
278 outputter.pushFieldSpec(
"col a", TO::INT);
279 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
280 outputter.pushFieldSpec(
"col c", TO::STRING);
281 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
283 TEST_THROW(outputter.outputField(1), TO::MissingHeaderError);
293 TabularOutputter outputter(out);
295 outputter.pushFieldSpec(
"col a", TO::INT);
296 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
297 outputter.pushFieldSpec(
"col c", TO::STRING);
298 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
300 outputter.outputHeader();
302 outputter.outputField(1);
303 outputter.outputField(1.2);
304 outputter.outputField(
"s13");
305 outputter.outputField(1.4);
309 TEST_THROW(outputter.outputField(2), TO::InvalidFieldOutputError);
319 TabularOutputter outputter(out);
321 outputter.pushFieldSpec(
"col a", TO::INT);
322 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
323 outputter.pushFieldSpec(
"col c", TO::STRING);
324 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
326 outputter.outputHeader();
328 outputter.outputField(1);
329 outputter.outputField(1.2);
330 outputter.outputField(
"s13");
336 TEST_THROW(outputter.nextRow(), TO::InvalidFieldOutputError);
346 TabularOutputter outputter(out);
348 outputter.pushFieldSpec(
"col a", TO::INT);
349 outputter.pushFieldSpec(
"col b", TO::DOUBLE);
350 outputter.pushFieldSpec(
"col c", TO::STRING);
351 outputter.pushFieldSpec(
"col d", TO::DOUBLE);
353 outputter.outputHeader();
355 outputter.outputField(1);
356 outputter.outputField(1.2);
357 outputter.outputField(
"s13");
361 outputter.nextRow(
true);
371 std::ostringstream sout;
372 TabularOutputter outputter(sout);
374 TEST_THROW(outputter.outputHeader(), TO::MissingFieldsError);
379 #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 .