Debian Codegraph @

test_suite/formatting.cxx

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 Edward d'Auvergne
3 *
4 * This file is part of the program FlightGear.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #include <string>
22
23 #include "formatting.hxx"
24
25 using namespace std;
26
27
28 // Printout of a section label.
29 void printSection(CppUnit::OStream &stream, const string &text)
30 {
31 // Declarations.
32 string::size_type width = text.size();
33
34 // Format the text.
35 stream << endl;
36 stream << text << endl;
37 stream << string(width, '=') << endl << endl;
38 }
39
40
41 // Print a summary line.
42 void printSummaryLine(CppUnit::OStream &stream, const string &name, int passed)
43 {
44 // Declarations.
45 int n;
46 string dots, state;
47
48 // Passed.
49 if (!passed)
50 state = "OK";
51
52 // Skipped.
53 else if (passed == -1)
54 state = "Skipped";
55
56 // Failed.
57 else
58 state = "Failed";
59
60 // Dots.
61 n = WIDTH_DIVIDER - name.size() - state.size() - 6;
62 dots = string(n, '.');
63
64 // Write out the line.
65 stream << name;
66 stream << " " << dots << " ";
67 stream << "[ " << state << " ]" << endl;
68 }
69
70
71 // Printout of a title label.
72 void printTitle(CppUnit::OStream &stream, const string &text)
73 {
74 // Declarations.
75 string::size_type width = text.size() + 4;
76
77 // Format the text.
78 stream << endl << endl;
79 stream << string(width, '=') << endl;
80 stream << "= " << text << " =" << endl;
81 stream << string(width, '=') << endl << endl;
82 }