Stop using QTest::qt_snprintf() in testlib.
After the previous commit, QTest::qt_snprintf() is equivalent to qsnprintf(), so just use that instead. Change-Id: I89ad6e3749ba5efb1926b0b618a904e8baca9f52 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
e179afdbb6
commit
949aaf9a2a
@ -257,7 +257,7 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
|
||||
const char *bmtag = QTest::benchmarkResult2String();
|
||||
|
||||
char buf1[1024];
|
||||
QTest::qt_snprintf(
|
||||
qsnprintf(
|
||||
buf1, sizeof(buf1), "%s: %s::%s",
|
||||
bmtag,
|
||||
QTestResult::currentTestObjectName(),
|
||||
@ -267,16 +267,15 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
|
||||
bufTag[0] = 0;
|
||||
QByteArray tag = result.context.tag.toAscii();
|
||||
if (tag.isEmpty() == false) {
|
||||
QTest::qt_snprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data());
|
||||
qsnprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data());
|
||||
}
|
||||
|
||||
|
||||
char fillFormat[8];
|
||||
int fillLength = 5;
|
||||
QTest::qt_snprintf(
|
||||
fillFormat, sizeof(fillFormat), ":\n%%%ds", fillLength);
|
||||
qsnprintf(fillFormat, sizeof(fillFormat), ":\n%%%ds", fillLength);
|
||||
char fill[1024];
|
||||
QTest::qt_snprintf(fill, sizeof(fill), fillFormat, "");
|
||||
qsnprintf(fill, sizeof(fill), fillFormat, "");
|
||||
|
||||
const char * unitText = QTest::benchmarkMetricUnit(result.metric);
|
||||
|
||||
@ -285,34 +284,24 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
|
||||
QTest::formatResult(resultBuffer, 100, valuePerIteration, QTest::countSignificantDigits(result.value));
|
||||
|
||||
char buf2[1024];
|
||||
QTest::qt_snprintf(
|
||||
buf2, sizeof(buf2), "%s %s",
|
||||
resultBuffer,
|
||||
unitText);
|
||||
qsnprintf(buf2, sizeof(buf2), "%s %s", resultBuffer, unitText);
|
||||
|
||||
char buf2_[1024];
|
||||
QByteArray iterationText = " per iteration";
|
||||
Q_ASSERT(result.iterations > 0);
|
||||
QTest::qt_snprintf(
|
||||
buf2_,
|
||||
sizeof(buf2_), "%s",
|
||||
iterationText.data());
|
||||
qsnprintf(buf2_, sizeof(buf2_), "%s", iterationText.data());
|
||||
|
||||
char buf3[1024];
|
||||
Q_ASSERT(result.iterations > 0);
|
||||
QTest::formatResult(resultBuffer, 100, result.value, QTest::countSignificantDigits(result.value));
|
||||
QTest::qt_snprintf(
|
||||
buf3, sizeof(buf3), " (total: %s, iterations: %d)",
|
||||
resultBuffer,
|
||||
result.iterations);
|
||||
qsnprintf(buf3, sizeof(buf3), " (total: %s, iterations: %d)", resultBuffer, result.iterations);
|
||||
|
||||
char buf[1024];
|
||||
|
||||
if (result.setByMacro) {
|
||||
QTest::qt_snprintf(
|
||||
buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3);
|
||||
qsnprintf(buf, sizeof(buf), "%s%s%s%s%s%s\n", buf1, bufTag, fill, buf2, buf2_, buf3);
|
||||
} else {
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2);
|
||||
qsnprintf(buf, sizeof(buf), "%s%s%s%s\n", buf1, bufTag, fill, buf2);
|
||||
}
|
||||
|
||||
memcpy(buf, bmtag, strlen(bmtag));
|
||||
@ -340,13 +329,12 @@ void QPlainTestLogger::startLogging()
|
||||
|
||||
char buf[1024];
|
||||
if (QTestLog::verboseLevel() < 0) {
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n",
|
||||
QTestResult::currentTestObjectName());
|
||||
qsnprintf(buf, sizeof(buf), "Testing %s\n", QTestResult::currentTestObjectName());
|
||||
} else {
|
||||
QTest::qt_snprintf(buf, sizeof(buf),
|
||||
"********* Start testing of %s *********\n"
|
||||
"Config: Using QTest library " QTEST_VERSION_STR
|
||||
", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
|
||||
qsnprintf(buf, sizeof(buf),
|
||||
"********* Start testing of %s *********\n"
|
||||
"Config: Using QTest library " QTEST_VERSION_STR
|
||||
", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
|
||||
}
|
||||
outputMessage(buf);
|
||||
}
|
||||
@ -355,15 +343,15 @@ void QPlainTestLogger::stopLogging()
|
||||
{
|
||||
char buf[1024];
|
||||
if (QTestLog::verboseLevel() < 0) {
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped\n",
|
||||
QTestResult::passCount(), QTestResult::failCount(),
|
||||
QTestResult::skipCount());
|
||||
qsnprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped\n",
|
||||
QTestResult::passCount(), QTestResult::failCount(),
|
||||
QTestResult::skipCount());
|
||||
} else {
|
||||
QTest::qt_snprintf(buf, sizeof(buf),
|
||||
"Totals: %d passed, %d failed, %d skipped\n"
|
||||
"********* Finished testing of %s *********\n",
|
||||
QTestResult::passCount(), QTestResult::failCount(),
|
||||
QTestResult::skipCount(), QTestResult::currentTestObjectName());
|
||||
qsnprintf(buf, sizeof(buf),
|
||||
"Totals: %d passed, %d failed, %d skipped\n"
|
||||
"********* Finished testing of %s *********\n",
|
||||
QTestResult::passCount(), QTestResult::failCount(),
|
||||
QTestResult::skipCount(), QTestResult::currentTestObjectName());
|
||||
}
|
||||
outputMessage(buf);
|
||||
|
||||
|
@ -195,18 +195,18 @@ inline bool qCompare(QStringList const &t1, QStringList const &t2,
|
||||
msg[0] = '\0';
|
||||
bool isOk = true;
|
||||
if (t1.count() != t2.count()) {
|
||||
qt_snprintf(msg, 1024, "Compared QStringLists have different sizes.\n"
|
||||
" Actual (%s) size : '%d'\n"
|
||||
" Expected (%s) size: '%d'", actual, t1.count(), expected, t2.count());
|
||||
qsnprintf(msg, 1024, "Compared QStringLists have different sizes.\n"
|
||||
" Actual (%s) size : '%d'\n"
|
||||
" Expected (%s) size: '%d'", actual, t1.count(), expected, t2.count());
|
||||
isOk = false;
|
||||
}
|
||||
const int min = qMin(t1.count(), t2.count());
|
||||
for (int i = 0; isOk && i < min; ++i) {
|
||||
if (t1.at(i) != t2.at(i)) {
|
||||
qt_snprintf(msg, 1024, "Compared QStringLists differ at index %d.\n"
|
||||
" Actual (%s) : '%s'\n"
|
||||
" Expected (%s) : '%s'", i, actual, t1.at(i).toLatin1().constData(),
|
||||
expected, t2.at(i).toLatin1().constData());
|
||||
qsnprintf(msg, 1024, "Compared QStringLists differ at index %d.\n"
|
||||
" Actual (%s) : '%s'\n"
|
||||
" Expected (%s) : '%s'", i, actual, t1.at(i).toLatin1().constData(),
|
||||
expected, t2.at(i).toLatin1().constData());
|
||||
isOk = false;
|
||||
}
|
||||
}
|
||||
|
@ -1106,7 +1106,7 @@ static void qPrintDataTags(FILE *stream)
|
||||
slot[strlen(slot) - 2] = '\0';
|
||||
QByteArray member;
|
||||
member.resize(qstrlen(slot) + qstrlen("_data()") + 1);
|
||||
QTest::qt_snprintf(member.data(), member.size(), "%s_data()", slot);
|
||||
qsnprintf(member.data(), member.size(), "%s_data()", slot);
|
||||
invokeMethod(QTest::currentTestObject, member.constData());
|
||||
for (int j = 0; j < table.dataCount(); ++j)
|
||||
localTags << QLatin1String(table.testData(j)->dataTag());
|
||||
@ -1436,8 +1436,8 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
||||
if (colon != -1) {
|
||||
data = qstrdup(argv[i]+colon+1);
|
||||
}
|
||||
QTest::qt_snprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf
|
||||
QTest::qt_snprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
|
||||
qsnprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf
|
||||
qsnprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
|
||||
int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
|
||||
if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) {
|
||||
fprintf(stderr, "Unknown testfunction: '%s'\n", buf);
|
||||
@ -1589,7 +1589,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
|
||||
|
||||
if (curGlobalDataIndex == 0) {
|
||||
QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
|
||||
QTest::qt_snprintf(member, 512, "%s_data()", slot);
|
||||
qsnprintf(member, 512, "%s_data()", slot);
|
||||
invokeMethod(QTest::currentTestObject, member);
|
||||
}
|
||||
|
||||
@ -2374,7 +2374,7 @@ Q_TESTLIB_EXPORT bool QTest::qCompare<double>(double const &t1, double const &t2
|
||||
template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE >(const TYPE &t) \
|
||||
{ \
|
||||
char *msg = new char[128]; \
|
||||
qt_snprintf(msg, 128, #FORMAT, t); \
|
||||
qsnprintf(msg, 128, #FORMAT, t); \
|
||||
return msg; \
|
||||
}
|
||||
|
||||
@ -2411,7 +2411,7 @@ char *QTest::toString(const char *str)
|
||||
char *QTest::toString(const void *p)
|
||||
{
|
||||
char *msg = new char[128];
|
||||
qt_snprintf(msg, 128, "%p", p);
|
||||
qsnprintf(msg, 128, "%p", p);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ void QTestLog::printUnhandledIgnoreMessages()
|
||||
char msg[1024];
|
||||
QTest::IgnoreResultList *list = QTest::ignoreResultList;
|
||||
while (list) {
|
||||
QTest::qt_snprintf(msg, 1024, "Did not receive message: \"%s\"", list->msg);
|
||||
qsnprintf(msg, 1024, "Did not receive message: \"%s\"", list->msg);
|
||||
QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, msg);
|
||||
|
||||
list = list->next;
|
||||
|
@ -239,11 +239,11 @@ bool QTestResult::verify(bool statement, const char *statementStr,
|
||||
char msg[1024];
|
||||
|
||||
if (QTestLog::verboseLevel() >= 2) {
|
||||
QTest::qt_snprintf(msg, 1024, "QVERIFY(%s)", statementStr);
|
||||
qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
|
||||
QTestLog::info(msg, file, line);
|
||||
}
|
||||
|
||||
QTest::qt_snprintf(msg, 1024, "'%s' returned FALSE. (%s)", statementStr, description);
|
||||
qsnprintf(msg, 1024, "'%s' returned FALSE. (%s)", statementStr, description);
|
||||
|
||||
return checkStatement(statement, msg, file, line);
|
||||
}
|
||||
@ -267,9 +267,9 @@ bool QTestResult::compare(bool success, const char *msg, char *val1, char *val2,
|
||||
return compare(success, msg, file, line);
|
||||
|
||||
char buf[1024];
|
||||
QTest::qt_snprintf(buf, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s", msg,
|
||||
actual, val1 ? val1 : "<null>",
|
||||
expected, val2 ? val2 : "<null>");
|
||||
qsnprintf(buf, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s", msg,
|
||||
actual, val1 ? val1 : "<null>",
|
||||
expected, val2 ? val2 : "<null>");
|
||||
delete [] val1;
|
||||
delete [] val2;
|
||||
return compare(success, buf, file, line);
|
||||
|
@ -251,7 +251,7 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
||||
QTest::benchmarkResultFormatString(),
|
||||
quotedMetric.constData(),
|
||||
quotedTag.constData(),
|
||||
QByteArray::number(result.value).constData(), //no 64-bit qt_snprintf support
|
||||
QByteArray::number(result.value).constData(), //no 64-bit qsnprintf support
|
||||
result.iterations);
|
||||
outputString(buf.constData());
|
||||
}
|
||||
|
@ -86,13 +86,13 @@ void QXunitTestLogger::stopLogging()
|
||||
currentLogElement = new QTestElement(QTest::LET_TestSuite);
|
||||
currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName());
|
||||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter);
|
||||
qsnprintf(buf, sizeof(buf), "%i", testCounter);
|
||||
currentLogElement->addAttribute(QTest::AI_Tests, buf);
|
||||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter);
|
||||
qsnprintf(buf, sizeof(buf), "%i", failureCounter);
|
||||
currentLogElement->addAttribute(QTest::AI_Failures, buf);
|
||||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
|
||||
qsnprintf(buf, sizeof(buf), "%i", errorCounter);
|
||||
currentLogElement->addAttribute(QTest::AI_Errors, buf);
|
||||
|
||||
QTestElement *property;
|
||||
@ -173,7 +173,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
|
||||
failureElement->addAttribute(QTest::AI_File, file);
|
||||
else
|
||||
failureElement->addAttribute(QTest::AI_File, "");
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
|
||||
qsnprintf(buf, sizeof(buf), "%i", line);
|
||||
failureElement->addAttribute(QTest::AI_Line, buf);
|
||||
failureElement->addAttribute(QTest::AI_Description, description);
|
||||
addTag(failureElement);
|
||||
@ -212,7 +212,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
|
||||
else
|
||||
currentLogElement->addAttribute(QTest::AI_File, "");
|
||||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
|
||||
qsnprintf(buf, sizeof(buf), "%i", line);
|
||||
currentLogElement->addAttribute(QTest::AI_Line, buf);
|
||||
|
||||
/*
|
||||
@ -235,7 +235,7 @@ void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
||||
benchmarkElement->addAttribute(QTest::AI_Value, QByteArray::number(result.value).constData());
|
||||
|
||||
char buf[100];
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", result.iterations);
|
||||
qsnprintf(buf, sizeof(buf), "%i", result.iterations);
|
||||
benchmarkElement->addAttribute(QTest::AI_Iterations, buf);
|
||||
currentLogElement->addLogElement(benchmarkElement);
|
||||
}
|
||||
@ -303,7 +303,7 @@ void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const
|
||||
errorElement->addAttribute(QTest::AI_File, "");
|
||||
|
||||
char buf[100];
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
|
||||
qsnprintf(buf, sizeof(buf), "%i", line);
|
||||
errorElement->addAttribute(QTest::AI_Line, buf);
|
||||
|
||||
currentLogElement->addLogElement(errorElement);
|
||||
|
Loading…
x
Reference in New Issue
Block a user