1
#ifndef TRPI_FORMATTER_H_SEEN
2
#define TRPI_FORMATTER_H_SEEN
4
#include <cxxtest/Flags.h>
6
#ifndef _CXXTEST_HAVE_STD
7
# define _CXXTEST_HAVE_STD
8
#endif // _CXXTEST_HAVE_STD
10
#include <cxxtest/ErrorFormatter.h>
11
#include <cxxtest/StdValueTraits.h>
13
#ifdef _CXXTEST_OLD_STD
14
# include <iostream.h>
15
#else // !_CXXTEST_OLD_STD
17
#endif // _CXXTEST_OLD_STD
21
class TRPIFormatter : public TestListener
24
TRPIFormatter( OutputStream *o ) :
30
virtual ~TRPIFormatter() { delete outputStream(); }
32
virtual void enterWorld( const WorldDescription & desc )
36
(*_o) << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
37
(*_o) << "<component name=\"inkscape\" version=\"0.43+svn\" xmlns=\"http://www.spikesource.com/xsd/2005/04/TRPI\">" << endl;
38
(*_o) << " <description>TBD</description>" << endl;
39
(*_o) << " <summary>single-line info</summary>" << endl;
40
(*_o) << " <license></license>" << endl;
41
(*_o) << " <vendor></vendor>" << endl;
42
(*_o) << " <release>devel SVN</release>" << endl;
43
(*_o) << " <url>http://www.inkscape.org/</url>" << endl;
44
// (*_o) << " <root></root>" << endl;
45
(*_o) << " <platform>\?\?\?</platform>" << endl;
49
virtual void leaveWorld( const WorldDescription & desc )
51
(*_o) << " <build status=\"" << (_runPassed?"pass":"fail") << "\"/>" << endl;
53
for ( unsigned int i = 0; i < desc.numSuites(); i++ ) {
54
const SuiteDescription& suite = desc.suiteDescription(i);
55
for ( unsigned int j = 0; j < suite.numTests(); j++ ) {
56
const TestDescription& test = suite.testDescription(j);
57
(*_o) << " <test suite-type=\"unit\">" << endl;
58
(*_o) << " <result executed=\"" << (unsigned)1
59
<< "\" passed=\"" << (unsigned)(_status[i][j] ? 1:0)
60
<< "\" failed=\"" << (unsigned)(_status[i][j] ? 0:1)
61
<< "\" skipped=\"" << (unsigned)0
64
(*_o) << " <suiteName>" << test.suiteName() << "</suiteName>" << endl;
65
(*_o) << " <testName>" << test.testName() << "</testName>" << endl;
67
// (*_o) << " <report name=\"" << test.suiteName() << "|" << test.testName() << "\" path=\"index.html\"/>" << endl;
69
(*_o) << " <expected-result executed=\"" << (unsigned)1
70
<< "\" passed=\"" << (unsigned)1
71
<< "\" failed=\"" << (unsigned)0
72
<< "\" skipped=\"" << (unsigned)0
74
(*_o) << " </test>" << endl;
78
// (*_o) << " <coverage-report />" << endl;
79
// (*_o) << " <code-convention-report />" << endl;
80
(*_o) << "</component>" << endl;
83
virtual void enterSuite( const SuiteDescription & desc )
88
while ( (_suiteIndex >= 0) && ((int)_status.size() <= _suiteIndex) ) {
89
std::vector<bool> tmp;
90
_status.push_back(tmp);
94
virtual void leaveSuite( const SuiteDescription & desc )
99
virtual void enterTest( const TestDescription & desc )
102
if ( _suiteIndex >= 0 && (int)_status.size() > _suiteIndex ) {
104
while ( (_testIndex >= 0) && ((int)_status[_suiteIndex].size() <= _testIndex) ) {
106
_status[_suiteIndex].push_back(tmp);
111
virtual void leaveTest( const TestDescription & desc )
118
virtual void failedTest( const char * /*file*/, unsigned /*line*/,
119
const char * /*expression*/ ) { _failCurrent(); }
120
virtual void failedAssert( const char * /*file*/, unsigned /*line*/,
121
const char * /*expression*/ ) { _failCurrent(); }
122
virtual void failedAssertEquals( const char * /*file*/, unsigned /*line*/,
123
const char * /*xStr*/, const char * /*yStr*/,
124
const char * /*x*/, const char * /*y*/ ) { _failCurrent(); }
125
virtual void failedAssertSameData( const char * /*file*/, unsigned /*line*/,
126
const char * /*xStr*/, const char * /*yStr*/,
127
const char * /*sizeStr*/, const void * /*x*/,
128
const void * /*y*/, unsigned /*size*/ ) { _failCurrent(); }
129
virtual void failedAssertDelta( const char * /*file*/, unsigned /*line*/,
130
const char * /*xStr*/, const char * /*yStr*/,
131
const char * /*dStr*/, const char * /*x*/,
132
const char * /*y*/, const char * /*d*/ ) { _failCurrent(); }
133
virtual void failedAssertDiffers( const char * /*file*/, unsigned /*line*/,
134
const char * /*xStr*/, const char * /*yStr*/,
135
const char * /*value*/ ) { _failCurrent(); }
136
virtual void failedAssertLessThan( const char * /*file*/, unsigned /*line*/,
137
const char * /*xStr*/, const char * /*yStr*/,
138
const char * /*x*/, const char * /*y*/ ) { _failCurrent(); }
139
virtual void failedAssertLessThanEquals( const char * /*file*/, unsigned /*line*/,
140
const char * /*xStr*/, const char * /*yStr*/,
141
const char * /*x*/, const char * /*y*/ ) { _failCurrent(); }
142
virtual void failedAssertPredicate( const char * /*file*/, unsigned /*line*/,
143
const char * /*predicate*/, const char * /*xStr*/, const char * /*x*/ ) { _failCurrent(); }
144
virtual void failedAssertRelation( const char * /*file*/, unsigned /*line*/,
145
const char * /*relation*/, const char * /*xStr*/, const char * /*yStr*/,
146
const char * /*x*/, const char * /*y*/ ) { _failCurrent(); }
147
virtual void failedAssertThrows( const char * /*file*/, unsigned /*line*/,
148
const char * /*expression*/, const char * /*type*/,
149
bool /*otherThrown*/ ) { _failCurrent(); }
150
virtual void failedAssertThrowsNot( const char * /*file*/, unsigned /*line*/,
151
const char * /*expression*/ ) { _failCurrent(); }
154
OutputStream *outputStream() const
159
void _failCurrent() {
161
if ( _suiteIndex < (int)_status.size() ) {
162
if ( _testIndex < (int)_status[_suiteIndex].size() ) {
163
_status[_suiteIndex][_testIndex] = false;
169
static void endl( OutputStream &o )
171
OutputStream::endl( o );
175
std::vector< std::vector<bool> > _status;
181
} // namespace CxxTest
186
c-file-style:"stroustrup"
187
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
192
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
194
#endif // TRPI_FORMATTER_H_SEEN