~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/TRPIFormatter.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-06 22:03:02 UTC
  • mto: (2.4.1 sid) (1.4.1 upstream) (45.1.3 maverick)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060706220302-itgso3qgxdaxjmcy
Tags: upstream-0.44
ImportĀ upstreamĀ versionĀ 0.44

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef TRPI_FORMATTER_H_SEEN
 
2
#define TRPI_FORMATTER_H_SEEN
 
3
 
 
4
#include <cxxtest/Flags.h>
 
5
 
 
6
#ifndef _CXXTEST_HAVE_STD
 
7
#   define _CXXTEST_HAVE_STD
 
8
#endif // _CXXTEST_HAVE_STD
 
9
 
 
10
#include <cxxtest/ErrorFormatter.h>
 
11
#include <cxxtest/StdValueTraits.h>
 
12
 
 
13
#ifdef _CXXTEST_OLD_STD
 
14
#   include <iostream.h>
 
15
#else // !_CXXTEST_OLD_STD
 
16
#   include <iostream>
 
17
#endif // _CXXTEST_OLD_STD
 
18
 
 
19
namespace CxxTest 
 
20
{
 
21
class TRPIFormatter : public TestListener
 
22
{
 
23
public:
 
24
    TRPIFormatter( OutputStream *o ) :
 
25
        _o(o),
 
26
        _runPassed(true),
 
27
        _suiteIndex(-1),
 
28
        _testIndex(-1)
 
29
    {}
 
30
    virtual ~TRPIFormatter() { delete outputStream(); }
 
31
 
 
32
    virtual void enterWorld( const WorldDescription & desc )
 
33
    {
 
34
        _status.clear();
 
35
 
 
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;
 
46
        _o->flush();
 
47
    }
 
48
 
 
49
    virtual void leaveWorld( const WorldDescription & desc )
 
50
    {
 
51
        (*_o) << "    <build status=\"" << (_runPassed?"pass":"fail") <<  "\"/>" << endl;
 
52
 
 
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
 
62
                      << "\"/>" << endl;
 
63
 
 
64
                (*_o) << "        <suiteName>" << test.suiteName() << "</suiteName>" << endl;
 
65
                (*_o) << "        <testName>" << test.testName() << "</testName>" << endl;
 
66
 
 
67
//                 (*_o) << "        <report name=\"" << test.suiteName() << "|" << test.testName() << "\" path=\"index.html\"/>" << endl;
 
68
 
 
69
                (*_o) << "        <expected-result executed=\"" << (unsigned)1
 
70
                      << "\" passed=\"" << (unsigned)1
 
71
                      << "\" failed=\"" << (unsigned)0
 
72
                      << "\" skipped=\"" << (unsigned)0
 
73
                      << "\"/>" << endl;
 
74
                (*_o) << "    </test>" << endl;
 
75
            }
 
76
        }
 
77
 
 
78
//         (*_o) << "    <coverage-report />" << endl;
 
79
//         (*_o) << "    <code-convention-report />" << endl;
 
80
        (*_o) << "</component>" << endl;
 
81
    }
 
82
 
 
83
    virtual void enterSuite( const SuiteDescription & desc )
 
84
    {
 
85
        (void)desc;
 
86
        _suiteIndex++;
 
87
        _testIndex = -1;
 
88
        while ( (_suiteIndex >= 0) && ((int)_status.size() <= _suiteIndex) ) {
 
89
            std::vector<bool> tmp;
 
90
            _status.push_back(tmp);
 
91
        }
 
92
    }
 
93
 
 
94
    virtual void leaveSuite( const SuiteDescription & desc )
 
95
    {
 
96
        (void)desc;
 
97
    }
 
98
 
 
99
    virtual void enterTest( const TestDescription & desc )
 
100
    {
 
101
        (void)desc;
 
102
        if ( _suiteIndex >= 0 && (int)_status.size() > _suiteIndex ) {
 
103
            _testIndex++;
 
104
            while ( (_testIndex >= 0) && ((int)_status[_suiteIndex].size() <= _testIndex) ) {
 
105
                bool tmp = true;
 
106
                _status[_suiteIndex].push_back(tmp);
 
107
            }
 
108
        }
 
109
    }
 
110
 
 
111
    virtual void leaveTest( const TestDescription & desc )
 
112
    {
 
113
        (void)desc;
 
114
    }
 
115
 
 
116
 
 
117
 
 
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(); }
 
152
 
 
153
protected:
 
154
    OutputStream *outputStream() const
 
155
    {
 
156
        return _o;
 
157
    }
 
158
 
 
159
    void _failCurrent() {
 
160
        _runPassed = false;
 
161
        if ( _suiteIndex < (int)_status.size() ) {
 
162
            if ( _testIndex < (int)_status[_suiteIndex].size() ) {
 
163
                _status[_suiteIndex][_testIndex] = false;
 
164
            }
 
165
        }
 
166
    }
 
167
 
 
168
private:
 
169
    static void endl( OutputStream &o )
 
170
    {
 
171
        OutputStream::endl( o );
 
172
    }
 
173
 
 
174
    OutputStream *_o;
 
175
    std::vector< std::vector<bool> > _status;
 
176
    bool _runPassed;
 
177
    int _suiteIndex;
 
178
    int _testIndex;
 
179
};
 
180
 
 
181
} // namespace CxxTest
 
182
 
 
183
/*
 
184
  Local Variables:
 
185
  mode:c++
 
186
  c-file-style:"stroustrup"
 
187
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
188
  indent-tabs-mode:nil
 
189
  fill-column:99
 
190
  End:
 
191
*/
 
192
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 
193
 
 
194
#endif // TRPI_FORMATTER_H_SEEN