Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtTest module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include <QtTest/private/qtestresult_p.h> | - |
43 | #include <QtTest/qtestassert.h> | - |
44 | #include <QtTest/private/qtestlog_p.h> | - |
45 | #include <QtTest/private/qplaintestlogger_p.h> | - |
46 | #include <QtTest/private/qbenchmark_p.h> | - |
47 | #include <QtTest/private/qbenchmarkmetric_p.h> | - |
48 | | - |
49 | #include <stdarg.h> | - |
50 | #include <stdio.h> | - |
51 | #include <stdlib.h> | - |
52 | #include <string.h> | - |
53 | | - |
54 | #ifdef Q_OS_WIN | - |
55 | #include <windows.h> | - |
56 | #endif | - |
57 | | - |
58 | #ifdef Q_OS_WINCE | - |
59 | #include <QtCore/QString> | - |
60 | #endif | - |
61 | | - |
62 | #include <QtCore/QByteArray> | - |
63 | #include <QtCore/qmath.h> | - |
64 | | - |
65 | QT_BEGIN_NAMESPACE | - |
66 | | - |
67 | namespace QTest { | - |
68 | | - |
69 | static const char *incidentType2String(QAbstractTestLogger::IncidentTypes type) | - |
70 | { | - |
71 | switch (type) { | - |
72 | case QAbstractTestLogger::Pass: | - |
73 | return "PASS "; executed: return "PASS "; Execution Count:66746 | 66746 |
74 | case QAbstractTestLogger::XFail: | - |
75 | return "XFAIL "; executed: return "XFAIL "; Execution Count:339 | 339 |
76 | case QAbstractTestLogger::Fail: | - |
77 | return "FAIL! "; executed: return "FAIL! "; Execution Count:237 | 237 |
78 | case QAbstractTestLogger::XPass: | - |
79 | return "XPASS "; never executed: return "XPASS "; | 0 |
80 | } | - |
81 | return "??????"; never executed: return "??????"; | 0 |
82 | } | - |
83 | | - |
84 | static const char *benchmarkResult2String() | - |
85 | { | - |
86 | return "RESULT "; executed: return "RESULT "; Execution Count:8 | 8 |
87 | } | - |
88 | | - |
89 | static const char *messageType2String(QAbstractTestLogger::MessageTypes type) | - |
90 | { | - |
91 | switch (type) { | - |
92 | case QAbstractTestLogger::Skip: | - |
93 | return "SKIP "; executed: return "SKIP "; Execution Count:315 | 315 |
94 | case QAbstractTestLogger::Warn: | - |
95 | return "WARNING"; executed: return "WARNING"; Execution Count:8 | 8 |
96 | case QAbstractTestLogger::QWarning: | - |
97 | return "QWARN "; executed: return "QWARN "; Execution Count:445 | 445 |
98 | case QAbstractTestLogger::QDebug: | - |
99 | return "QDEBUG "; executed: return "QDEBUG "; Execution Count:1076 | 1076 |
100 | case QAbstractTestLogger::QSystem: | - |
101 | return "QSYSTEM"; never executed: return "QSYSTEM"; | 0 |
102 | case QAbstractTestLogger::QFatal: | - |
103 | return "QFATAL "; executed: return "QFATAL "; Execution Count:5 | 5 |
104 | case QAbstractTestLogger::Info: | - |
105 | return "INFO "; never executed: return "INFO "; | 0 |
106 | } | - |
107 | return "??????"; never executed: return "??????"; | 0 |
108 | } | - |
109 | | - |
110 | template <typename T> | - |
111 | static int countSignificantDigits(T num) | - |
112 | { | - |
113 | if (num <= 0) evaluated: num <= 0 yes Evaluation Count:10 | yes Evaluation Count:6 |
| 6-10 |
114 | return 0; executed: return 0; Execution Count:10 | 10 |
115 | | - |
116 | int digits = 0; executed (the execution status of this line is deduced): int digits = 0; | - |
117 | qreal divisor = 1; executed (the execution status of this line is deduced): qreal divisor = 1; | - |
118 | | - |
119 | while (num / divisor >= 1) { evaluated: num / divisor >= 1 yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
120 | divisor *= 10; executed (the execution status of this line is deduced): divisor *= 10; | - |
121 | ++digits; executed (the execution status of this line is deduced): ++digits; | - |
122 | } executed: } Execution Count:6 | 6 |
123 | | - |
124 | return digits; executed: return digits; Execution Count:6 | 6 |
125 | } | - |
126 | | - |
127 | // Pretty-prints a benchmark result using the given number of digits. | - |
128 | template <typename T> QString formatResult(T number, int significantDigits) | - |
129 | { | - |
130 | if (number < T(0)) partially evaluated: number < T(0) no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
131 | return QLatin1String("NAN"); never executed: return QLatin1String("NAN"); | 0 |
132 | if (number == T(0)) evaluated: number == T(0) yes Evaluation Count:10 | yes Evaluation Count:6 |
| 6-10 |
133 | return QLatin1String("0"); executed: return QLatin1String("0"); Execution Count:10 | 10 |
134 | | - |
135 | QString beforeDecimalPoint = QString::number(qint64(number), 'f', 0); executed (the execution status of this line is deduced): QString beforeDecimalPoint = QString::number(qint64(number), 'f', 0); | - |
136 | QString afterDecimalPoint = QString::number(number, 'f', 20); executed (the execution status of this line is deduced): QString afterDecimalPoint = QString::number(number, 'f', 20); | - |
137 | afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1); executed (the execution status of this line is deduced): afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1); | - |
138 | | - |
139 | int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits); executed (the execution status of this line is deduced): int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits); | - |
140 | int beforeRemove = beforeDecimalPoint.count() - beforeUse; executed (the execution status of this line is deduced): int beforeRemove = beforeDecimalPoint.count() - beforeUse; | - |
141 | | - |
142 | // Replace insignificant digits before the decimal point with zeros. | - |
143 | beforeDecimalPoint.chop(beforeRemove); executed (the execution status of this line is deduced): beforeDecimalPoint.chop(beforeRemove); | - |
144 | for (int i = 0; i < beforeRemove; ++i) { partially evaluated: i < beforeRemove no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
145 | beforeDecimalPoint.append(QLatin1Char('0')); never executed (the execution status of this line is deduced): beforeDecimalPoint.append(QLatin1Char('0')); | - |
146 | } | 0 |
147 | | - |
148 | int afterUse = significantDigits - beforeUse; executed (the execution status of this line is deduced): int afterUse = significantDigits - beforeUse; | - |
149 | | - |
150 | // leading zeroes after the decimal point does not count towards the digit use. | - |
151 | if (beforeDecimalPoint == QLatin1String("0") && afterDecimalPoint.isEmpty() == false) { partially evaluated: beforeDecimalPoint == QLatin1String("0") no Evaluation Count:0 | yes Evaluation Count:6 |
never evaluated: afterDecimalPoint.isEmpty() == false | 0-6 |
152 | ++afterUse; never executed (the execution status of this line is deduced): ++afterUse; | - |
153 | | - |
154 | int i = 0; never executed (the execution status of this line is deduced): int i = 0; | - |
155 | while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0')) { never evaluated: i < afterDecimalPoint.count() never evaluated: afterDecimalPoint.at(i) == QLatin1Char('0') | 0 |
156 | ++i; never executed (the execution status of this line is deduced): ++i; | - |
157 | } | 0 |
158 | | - |
159 | afterUse += i; never executed (the execution status of this line is deduced): afterUse += i; | - |
160 | } | 0 |
161 | | - |
162 | int afterRemove = afterDecimalPoint.count() - afterUse; executed (the execution status of this line is deduced): int afterRemove = afterDecimalPoint.count() - afterUse; | - |
163 | afterDecimalPoint.chop(afterRemove); executed (the execution status of this line is deduced): afterDecimalPoint.chop(afterRemove); | - |
164 | | - |
165 | QChar separator = QLatin1Char(','); executed (the execution status of this line is deduced): QChar separator = QLatin1Char(','); | - |
166 | QChar decimalPoint = QLatin1Char('.'); executed (the execution status of this line is deduced): QChar decimalPoint = QLatin1Char('.'); | - |
167 | | - |
168 | // insert thousands separators | - |
169 | int length = beforeDecimalPoint.length(); executed (the execution status of this line is deduced): int length = beforeDecimalPoint.length(); | - |
170 | for (int i = beforeDecimalPoint.length() -1; i >= 1; --i) { partially evaluated: i >= 1 no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
171 | if ((length - i) % 3 == 0) never evaluated: (length - i) % 3 == 0 | 0 |
172 | beforeDecimalPoint.insert(i, separator); never executed: beforeDecimalPoint.insert(i, separator); | 0 |
173 | } | 0 |
174 | | - |
175 | QString print; executed (the execution status of this line is deduced): QString print; | - |
176 | print = beforeDecimalPoint; executed (the execution status of this line is deduced): print = beforeDecimalPoint; | - |
177 | if (afterUse > 0) partially evaluated: afterUse > 0 no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
178 | print.append(decimalPoint); never executed: print.append(decimalPoint); | 0 |
179 | | - |
180 | print += afterDecimalPoint; executed (the execution status of this line is deduced): print += afterDecimalPoint; | - |
181 | | - |
182 | | - |
183 | return print; executed: return print; Execution Count:6 | 6 |
184 | } | - |
185 | | - |
186 | template <typename T> | - |
187 | int formatResult(char * buffer, int bufferSize, T number, int significantDigits) | - |
188 | { | - |
189 | QString result = formatResult(number, significantDigits); executed (the execution status of this line is deduced): QString result = formatResult(number, significantDigits); | - |
190 | qstrncpy(buffer, result.toLatin1().constData(), bufferSize); executed (the execution status of this line is deduced): qstrncpy(buffer, result.toLatin1().constData(), bufferSize); | - |
191 | int size = result.count(); executed (the execution status of this line is deduced): int size = result.count(); | - |
192 | return size; executed: return size; Execution Count:16 | 16 |
193 | } | - |
194 | } | - |
195 | | - |
196 | void QPlainTestLogger::outputMessage(const char *str) | - |
197 | { | - |
198 | #if defined(Q_OS_WINCE) | - |
199 | QString strUtf16 = QString::fromLatin1(str); | - |
200 | const int maxOutputLength = 255; | - |
201 | do { | - |
202 | QString tmp = strUtf16.left(maxOutputLength); | - |
203 | OutputDebugString((wchar_t*)tmp.utf16()); | - |
204 | strUtf16.remove(0, maxOutputLength); | - |
205 | } while (!strUtf16.isEmpty()); | - |
206 | if (stream != stdout) | - |
207 | #elif defined(Q_OS_WIN) | - |
208 | OutputDebugStringA(str); | - |
209 | #endif | - |
210 | outputString(str); executed (the execution status of this line is deduced): outputString(str); | - |
211 | } executed: } Execution Count:69974 | 69974 |
212 | | - |
213 | void QPlainTestLogger::printMessage(const char *type, const char *msg, const char *file, int line) | - |
214 | { | - |
215 | QTEST_ASSERT(type); never executed: qt_assert("type","qplaintestlogger.cpp",215); executed: } Execution Count:69171 partially evaluated: !(type) no Evaluation Count:0 | yes Evaluation Count:69171 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:69171 |
| 0-69171 |
216 | QTEST_ASSERT(msg); never executed: qt_assert("msg","qplaintestlogger.cpp",216); executed: } Execution Count:69171 partially evaluated: !(msg) no Evaluation Count:0 | yes Evaluation Count:69171 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:69171 |
| 0-69171 |
217 | | - |
218 | QTestCharBuffer buf; executed (the execution status of this line is deduced): QTestCharBuffer buf; | - |
219 | | - |
220 | const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() partially evaluated: QTestResult::currentTestFunction() yes Evaluation Count:69171 | no Evaluation Count:0 |
| 0-69171 |
221 | : "UnknownTestFunc"; executed (the execution status of this line is deduced): : "UnknownTestFunc"; | - |
222 | const char *tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : ""; evaluated: QTestResult::currentDataTag() yes Evaluation Count:62195 | yes Evaluation Count:6976 |
| 6976-62195 |
223 | const char *gtag = QTestResult::currentGlobalDataTag() evaluated: QTestResult::currentGlobalDataTag() yes Evaluation Count:804 | yes Evaluation Count:68367 |
| 804-68367 |
224 | ? QTestResult::currentGlobalDataTag() executed (the execution status of this line is deduced): ? QTestResult::currentGlobalDataTag() | - |
225 | : ""; executed (the execution status of this line is deduced): : ""; | - |
226 | const char *filler = (tag[0] && gtag[0]) ? ":" : ""; evaluated: tag[0] yes Evaluation Count:62180 | yes Evaluation Count:6991 |
evaluated: gtag[0] yes Evaluation Count:700 | yes Evaluation Count:61480 |
| 700-62180 |
227 | if (file) { evaluated: file yes Evaluation Count:895 | yes Evaluation Count:68276 |
| 895-68276 |
228 | QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n" executed (the execution status of this line is deduced): QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n" | - |
229 | #ifdef Q_OS_WIN executed (the execution status of this line is deduced):
| - |
230 | "%s(%d) : failure location\n" executed (the execution status of this line is deduced):
| - |
231 | #else executed (the execution status of this line is deduced):
| - |
232 | " Loc: [%s(%d)]\n" executed (the execution status of this line is deduced): " Loc: [%s(%d)]\n" | - |
233 | #endif executed (the execution status of this line is deduced):
| - |
234 | , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, executed (the execution status of this line is deduced): , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, | - |
235 | msg[0] ? " " : "", msg, file, line); executed (the execution status of this line is deduced): msg[0] ? " " : "", msg, file, line); | - |
236 | } else { executed: } Execution Count:895 | 895 |
237 | QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n", executed (the execution status of this line is deduced): QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n", | - |
238 | type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, executed (the execution status of this line is deduced): type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, | - |
239 | msg[0] ? " " : "", msg); executed (the execution status of this line is deduced): msg[0] ? " " : "", msg); | - |
240 | } executed: } Execution Count:68276 | 68276 |
241 | // In colored mode, printf above stripped our nonprintable control characters. | - |
242 | // Put them back. | - |
243 | memcpy(buf.data(), type, strlen(type)); executed (the execution status of this line is deduced): memcpy(buf.data(), type, strlen(type)); | - |
244 | outputMessage(buf.data()); executed (the execution status of this line is deduced): outputMessage(buf.data()); | - |
245 | } executed: } Execution Count:69171 | 69171 |
246 | | - |
247 | void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result) | - |
248 | { | - |
249 | const char *bmtag = QTest::benchmarkResult2String(); executed (the execution status of this line is deduced): const char *bmtag = QTest::benchmarkResult2String(); | - |
250 | | - |
251 | char buf1[1024]; executed (the execution status of this line is deduced): char buf1[1024]; | - |
252 | qsnprintf( executed (the execution status of this line is deduced): qsnprintf( | - |
253 | buf1, sizeof(buf1), "%s: %s::%s", executed (the execution status of this line is deduced): buf1, sizeof(buf1), "%s: %s::%s", | - |
254 | bmtag, executed (the execution status of this line is deduced): bmtag, | - |
255 | QTestResult::currentTestObjectName(), executed (the execution status of this line is deduced): QTestResult::currentTestObjectName(), | - |
256 | result.context.slotName.toLatin1().data()); executed (the execution status of this line is deduced): result.context.slotName.toLatin1().data()); | - |
257 | | - |
258 | char bufTag[1024]; executed (the execution status of this line is deduced): char bufTag[1024]; | - |
259 | bufTag[0] = 0; executed (the execution status of this line is deduced): bufTag[0] = 0; | - |
260 | QByteArray tag = result.context.tag.toLocal8Bit(); executed (the execution status of this line is deduced): QByteArray tag = result.context.tag.toLocal8Bit(); | - |
261 | if (tag.isEmpty() == false) { partially evaluated: tag.isEmpty() == false yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
262 | qsnprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data()); executed (the execution status of this line is deduced): qsnprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data()); | - |
263 | } executed: } Execution Count:8 | 8 |
264 | | - |
265 | | - |
266 | char fillFormat[8]; executed (the execution status of this line is deduced): char fillFormat[8]; | - |
267 | int fillLength = 5; executed (the execution status of this line is deduced): int fillLength = 5; | - |
268 | qsnprintf(fillFormat, sizeof(fillFormat), ":\n%%%ds", fillLength); executed (the execution status of this line is deduced): qsnprintf(fillFormat, sizeof(fillFormat), ":\n%%%ds", fillLength); | - |
269 | char fill[1024]; executed (the execution status of this line is deduced): char fill[1024]; | - |
270 | qsnprintf(fill, sizeof(fill), fillFormat, ""); executed (the execution status of this line is deduced): qsnprintf(fill, sizeof(fill), fillFormat, ""); | - |
271 | | - |
272 | const char * unitText = QTest::benchmarkMetricUnit(result.metric); executed (the execution status of this line is deduced): const char * unitText = QTest::benchmarkMetricUnit(result.metric); | - |
273 | | - |
274 | qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); executed (the execution status of this line is deduced): qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); | - |
275 | char resultBuffer[100] = ""; executed (the execution status of this line is deduced): char resultBuffer[100] = ""; | - |
276 | QTest::formatResult(resultBuffer, 100, valuePerIteration, QTest::countSignificantDigits(result.value)); executed (the execution status of this line is deduced): QTest::formatResult(resultBuffer, 100, valuePerIteration, QTest::countSignificantDigits(result.value)); | - |
277 | | - |
278 | char buf2[1024]; executed (the execution status of this line is deduced): char buf2[1024]; | - |
279 | qsnprintf(buf2, sizeof(buf2), "%s %s", resultBuffer, unitText); executed (the execution status of this line is deduced): qsnprintf(buf2, sizeof(buf2), "%s %s", resultBuffer, unitText); | - |
280 | | - |
281 | char buf2_[1024]; executed (the execution status of this line is deduced): char buf2_[1024]; | - |
282 | QByteArray iterationText = " per iteration"; executed (the execution status of this line is deduced): QByteArray iterationText = " per iteration"; | - |
283 | Q_ASSERT(result.iterations > 0); executed (the execution status of this line is deduced): qt_noop(); | - |
284 | qsnprintf(buf2_, sizeof(buf2_), "%s", iterationText.data()); executed (the execution status of this line is deduced): qsnprintf(buf2_, sizeof(buf2_), "%s", iterationText.data()); | - |
285 | | - |
286 | char buf3[1024]; executed (the execution status of this line is deduced): char buf3[1024]; | - |
287 | Q_ASSERT(result.iterations > 0); executed (the execution status of this line is deduced): qt_noop(); | - |
288 | QTest::formatResult(resultBuffer, 100, result.value, QTest::countSignificantDigits(result.value)); executed (the execution status of this line is deduced): QTest::formatResult(resultBuffer, 100, result.value, QTest::countSignificantDigits(result.value)); | - |
289 | qsnprintf(buf3, sizeof(buf3), " (total: %s, iterations: %d)", resultBuffer, result.iterations); executed (the execution status of this line is deduced): qsnprintf(buf3, sizeof(buf3), " (total: %s, iterations: %d)", resultBuffer, result.iterations); | - |
290 | | - |
291 | char buf[1024]; executed (the execution status of this line is deduced): char buf[1024]; | - |
292 | | - |
293 | if (result.setByMacro) { partially evaluated: result.setByMacro yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
294 | qsnprintf(buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3); executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3); | - |
295 | } else { executed: } Execution Count:8 | 8 |
296 | qsnprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2); never executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2); | - |
297 | } | 0 |
298 | | - |
299 | memcpy(buf, bmtag, strlen(bmtag)); executed (the execution status of this line is deduced): memcpy(buf, bmtag, strlen(bmtag)); | - |
300 | outputMessage(buf); executed (the execution status of this line is deduced): outputMessage(buf); | - |
301 | } executed: } Execution Count:8 | 8 |
302 | | - |
303 | QPlainTestLogger::QPlainTestLogger(const char *filename) | - |
304 | : QAbstractTestLogger(filename) | - |
305 | { | - |
306 | } executed: } Execution Count:399 | 399 |
307 | | - |
308 | QPlainTestLogger::~QPlainTestLogger() | - |
309 | { | - |
310 | } | - |
311 | | - |
312 | void QPlainTestLogger::startLogging() | - |
313 | { | - |
314 | QAbstractTestLogger::startLogging(); executed (the execution status of this line is deduced): QAbstractTestLogger::startLogging(); | - |
315 | | - |
316 | char buf[1024]; executed (the execution status of this line is deduced): char buf[1024]; | - |
317 | if (QTestLog::verboseLevel() < 0) { partially evaluated: QTestLog::verboseLevel() < 0 no Evaluation Count:0 | yes Evaluation Count:399 |
| 0-399 |
318 | qsnprintf(buf, sizeof(buf), "Testing %s\n", QTestResult::currentTestObjectName()); never executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), "Testing %s\n", QTestResult::currentTestObjectName()); | - |
319 | } else { | 0 |
320 | qsnprintf(buf, sizeof(buf), executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), | - |
321 | "********* Start testing of %s *********\n" executed (the execution status of this line is deduced): "********* Start testing of %s *********\n" | - |
322 | "Config: Using QTest library " QTEST_VERSION_STR executed (the execution status of this line is deduced): "Config: Using QTest library " "5.0.2" | - |
323 | ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); executed (the execution status of this line is deduced): ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); | - |
324 | } executed: } Execution Count:399 | 399 |
325 | outputMessage(buf); executed (the execution status of this line is deduced): outputMessage(buf); | - |
326 | } executed: } Execution Count:399 | 399 |
327 | | - |
328 | void QPlainTestLogger::stopLogging() | - |
329 | { | - |
330 | char buf[1024]; executed (the execution status of this line is deduced): char buf[1024]; | - |
331 | if (QTestLog::verboseLevel() < 0) { partially evaluated: QTestLog::verboseLevel() < 0 no Evaluation Count:0 | yes Evaluation Count:396 |
| 0-396 |
332 | qsnprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped\n", never executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped\n", | - |
333 | QTestLog::passCount(), QTestLog::failCount(), never executed (the execution status of this line is deduced): QTestLog::passCount(), QTestLog::failCount(), | - |
334 | QTestLog::skipCount()); never executed (the execution status of this line is deduced): QTestLog::skipCount()); | - |
335 | } else { | 0 |
336 | qsnprintf(buf, sizeof(buf), executed (the execution status of this line is deduced): qsnprintf(buf, sizeof(buf), | - |
337 | "Totals: %d passed, %d failed, %d skipped\n" executed (the execution status of this line is deduced): "Totals: %d passed, %d failed, %d skipped\n" | - |
338 | "********* Finished testing of %s *********\n", executed (the execution status of this line is deduced): "********* Finished testing of %s *********\n", | - |
339 | QTestLog::passCount(), QTestLog::failCount(), executed (the execution status of this line is deduced): QTestLog::passCount(), QTestLog::failCount(), | - |
340 | QTestLog::skipCount(), QTestResult::currentTestObjectName()); executed (the execution status of this line is deduced): QTestLog::skipCount(), QTestResult::currentTestObjectName()); | - |
341 | } executed: } Execution Count:396 | 396 |
342 | outputMessage(buf); executed (the execution status of this line is deduced): outputMessage(buf); | - |
343 | | - |
344 | QAbstractTestLogger::stopLogging(); executed (the execution status of this line is deduced): QAbstractTestLogger::stopLogging(); | - |
345 | } executed: } Execution Count:396 | 396 |
346 | | - |
347 | | - |
348 | void QPlainTestLogger::enterTestFunction(const char * /*function*/) | - |
349 | { | - |
350 | if (QTestLog::verboseLevel() >= 1) partially evaluated: QTestLog::verboseLevel() >= 1 no Evaluation Count:0 | yes Evaluation Count:7610 |
| 0-7610 |
351 | printMessage(QTest::messageType2String(Info), "entering"); never executed: printMessage(QTest::messageType2String(Info), "entering"); | 0 |
352 | } executed: } Execution Count:7610 | 7610 |
353 | | - |
354 | void QPlainTestLogger::leaveTestFunction() | - |
355 | { | - |
356 | } | - |
357 | | - |
358 | void QPlainTestLogger::addIncident(IncidentTypes type, const char *description, | - |
359 | const char *file, int line) | - |
360 | { | - |
361 | // suppress PASS and XFAIL in silent mode | - |
362 | if ((type == QAbstractTestLogger::Pass || type == QAbstractTestLogger::XFail) evaluated: type == QAbstractTestLogger::Pass yes Evaluation Count:66746 | yes Evaluation Count:576 |
evaluated: type == QAbstractTestLogger::XFail yes Evaluation Count:339 | yes Evaluation Count:237 |
| 237-66746 |
363 | && QTestLog::verboseLevel() < 0) partially evaluated: QTestLog::verboseLevel() < 0 no Evaluation Count:0 | yes Evaluation Count:67085 |
| 0-67085 |
364 | return; | 0 |
365 | | - |
366 | printMessage(QTest::incidentType2String(type), description, file, line); executed (the execution status of this line is deduced): printMessage(QTest::incidentType2String(type), description, file, line); | - |
367 | } executed: } Execution Count:67322 | 67322 |
368 | | - |
369 | void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result) | - |
370 | { | - |
371 | // suppress benchmark results in silent mode | - |
372 | if (QTestLog::verboseLevel() < 0) partially evaluated: QTestLog::verboseLevel() < 0 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
373 | return; | 0 |
374 | | - |
375 | printBenchmarkResult(result); executed (the execution status of this line is deduced): printBenchmarkResult(result); | - |
376 | } executed: } Execution Count:8 | 8 |
377 | | - |
378 | void QPlainTestLogger::addMessage(MessageTypes type, const char *message, | - |
379 | const char *file, int line) | - |
380 | { | - |
381 | // suppress non-fatal messages in silent mode | - |
382 | if (type != QAbstractTestLogger::QFatal && QTestLog::verboseLevel() < 0) evaluated: type != QAbstractTestLogger::QFatal yes Evaluation Count:1844 | yes Evaluation Count:5 |
partially evaluated: QTestLog::verboseLevel() < 0 no Evaluation Count:0 | yes Evaluation Count:1844 |
| 0-1844 |
383 | return; | 0 |
384 | | - |
385 | printMessage(QTest::messageType2String(type), message, file, line); executed (the execution status of this line is deduced): printMessage(QTest::messageType2String(type), message, file, line); | - |
386 | } executed: } Execution Count:1849 | 1849 |
387 | | - |
388 | QT_END_NAMESPACE | - |
389 | | - |
| | |