Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qxmltestlogger.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | namespace QTest { | - | ||||||||||||
6 | - | |||||||||||||
7 | static const char* xmlMessageType2String(QAbstractTestLogger::MessageTypes type) | - | ||||||||||||
8 | { | - | ||||||||||||
9 | switch (type) { | - | ||||||||||||
10 | case executed 24 times by 1 test: QAbstractTestLogger::Warn:case QAbstractTestLogger::Warn: Executed by:
executed 24 times by 1 test: case QAbstractTestLogger::Warn: Executed by:
| 24 | ||||||||||||
11 | return executed 24 times by 1 test: "warn";return "warn"; Executed by:
executed 24 times by 1 test: return "warn"; Executed by:
| 24 | ||||||||||||
12 | case executed 12 times by 1 test: QAbstractTestLogger::QSystem:case QAbstractTestLogger::QSystem: Executed by:
executed 12 times by 1 test: case QAbstractTestLogger::QSystem: Executed by:
| 12 | ||||||||||||
13 | return executed 12 times by 1 test: "system";return "system"; Executed by:
executed 12 times by 1 test: return "system"; Executed by:
| 12 | ||||||||||||
14 | case executed 1077 times by 1 test: QAbstractTestLogger::QDebug:case QAbstractTestLogger::QDebug: Executed by:
executed 1077 times by 1 test: case QAbstractTestLogger::QDebug: Executed by:
| 1077 | ||||||||||||
15 | return executed 1077 times by 1 test: "qdebug";return "qdebug"; Executed by:
executed 1077 times by 1 test: return "qdebug"; Executed by:
| 1077 | ||||||||||||
16 | case executed 24 times by 1 test: QAbstractTestLogger::QInfo:case QAbstractTestLogger::QInfo: Executed by:
executed 24 times by 1 test: case QAbstractTestLogger::QInfo: Executed by:
| 24 | ||||||||||||
17 | return executed 24 times by 1 test: "qinfo";return "qinfo"; Executed by:
executed 24 times by 1 test: return "qinfo"; Executed by:
| 24 | ||||||||||||
18 | case executed 24048 times by 1 test: QAbstractTestLogger::QWarning:case QAbstractTestLogger::QWarning: Executed by:
executed 24048 times by 1 test: case QAbstractTestLogger::QWarning: Executed by:
| 24048 | ||||||||||||
19 | return executed 24048 times by 1 test: "qwarn";return "qwarn"; Executed by:
executed 24048 times by 1 test: return "qwarn"; Executed by:
| 24048 | ||||||||||||
20 | case executed 24 times by 1 test: QAbstractTestLogger::QFatal:case QAbstractTestLogger::QFatal: Executed by:
executed 24 times by 1 test: case QAbstractTestLogger::QFatal: Executed by:
| 24 | ||||||||||||
21 | return executed 24 times by 1 test: "qfatal";return "qfatal"; Executed by:
executed 24 times by 1 test: return "qfatal"; Executed by:
| 24 | ||||||||||||
22 | case executed 444 times by 1 test: QAbstractTestLogger::Skip:case QAbstractTestLogger::Skip: Executed by:
executed 444 times by 1 test: case QAbstractTestLogger::Skip: Executed by:
| 444 | ||||||||||||
23 | return executed 444 times by 1 test: "skip";return "skip"; Executed by:
executed 444 times by 1 test: return "skip"; Executed by:
| 444 | ||||||||||||
24 | case executed 372 times by 1 test: QAbstractTestLogger::Info:case QAbstractTestLogger::Info: Executed by:
executed 372 times by 1 test: case QAbstractTestLogger::Info: Executed by:
| 372 | ||||||||||||
25 | return executed 372 times by 1 test: "info";return "info"; Executed by:
executed 372 times by 1 test: return "info"; Executed by:
| 372 | ||||||||||||
26 | } | - | ||||||||||||
27 | return never executed: "??????";return "??????"; never executed: return "??????"; | 0 | ||||||||||||
28 | } | - | ||||||||||||
29 | - | |||||||||||||
30 | static const char* xmlIncidentType2String(QAbstractTestLogger::IncidentTypes type) | - | ||||||||||||
31 | { | - | ||||||||||||
32 | switch (type) { | - | ||||||||||||
33 | case executed 2247 times by 1 test: QAbstractTestLogger::Pass:case QAbstractTestLogger::Pass: Executed by:
executed 2247 times by 1 test: case QAbstractTestLogger::Pass: Executed by:
| 2247 | ||||||||||||
34 | return executed 2247 times by 1 test: "pass";return "pass"; Executed by:
executed 2247 times by 1 test: return "pass"; Executed by:
| 2247 | ||||||||||||
35 | case executed 180 times by 1 test: QAbstractTestLogger::XFail:case QAbstractTestLogger::XFail: Executed by:
executed 180 times by 1 test: case QAbstractTestLogger::XFail: Executed by:
| 180 | ||||||||||||
36 | return executed 180 times by 1 test: "xfail";return "xfail"; Executed by:
executed 180 times by 1 test: return "xfail"; Executed by:
| 180 | ||||||||||||
37 | case executed 1245 times by 1 test: QAbstractTestLogger::Fail:case QAbstractTestLogger::Fail: Executed by:
executed 1245 times by 1 test: case QAbstractTestLogger::Fail: Executed by:
| 1245 | ||||||||||||
38 | return executed 1245 times by 1 test: "fail";return "fail"; Executed by:
executed 1245 times by 1 test: return "fail"; Executed by:
| 1245 | ||||||||||||
39 | case executed 48 times by 1 test: QAbstractTestLogger::XPass:case QAbstractTestLogger::XPass: Executed by:
executed 48 times by 1 test: case QAbstractTestLogger::XPass: Executed by:
| 48 | ||||||||||||
40 | return executed 48 times by 1 test: "xpass";return "xpass"; Executed by:
executed 48 times by 1 test: return "xpass"; Executed by:
| 48 | ||||||||||||
41 | case never executed: QAbstractTestLogger::BlacklistedPass:case QAbstractTestLogger::BlacklistedPass: never executed: case QAbstractTestLogger::BlacklistedPass: | 0 | ||||||||||||
42 | return never executed: "bpass";return "bpass"; never executed: return "bpass"; | 0 | ||||||||||||
43 | case never executed: QAbstractTestLogger::BlacklistedFail:case QAbstractTestLogger::BlacklistedFail: never executed: case QAbstractTestLogger::BlacklistedFail: | 0 | ||||||||||||
44 | return never executed: "bfail";return "bfail"; never executed: return "bfail"; | 0 | ||||||||||||
45 | } | - | ||||||||||||
46 | return never executed: "??????";return "??????"; never executed: return "??????"; | 0 | ||||||||||||
47 | } | - | ||||||||||||
48 | - | |||||||||||||
49 | } | - | ||||||||||||
50 | - | |||||||||||||
51 | - | |||||||||||||
52 | QXmlTestLogger::QXmlTestLogger(XmlMode mode, const char *filename) | - | ||||||||||||
53 | : QAbstractTestLogger(filename), xmlmode(mode) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | } executed 369 times by 1 test: end of block Executed by:
| 369 | ||||||||||||
56 | - | |||||||||||||
57 | QXmlTestLogger::~QXmlTestLogger() | - | ||||||||||||
58 | { | - | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | void QXmlTestLogger::startLogging() | - | ||||||||||||
62 | { | - | ||||||||||||
63 | QAbstractTestLogger::startLogging(); | - | ||||||||||||
64 | QTestCharBuffer buf; | - | ||||||||||||
65 | - | |||||||||||||
66 | if (xmlmode == QXmlTestLogger::Complete
| 184-185 | ||||||||||||
67 | QTestCharBuffer quotedTc; | - | ||||||||||||
68 | xmlQuote("edTc, QTestResult::currentTestObjectName()); | - | ||||||||||||
69 | QTest::qt_asprintf(&buf, | - | ||||||||||||
70 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | - | ||||||||||||
71 | "<TestCase name=\"%s\">\n", quotedTc.constData()); | - | ||||||||||||
72 | outputString(buf.constData()); | - | ||||||||||||
73 | } executed 184 times by 1 test: end of block Executed by:
| 184 | ||||||||||||
74 | - | |||||||||||||
75 | QTestCharBuffer quotedBuild; | - | ||||||||||||
76 | xmlQuote("edBuild, QLibraryInfo::build()); | - | ||||||||||||
77 | - | |||||||||||||
78 | QTest::qt_asprintf(&buf, | - | ||||||||||||
79 | "<Environment>\n" | - | ||||||||||||
80 | " <QtVersion>%s</QtVersion>\n" | - | ||||||||||||
81 | " <QtBuild>%s</QtBuild>\n" | - | ||||||||||||
82 | " <QTestVersion>" "5.7.1" "</QTestVersion>\n" | - | ||||||||||||
83 | "</Environment>\n", qVersion(), quotedBuild.constData()); | - | ||||||||||||
84 | outputString(buf.constData()); | - | ||||||||||||
85 | } executed 369 times by 1 test: end of block Executed by:
| 369 | ||||||||||||
86 | - | |||||||||||||
87 | void QXmlTestLogger::stopLogging() | - | ||||||||||||
88 | { | - | ||||||||||||
89 | QTestCharBuffer buf; | - | ||||||||||||
90 | QTest::qt_asprintf(&buf, | - | ||||||||||||
91 | "<Duration msecs=\"%f\"/>\n", QTestLog::msecsTotalTime()); | - | ||||||||||||
92 | outputString(buf.constData()); | - | ||||||||||||
93 | if (xmlmode == QXmlTestLogger::Complete
| 184-185 | ||||||||||||
94 | outputString("</TestCase>\n"); | - | ||||||||||||
95 | } executed 184 times by 1 test: end of block Executed by:
| 184 | ||||||||||||
96 | - | |||||||||||||
97 | QAbstractTestLogger::stopLogging(); | - | ||||||||||||
98 | } executed 369 times by 1 test: end of block Executed by:
| 369 | ||||||||||||
99 | - | |||||||||||||
100 | void QXmlTestLogger::enterTestFunction(const char *function) | - | ||||||||||||
101 | { | - | ||||||||||||
102 | QTestCharBuffer buf; | - | ||||||||||||
103 | QTestCharBuffer quotedFunction; | - | ||||||||||||
104 | xmlQuote("edFunction, function); | - | ||||||||||||
105 | QTest::qt_asprintf(&buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData()); | - | ||||||||||||
106 | outputString(buf.constData()); | - | ||||||||||||
107 | } executed 2274 times by 1 test: end of block Executed by:
| 2274 | ||||||||||||
108 | - | |||||||||||||
109 | void QXmlTestLogger::leaveTestFunction() | - | ||||||||||||
110 | { | - | ||||||||||||
111 | QTestCharBuffer buf; | - | ||||||||||||
112 | QTest::qt_asprintf(&buf, | - | ||||||||||||
113 | " <Duration msecs=\"%f\"/>\n" | - | ||||||||||||
114 | "</TestFunction>\n", | - | ||||||||||||
115 | QTestLog::msecsFunctionTime()); | - | ||||||||||||
116 | - | |||||||||||||
117 | outputString(buf.constData()); | - | ||||||||||||
118 | } executed 2274 times by 1 test: end of block Executed by:
| 2274 | ||||||||||||
119 | - | |||||||||||||
120 | namespace QTest | - | ||||||||||||
121 | { | - | ||||||||||||
122 | - | |||||||||||||
123 | inline static bool isEmpty(const char *str) | - | ||||||||||||
124 | { | - | ||||||||||||
125 | return executed 59406 times by 1 test: !str || !str[0];return !str || !str[0]; Executed by:
executed 59406 times by 1 test: return !str || !str[0]; Executed by:
| 59406 | ||||||||||||
126 | } | - | ||||||||||||
127 | - | |||||||||||||
128 | static const char *incidentFormatString(bool noDescription, bool noTag) | - | ||||||||||||
129 | { | - | ||||||||||||
130 | if (noDescription
| 1473-2247 | ||||||||||||
131 | if (noTag
| 879-1368 | ||||||||||||
132 | return executed 879 times by 1 test: "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n";return "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n"; Executed by:
executed 879 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n"; Executed by:
| 879 | ||||||||||||
133 | else | - | ||||||||||||
134 | return executed 1368 times by 1 test: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Incident>\n"; Executed by:
executed 1368 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Incident>\n"; Executed by:
| 1368 | ||||||||||||
135 | " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" executed 1368 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Incident>\n"; Executed by:
| 1368 | ||||||||||||
136 | "</Incident>\n"; executed 1368 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Incident>\n"; Executed by:
| 1368 | ||||||||||||
137 | } else { | - | ||||||||||||
138 | if (noTag
| 549-924 | ||||||||||||
139 | return executed 549 times by 1 test: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Incident>\n"; Executed by:
executed 549 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Incident>\n"; Executed by:
| 549 | ||||||||||||
140 | " <Description><![CDATA[%s%s%s%s]]></Description>\n" executed 549 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Incident>\n"; Executed by:
| 549 | ||||||||||||
141 | "</Incident>\n"; executed 549 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Incident>\n"; Executed by:
| 549 | ||||||||||||
142 | else | - | ||||||||||||
143 | return executed 924 times by 1 test: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Incident>\n"; Executed by:
executed 924 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Incident>\n"; Executed by:
| 924 | ||||||||||||
144 | " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" executed 924 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Incident>\n"; Executed by:
| 924 | ||||||||||||
145 | " <Description><![CDATA[%s]]></Description>\n" executed 924 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Incident>\n"; Executed by:
| 924 | ||||||||||||
146 | "</Incident>\n"; executed 924 times by 1 test: return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Incident>\n"; Executed by:
| 924 | ||||||||||||
147 | } | - | ||||||||||||
148 | } | - | ||||||||||||
149 | - | |||||||||||||
150 | static const char *benchmarkResultFormatString() | - | ||||||||||||
151 | { | - | ||||||||||||
152 | return executed 132 times by 1 test: "<BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%s\" iterations=\"%d\" />\n";return "<BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%s\" iterations=\"%d\" />\n"; Executed by:
executed 132 times by 1 test: return "<BenchmarkResult metric=\"%s\" tag=\"%s\" value=\"%s\" iterations=\"%d\" />\n"; Executed by:
| 132 | ||||||||||||
153 | } | - | ||||||||||||
154 | - | |||||||||||||
155 | static const char *messageFormatString(bool noDescription, bool noTag) | - | ||||||||||||
156 | { | - | ||||||||||||
157 | if (noDescription
| 0-26025 | ||||||||||||
158 | if (noTag
| 0 | ||||||||||||
159 | return never executed: "<Message type=\"%s\" file=\"%s\" line=\"%d\" />\n";return "<Message type=\"%s\" file=\"%s\" line=\"%d\" />\n"; never executed: return "<Message type=\"%s\" file=\"%s\" line=\"%d\" />\n"; | 0 | ||||||||||||
160 | else | - | ||||||||||||
161 | return never executed: "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Message>\n"; never executed: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Message>\n"; | 0 | ||||||||||||
162 | " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" never executed: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Message>\n"; | 0 | ||||||||||||
163 | "</Message>\n"; never executed: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n" "</Message>\n"; | 0 | ||||||||||||
164 | } else { | - | ||||||||||||
165 | if (noTag
| 1524-24501 | ||||||||||||
166 | return executed 24501 times by 1 test: "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Message>\n"; Executed by:
executed 24501 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Message>\n"; Executed by:
| 24501 | ||||||||||||
167 | " <Description><![CDATA[%s%s%s%s]]></Description>\n" executed 24501 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Message>\n"; Executed by:
| 24501 | ||||||||||||
168 | "</Message>\n"; executed 24501 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <Description><![CDATA[%s%s%s%s]]></Description>\n" "</Message>\n"; Executed by:
| 24501 | ||||||||||||
169 | else | - | ||||||||||||
170 | return executed 1524 times by 1 test: "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Message>\n"; Executed by:
executed 1524 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Message>\n"; Executed by:
| 1524 | ||||||||||||
171 | " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" executed 1524 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Message>\n"; Executed by:
| 1524 | ||||||||||||
172 | " <Description><![CDATA[%s]]></Description>\n" executed 1524 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Message>\n"; Executed by:
| 1524 | ||||||||||||
173 | "</Message>\n"; executed 1524 times by 1 test: return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n" " <DataTag><![CDATA[%s%s%s]]></DataTag>\n" " <Description><![CDATA[%s]]></Description>\n" "</Message>\n"; Executed by:
| 1524 | ||||||||||||
174 | } | - | ||||||||||||
175 | } | - | ||||||||||||
176 | - | |||||||||||||
177 | } | - | ||||||||||||
178 | - | |||||||||||||
179 | void QXmlTestLogger::addIncident(IncidentTypes type, const char *description, | - | ||||||||||||
180 | const char *file, int line) | - | ||||||||||||
181 | { | - | ||||||||||||
182 | QTestCharBuffer buf; | - | ||||||||||||
183 | const char *tag = QTestResult::currentDataTag(); | - | ||||||||||||
184 | const char *gtag = QTestResult::currentGlobalDataTag(); | - | ||||||||||||
185 | const char *filler = (tag
| 84-2292 | ||||||||||||
186 | const bool notag = QTest::isEmpty(tag)
| 0-2292 | ||||||||||||
187 | - | |||||||||||||
188 | QTestCharBuffer quotedFile; | - | ||||||||||||
189 | QTestCharBuffer cdataGtag; | - | ||||||||||||
190 | QTestCharBuffer cdataTag; | - | ||||||||||||
191 | QTestCharBuffer cdataDescription; | - | ||||||||||||
192 | - | |||||||||||||
193 | xmlQuote("edFile, file); | - | ||||||||||||
194 | xmlCdata(&cdataGtag, gtag); | - | ||||||||||||
195 | xmlCdata(&cdataTag, tag); | - | ||||||||||||
196 | xmlCdata(&cdataDescription, description); | - | ||||||||||||
197 | - | |||||||||||||
198 | QTest::qt_asprintf(&buf, | - | ||||||||||||
199 | QTest::incidentFormatString(QTest::isEmpty(description), notag), | - | ||||||||||||
200 | QTest::xmlIncidentType2String(type), | - | ||||||||||||
201 | quotedFile.constData(), line, | - | ||||||||||||
202 | cdataGtag.constData(), | - | ||||||||||||
203 | filler, | - | ||||||||||||
204 | cdataTag.constData(), | - | ||||||||||||
205 | cdataDescription.constData()); | - | ||||||||||||
206 | - | |||||||||||||
207 | outputString(buf.constData()); | - | ||||||||||||
208 | } executed 3720 times by 1 test: end of block Executed by:
| 3720 | ||||||||||||
209 | - | |||||||||||||
210 | void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) | - | ||||||||||||
211 | { | - | ||||||||||||
212 | QTestCharBuffer buf; | - | ||||||||||||
213 | QTestCharBuffer quotedMetric; | - | ||||||||||||
214 | QTestCharBuffer quotedTag; | - | ||||||||||||
215 | - | |||||||||||||
216 | xmlQuote("edMetric, | - | ||||||||||||
217 | benchmarkMetricName(result.metric)); | - | ||||||||||||
218 | xmlQuote("edTag, result.context.tag.toUtf8().constData()); | - | ||||||||||||
219 | - | |||||||||||||
220 | const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); | - | ||||||||||||
221 | QTest::qt_asprintf( | - | ||||||||||||
222 | &buf, | - | ||||||||||||
223 | QTest::benchmarkResultFormatString(), | - | ||||||||||||
224 | quotedMetric.constData(), | - | ||||||||||||
225 | quotedTag.constData(), | - | ||||||||||||
226 | QByteArray::number(valuePerIteration).constData(), | - | ||||||||||||
227 | result.iterations); | - | ||||||||||||
228 | outputString(buf.constData()); | - | ||||||||||||
229 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||||||||
230 | - | |||||||||||||
231 | void QXmlTestLogger::addMessage(MessageTypes type, const QString &message, | - | ||||||||||||
232 | const char *file, int line) | - | ||||||||||||
233 | { | - | ||||||||||||
234 | QTestCharBuffer buf; | - | ||||||||||||
235 | const char *tag = QTestResult::currentDataTag(); | - | ||||||||||||
236 | const char *gtag = QTestResult::currentGlobalDataTag(); | - | ||||||||||||
237 | const char *filler = (tag
| 408-24513 | ||||||||||||
238 | const bool notag = QTest::isEmpty(tag)
| 12-24513 | ||||||||||||
239 | - | |||||||||||||
240 | QTestCharBuffer quotedFile; | - | ||||||||||||
241 | QTestCharBuffer cdataGtag; | - | ||||||||||||
242 | QTestCharBuffer cdataTag; | - | ||||||||||||
243 | QTestCharBuffer cdataDescription; | - | ||||||||||||
244 | - | |||||||||||||
245 | xmlQuote("edFile, file); | - | ||||||||||||
246 | xmlCdata(&cdataGtag, gtag); | - | ||||||||||||
247 | xmlCdata(&cdataTag, tag); | - | ||||||||||||
248 | xmlCdata(&cdataDescription, message.toUtf8().constData()); | - | ||||||||||||
249 | - | |||||||||||||
250 | QTest::qt_asprintf(&buf, | - | ||||||||||||
251 | QTest::messageFormatString(message.isEmpty(), notag), | - | ||||||||||||
252 | QTest::xmlMessageType2String(type), | - | ||||||||||||
253 | quotedFile.constData(), line, | - | ||||||||||||
254 | cdataGtag.constData(), | - | ||||||||||||
255 | filler, | - | ||||||||||||
256 | cdataTag.constData(), | - | ||||||||||||
257 | cdataDescription.constData()); | - | ||||||||||||
258 | - | |||||||||||||
259 | outputString(buf.constData()); | - | ||||||||||||
260 | } executed 26025 times by 1 test: end of block Executed by:
| 26025 | ||||||||||||
261 | - | |||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | int QXmlTestLogger::xmlQuote(QTestCharBuffer* destBuf, char const* src, size_t n) | - | ||||||||||||
268 | { | - | ||||||||||||
269 | if (n == 0
never executed: 0;return 0; never executed: return 0; | 0-71069 | ||||||||||||
270 | - | |||||||||||||
271 | char *dest = destBuf->data(); | - | ||||||||||||
272 | *dest = 0; | - | ||||||||||||
273 | if (!src
executed 27597 times by 1 test: 0;return 0; Executed by:
executed 27597 times by 1 test: return 0; Executed by:
| 27597-43472 | ||||||||||||
274 | - | |||||||||||||
275 | char* begin = dest; | - | ||||||||||||
276 | char* end = dest + n; | - | ||||||||||||
277 | - | |||||||||||||
278 | while (dest < end
| 28-471029 | ||||||||||||
279 | switch (*src) { | - | ||||||||||||
280 | case executed 253 times by 1 test: '>':case '>': Executed by:
executed 253 times by 1 test: if (dest + sizeof(">") < endcase '>': Executed by:
executed 253 times by 1 test: else { *dest = 0; returnend of block Executed by:
never executed: (dest+sizeof(">")-begin);return (dest+sizeof(">")-begin); never executed: } ++src; break;return (dest+sizeof(">")-begin); executed 253 times by 1 test: ;break; Executed by:
| 0-253 | ||||||||||||
281 | case executed 187 times by 1 test: '<':case '<': Executed by:
executed 187 times by 1 test: if (dest + sizeof("<") < endcase '<': Executed by:
executed 187 times by 1 test: else { *dest = 0; returnend of block Executed by:
never executed: (dest+sizeof("<")-begin);return (dest+sizeof("<")-begin); never executed: } ++src; break;return (dest+sizeof("<")-begin); executed 187 times by 1 test: ;break; Executed by:
| 0-187 | ||||||||||||
282 | case executed 588 times by 1 test: '\'':case '\'': Executed by:
executed 588 times by 1 test: if (dest + sizeof("'") < endcase '\'': Executed by:
executed 588 times by 1 test: else { *dest = 0; returnend of block Executed by:
never executed: (dest+sizeof("'")-begin);return (dest+sizeof("'")-begin); never executed: } ++src; break;return (dest+sizeof("'")-begin); executed 588 times by 1 test: ;break; Executed by:
| 0-588 | ||||||||||||
283 | case executed 666 times by 1 test: '"':case '"': Executed by:
executed 666 times by 1 test: if (dest + sizeof(""") < endcase '"': Executed by:
executed 666 times by 1 test: else { *dest = 0; returnend of block Executed by:
never executed: (dest+sizeof(""")-begin);return (dest+sizeof(""")-begin); never executed: } ++src; break;return (dest+sizeof(""")-begin); executed 666 times by 1 test: ;break; Executed by:
| 0-666 | ||||||||||||
284 | case never executed: '&':case '&': never executed: if (dest + sizeof("&") < endcase '&':
never executed: else { *dest = 0; returnend of block never executed: (dest+sizeof("&")-begin);return (dest+sizeof("&")-begin); never executed: } ++src; break;return (dest+sizeof("&")-begin); never executed: ;break; | 0 | ||||||||||||
285 | - | |||||||||||||
286 | - | |||||||||||||
287 | - | |||||||||||||
288 | case executed 1217 times by 1 test: '-':case '-': Executed by:
executed 1217 times by 1 test: if (dest + sizeof("-") < endcase '-': Executed by:
executed 1217 times by 1 test: else { *dest = 0; returnend of block Executed by:
never executed: (dest+sizeof("-")-begin);return (dest+sizeof("-")-begin); never executed: } ++src; break;return (dest+sizeof("-")-begin); executed 1217 times by 1 test: ;break; Executed by:
| 0-1217 | ||||||||||||
289 | - | |||||||||||||
290 | - | |||||||||||||
291 | - | |||||||||||||
292 | case executed 43444 times by 1 test: 0:case 0: Executed by:
executed 43444 times by 1 test: case 0: Executed by:
| 43444 | ||||||||||||
293 | *dest = 0; | - | ||||||||||||
294 | return executed 43444 times by 1 test: (dest-begin);return (dest-begin); Executed by:
executed 43444 times by 1 test: return (dest-begin); Executed by:
| 43444 | ||||||||||||
295 | - | |||||||||||||
296 | default executed 424674 times by 1 test: :default: Executed by:
executed 424674 times by 1 test: default: Executed by:
| 424674 | ||||||||||||
297 | *dest = *src; | - | ||||||||||||
298 | ++dest; | - | ||||||||||||
299 | ++src; | - | ||||||||||||
300 | break; executed 424674 times by 1 test: break; Executed by:
| 424674 | ||||||||||||
301 | } | - | ||||||||||||
302 | } | - | ||||||||||||
303 | - | |||||||||||||
304 | - | |||||||||||||
305 | *(dest-1) = 0; | - | ||||||||||||
306 | return executed 28 times by 1 test: (dest-begin);return (dest-begin); Executed by:
executed 28 times by 1 test: return (dest-begin); Executed by:
| 28 | ||||||||||||
307 | } | - | ||||||||||||
308 | - | |||||||||||||
309 | - | |||||||||||||
310 | - | |||||||||||||
311 | - | |||||||||||||
312 | - | |||||||||||||
313 | int QXmlTestLogger::xmlCdata(QTestCharBuffer *destBuf, char const* src, size_t n) | - | ||||||||||||
314 | { | - | ||||||||||||
315 | if (!n
never executed: 0;return 0; never executed: return 0; | 0-104566 | ||||||||||||
316 | - | |||||||||||||
317 | char *dest = destBuf->data(); | - | ||||||||||||
318 | - | |||||||||||||
319 | if (!src
| 0-55182 | ||||||||||||
320 | *dest = 0; | - | ||||||||||||
321 | return executed 55182 times by 1 test: 0;return 0; Executed by:
executed 55182 times by 1 test: return 0; Executed by:
| 55182 | ||||||||||||
322 | } | - | ||||||||||||
323 | - | |||||||||||||
324 | static char const CDATA_END[] = "]]>"; | - | ||||||||||||
325 | static char const CDATA_END_ESCAPED[] = "]]]><![CDATA[]>"; | - | ||||||||||||
326 | - | |||||||||||||
327 | char* begin = dest; | - | ||||||||||||
328 | char* end = dest + n; | - | ||||||||||||
329 | while (dest < end
| 48-457940 | ||||||||||||
330 | if (!*src
| 49336-408604 | ||||||||||||
331 | *dest = 0; | - | ||||||||||||
332 | return executed 49336 times by 1 test: (dest-begin);return (dest-begin); Executed by:
executed 49336 times by 1 test: return (dest-begin); Executed by:
| 49336 | ||||||||||||
333 | } | - | ||||||||||||
334 | - | |||||||||||||
335 | if (!strncmp(src, CDATA_END, sizeof(CDATA_END)-1)
| 250-408354 | ||||||||||||
336 | if (dest + sizeof(CDATA_END_ESCAPED) < end
| 0-250 | ||||||||||||
337 | strcpy(dest, CDATA_END_ESCAPED); | - | ||||||||||||
338 | src += sizeof(CDATA_END)-1; | - | ||||||||||||
339 | dest += sizeof(CDATA_END_ESCAPED) - 1; | - | ||||||||||||
340 | } executed 250 times by 1 test: end of block Executed by:
| 250 | ||||||||||||
341 | else { | - | ||||||||||||
342 | *dest = 0; | - | ||||||||||||
343 | return never executed: (dest+sizeof(CDATA_END_ESCAPED)-begin);return (dest+sizeof(CDATA_END_ESCAPED)-begin); never executed: return (dest+sizeof(CDATA_END_ESCAPED)-begin); | 0 | ||||||||||||
344 | } | - | ||||||||||||
345 | continue; executed 250 times by 1 test: continue; Executed by:
| 250 | ||||||||||||
346 | } | - | ||||||||||||
347 | - | |||||||||||||
348 | *dest = *src; | - | ||||||||||||
349 | ++src; | - | ||||||||||||
350 | ++dest; | - | ||||||||||||
351 | } executed 408354 times by 1 test: end of block Executed by:
| 408354 | ||||||||||||
352 | - | |||||||||||||
353 | - | |||||||||||||
354 | *(dest-1) = 0; | - | ||||||||||||
355 | return executed 48 times by 1 test: (dest-begin);return (dest-begin); Executed by:
executed 48 times by 1 test: return (dest-begin); Executed by:
| 48 | ||||||||||||
356 | } | - | ||||||||||||
357 | - | |||||||||||||
358 | typedef int (*StringFormatFunction)(QTestCharBuffer*,char const*,size_t); | - | ||||||||||||
359 | - | |||||||||||||
360 | - | |||||||||||||
361 | - | |||||||||||||
362 | - | |||||||||||||
363 | - | |||||||||||||
364 | int allocateStringFn(QTestCharBuffer* str, char const* src, StringFormatFunction func) | - | ||||||||||||
365 | { | - | ||||||||||||
366 | static const int MAXSIZE = 1024*1024*2; | - | ||||||||||||
367 | - | |||||||||||||
368 | int size = str->size(); | - | ||||||||||||
369 | - | |||||||||||||
370 | int res = 0; | - | ||||||||||||
371 | - | |||||||||||||
372 | for (;;) { | - | ||||||||||||
373 | res = func(str, src, size); | - | ||||||||||||
374 | str->data()[size - 1] = '\0'; | - | ||||||||||||
375 | if (res < size
| 76-175559 | ||||||||||||
376 | - | |||||||||||||
377 | break; executed 175559 times by 1 test: break; Executed by:
| 175559 | ||||||||||||
378 | } | - | ||||||||||||
379 | - | |||||||||||||
380 | size *= 2; | - | ||||||||||||
381 | if (size > MAXSIZE
| 0-76 | ||||||||||||
382 | break; never executed: break; | 0 | ||||||||||||
383 | } | - | ||||||||||||
384 | if (!str->reset(size)
| 0-76 | ||||||||||||
385 | break; never executed: break; | 0 | ||||||||||||
386 | } executed 76 times by 1 test: end of block Executed by:
| 76 | ||||||||||||
387 | - | |||||||||||||
388 | return executed 175559 times by 1 test: res;return res; Executed by:
executed 175559 times by 1 test: return res; Executed by:
| 175559 | ||||||||||||
389 | } | - | ||||||||||||
390 | - | |||||||||||||
391 | int QXmlTestLogger::xmlQuote(QTestCharBuffer* str, char const* src) | - | ||||||||||||
392 | { | - | ||||||||||||
393 | return executed 71041 times by 1 test: allocateStringFn(str, src, QXmlTestLogger::xmlQuote);return allocateStringFn(str, src, QXmlTestLogger::xmlQuote); Executed by:
executed 71041 times by 1 test: return allocateStringFn(str, src, QXmlTestLogger::xmlQuote); Executed by:
| 71041 | ||||||||||||
394 | } | - | ||||||||||||
395 | - | |||||||||||||
396 | int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src) | - | ||||||||||||
397 | { | - | ||||||||||||
398 | return executed 104518 times by 1 test: allocateStringFn(str, src, QXmlTestLogger::xmlCdata);return allocateStringFn(str, src, QXmlTestLogger::xmlCdata); Executed by:
executed 104518 times by 1 test: return allocateStringFn(str, src, QXmlTestLogger::xmlCdata); Executed by:
| 104518 | ||||||||||||
399 | } | - | ||||||||||||
400 | - | |||||||||||||
401 | - | |||||||||||||
Switch to Source code | Preprocessed file |