testTabularStream.cc
Go to the documentation of this file.
1 
11 #include <iostream>
12 #include <utl/TabularStream.h>
13 
14 #include <cppunit/extensions/HelperMacros.h>
15 
16 using namespace utl;
17 using namespace std;
18 
19 
23 class TestTabularStream : public CppUnit::TestFixture {
24 
25  CPPUNIT_TEST_SUITE(TestTabularStream);
26  CPPUNIT_TEST(TestA);
27  CPPUNIT_TEST(TestB);
28  CPPUNIT_TEST(TestC);
29  CPPUNIT_TEST(TestStupidities);
30  CPPUNIT_TEST(TestTooManyColumns);
31  CPPUNIT_TEST_SUITE_END();
32 
33 public:
34  void
36  {
37  cout << "\nstart\n";
38 
39  TabularStream tab(". r l");
40 
41  tab << 3.14 << endc << "bla" << endc << 1111U << endr
42  << 13.07 << endc << "foobar" << endc << 22 << endr
43  << 123.456 << endc << 'a' << endc << 333;
44 
45  cout << tab << "stop" << endl;
46  }
47 
48  void
50  {
51  cout << "\nstart\n";
52 
53  TabularStream tab("|l|.|r|");
54 
55  tab << hline
56  << "gain" << endc << 1.23 << endc << "ok" << endr
57  << HLine('=')
58  << "jitter" << endc << 0.2 << endc << "+1" << endr
59  << "adc" << endc << ' ' << 13 << endc << "aha" << endr
60  << hline;
61 
62  cout << tab << "stop" << endl;
63  }
64 
65  void
67  {
68  cout << "\nstart\n";
69 
70  TabularStream tab("|c|.|.|");
71 
72  tab << "a" << "b" << 'c' << endc << 1.23 << endc << 1e-9 << endr;
73 
74  tab << 1 << 2 << 3 << endc << 12.3 << endc << "1." << "002" << endr
75  << "foo" << endc << 123 << endc << "0000.1" << endr
76  << "bar" << endc << "abc" << endc << "aabb";
77 
78  cout << tab << "stop" << endl;
79  }
80 
81  void
83  {
84  cout << "\nstart\n";
85 
86  TabularStream tab("|c|c|c|");
87 
88  tab << delr;
89 
90  cout << tab << "stop" << endl;
91  }
92 
93  void
95  {
96  cout << "\nstart\n";
97 
98  TabularStream tab("|r|r|l|");
99 
100  tab << hline
101  << "a " << endc << "b" << endc << "c" << endc << "d" << endc << "e"
102  << endr
103  << hline;
104 
105  cout << tab << "stop" << endl;
106  }
107 
108 };
109 
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
#define U
const EndRow endr
const int tab
Definition: SdInspector.cc:35
class that triggers insertion of the line row in the TabularStream
class to format data in tabular form
const DeleteRow delr
const HLine hline('-')
const EndColumn endc

, generated on Tue Sep 26 2023.