QTestLib: Introduce nullptr
Apply Fixits by Qt Creator with some amendments. Task-number: QTBUG-69413 Change-Id: I620e40a277dc2b20b0ec26fc32577e66b0456bb3 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
parent
2d8d738657
commit
225dd568af
@ -87,7 +87,7 @@ QAbstractTestLogger::~QAbstractTestLogger()
|
||||
if (stream != stdout) {
|
||||
fclose(stream);
|
||||
}
|
||||
stream = 0;
|
||||
stream = nullptr;
|
||||
}
|
||||
|
||||
void QAbstractTestLogger::filterUnprintable(char *str) const
|
||||
|
@ -73,7 +73,7 @@ void QBenchmarkGlobalData::setMode(Mode mode)
|
||||
|
||||
QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()
|
||||
{
|
||||
QBenchmarkMeasurerBase *measurer = 0;
|
||||
QBenchmarkMeasurerBase *measurer = nullptr;
|
||||
if (0) {
|
||||
#if QT_CONFIG(valgrind)
|
||||
} else if (mode_ == CallgrindChildProcess || mode_ == CallgrindParentProcess) {
|
||||
@ -112,7 +112,7 @@ QBenchmarkTestMethodData::QBenchmarkTestMethodData() = default;
|
||||
|
||||
QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
|
||||
{
|
||||
QBenchmarkTestMethodData::current = 0;
|
||||
QBenchmarkTestMethodData::current = nullptr;
|
||||
}
|
||||
|
||||
void QBenchmarkTestMethodData::beginDataRun()
|
||||
|
@ -147,7 +147,7 @@ bool QBenchmarkPerfEventsMeasurer::isAvailable()
|
||||
{
|
||||
// this generates an EFAULT because attr == NULL if perf_event_open is available
|
||||
// if the kernel is too old, it generates ENOSYS
|
||||
return perf_event_open(0, 0, 0, 0, 0) == -1 && errno != ENOSYS;
|
||||
return perf_event_open(nullptr, 0, 0, 0, 0) == -1 && errno != ENOSYS;
|
||||
}
|
||||
|
||||
/* Event list structure
|
||||
|
@ -56,7 +56,7 @@ namespace QTest
|
||||
|
||||
inline static void qPrintMessage(const QByteArray &ba)
|
||||
{
|
||||
QTestLog::info(ba.constData(), 0, 0);
|
||||
QTestLog::info(ba.constData(), nullptr, 0);
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QList<QByteArray>, ignoreClasses)
|
||||
@ -169,7 +169,7 @@ static void qSignalDumperCallbackEndSignal(QObject *caller, int /*signal_index*/
|
||||
void QSignalDumper::startDump()
|
||||
{
|
||||
static QSignalSpyCallbackSet set = { QTest::qSignalDumperCallback,
|
||||
QTest::qSignalDumperCallbackSlot, QTest::qSignalDumperCallbackEndSignal, 0 };
|
||||
QTest::qSignalDumperCallbackSlot, QTest::qSignalDumperCallbackEndSignal, nullptr };
|
||||
qt_register_signal_spy_callbacks(&set);
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ static bool checkCondition(const QByteArray &condition)
|
||||
}
|
||||
|
||||
static bool ignoreAll = false;
|
||||
static std::set<QByteArray> *ignoredTests = 0;
|
||||
static std::set<QByteArray> *ignoredTests = nullptr;
|
||||
|
||||
namespace QTestPrivate {
|
||||
|
||||
|
@ -289,7 +289,7 @@ namespace QTest
|
||||
{
|
||||
class WatchDog;
|
||||
|
||||
static QObject *currentTestObject = 0;
|
||||
static QObject *currentTestObject = nullptr;
|
||||
static QString mainSourcePath;
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
@ -423,7 +423,7 @@ Q_TESTLIB_EXPORT bool printAvailableFunctions = false;
|
||||
Q_TESTLIB_EXPORT QStringList testFunctions;
|
||||
Q_TESTLIB_EXPORT QStringList testTags;
|
||||
|
||||
static void qPrintTestSlots(FILE *stream, const char *filter = 0)
|
||||
static void qPrintTestSlots(FILE *stream, const char *filter = nullptr)
|
||||
{
|
||||
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
|
||||
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
|
||||
@ -516,7 +516,7 @@ static int qToInt(const char *str)
|
||||
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool qml)
|
||||
{
|
||||
int logFormat = -1; // Not set
|
||||
const char *logFilename = 0;
|
||||
const char *logFilename = nullptr;
|
||||
|
||||
QTest::testFunctions.clear();
|
||||
QTest::testTags.clear();
|
||||
@ -897,7 +897,7 @@ struct QTestDataSetter
|
||||
}
|
||||
~QTestDataSetter()
|
||||
{
|
||||
QTestResult::setCurrentTestData(0);
|
||||
QTestResult::setCurrentTestData(nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -974,11 +974,11 @@ void TestMethods::invokeTestOnData(int index) const
|
||||
if (i == -1) {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("warmup stage result : %1")
|
||||
.arg(QBenchmarkTestMethodData::current->result.value)), 0, 0);
|
||||
.arg(QBenchmarkTestMethodData::current->result.value)), nullptr, 0);
|
||||
} else {
|
||||
QTestLog::info(qPrintable(
|
||||
QString::fromLatin1("accumulation stage result: %1")
|
||||
.arg(QBenchmarkTestMethodData::current->result.value)), 0, 0);
|
||||
.arg(QBenchmarkTestMethodData::current->result.value)), nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1115,7 +1115,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
|
||||
if (data && !dataCount) {
|
||||
// Let empty data tag through.
|
||||
if (!*data)
|
||||
data = 0;
|
||||
data = nullptr;
|
||||
else {
|
||||
fprintf(stderr, "Unknown testdata for function %s(): '%s'\n", name.constData(), data);
|
||||
fprintf(stderr, "Function has no testdata.\n");
|
||||
@ -1130,10 +1130,9 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
|
||||
if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) {
|
||||
foundFunction = true;
|
||||
|
||||
QTestPrivate::checkBlackLists(name.constData(), dataCount ? table.testData(curDataIndex)->dataTag() : 0);
|
||||
QTestPrivate::checkBlackLists(name.constData(), dataCount ? table.testData(curDataIndex)->dataTag() : nullptr);
|
||||
|
||||
QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
|
||||
: table.testData(curDataIndex));
|
||||
QTestDataSetter s(curDataIndex >= dataCount ? nullptr : table.testData(curDataIndex));
|
||||
|
||||
QTestPrivate::qtestMouseButtons = Qt::NoButton;
|
||||
if (watchDog)
|
||||
@ -1156,14 +1155,14 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
|
||||
return false;
|
||||
}
|
||||
|
||||
QTestResult::setCurrentGlobalTestData(0);
|
||||
QTestResult::setCurrentGlobalTestData(nullptr);
|
||||
++curGlobalDataIndex;
|
||||
} while (curGlobalDataIndex < globalDataCount);
|
||||
|
||||
QTestResult::finishedCurrentTestFunction();
|
||||
QTestResult::setSkipCurrentTest(false);
|
||||
QTestResult::setBlacklistCurrentTest(false);
|
||||
QTestResult::setCurrentTestData(0);
|
||||
QTestResult::setCurrentTestData(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1241,7 +1240,7 @@ char *toHexRepresentation(const char *ba, int length)
|
||||
* */
|
||||
const int maxLen = 50;
|
||||
const int len = qMin(maxLen, length);
|
||||
char *result = 0;
|
||||
char *result = nullptr;
|
||||
|
||||
if (length > maxLen) {
|
||||
const int size = len * 3 + 4;
|
||||
@ -1497,7 +1496,7 @@ void TestMethods::invokeTests(QObject *testObject) const
|
||||
QTestResult::finishedCurrentTestDataCleanup();
|
||||
}
|
||||
QTestResult::finishedCurrentTestFunction();
|
||||
QTestResult::setCurrentTestFunction(0);
|
||||
QTestResult::setCurrentTestFunction(nullptr);
|
||||
}
|
||||
|
||||
#if defined(Q_OS_UNIX)
|
||||
@ -1567,7 +1566,7 @@ FatalSignalHandler::FatalSignalHandler()
|
||||
stack.ss_flags = 0;
|
||||
stack.ss_size = sizeof alternate_stack;
|
||||
stack.ss_sp = alternate_stack;
|
||||
sigaltstack(&stack, 0);
|
||||
sigaltstack(&stack, nullptr);
|
||||
act.sa_flags |= SA_ONSTACK;
|
||||
#endif
|
||||
|
||||
@ -1586,7 +1585,7 @@ FatalSignalHandler::FatalSignalHandler()
|
||||
oldact.sa_flags & SA_SIGINFO ||
|
||||
#endif
|
||||
oldact.sa_handler != SIG_DFL) {
|
||||
sigaction(fatalSignals[i], &oldact, 0);
|
||||
sigaction(fatalSignals[i], &oldact, nullptr);
|
||||
} else
|
||||
{
|
||||
sigaddset(&handledSignals, fatalSignals[i]);
|
||||
@ -1611,7 +1610,7 @@ FatalSignalHandler::~FatalSignalHandler()
|
||||
|
||||
// If someone overwrote it in the mean time, put it back
|
||||
if (oldact.sa_handler != FatalSignalHandler::signal)
|
||||
sigaction(i, &oldact, 0);
|
||||
sigaction(i, &oldact, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1927,7 +1926,7 @@ int QTest::qRun()
|
||||
QTestResult::addFailure("Caught unhandled exception", __FILE__, __LINE__);
|
||||
if (QTestResult::currentTestFunction()) {
|
||||
QTestResult::finishedCurrentTestFunction();
|
||||
QTestResult::setCurrentTestFunction(0);
|
||||
QTestResult::setCurrentTestFunction(nullptr);
|
||||
}
|
||||
|
||||
QTestLog::stopLogging();
|
||||
@ -1936,7 +1935,7 @@ int QTest::qRun()
|
||||
IOPMAssertionRelease(powerID);
|
||||
}
|
||||
#endif
|
||||
currentTestObject = 0;
|
||||
currentTestObject = nullptr;
|
||||
|
||||
// Rethrow exception to make debugging easier.
|
||||
throw;
|
||||
@ -1957,13 +1956,13 @@ int QTest::qRun()
|
||||
*/
|
||||
void QTest::qCleanup()
|
||||
{
|
||||
currentTestObject = 0;
|
||||
currentTestObject = nullptr;
|
||||
|
||||
QTestTable::clearGlobalTestTable();
|
||||
QTestLog::stopLogging();
|
||||
|
||||
delete QBenchmarkGlobalData::current;
|
||||
QBenchmarkGlobalData::current = 0;
|
||||
QBenchmarkGlobalData::current = nullptr;
|
||||
|
||||
QSignalDumper::endDump();
|
||||
|
||||
@ -2727,7 +2726,7 @@ template <> Q_TESTLIB_EXPORT char *QTest::toString<char>(const char &t)
|
||||
char *QTest::toString(const char *str)
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
return nullptr;
|
||||
char *msg = new char[strlen(str) + 1];
|
||||
return qstrcpy(msg, str);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ const char *QTestElementAttribute::name() const
|
||||
if (attributeIndex != QTest::AI_Undefined)
|
||||
return AttributeNames[attributeIndex];
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QTest::AttributeIndex QTestElementAttribute::index() const
|
||||
@ -164,7 +164,7 @@ bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *val
|
||||
attributeIndex = index;
|
||||
attributeValue = qstrdup(value);
|
||||
|
||||
return attributeValue != 0;
|
||||
return attributeValue != nullptr;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -166,7 +166,7 @@ namespace QTest {
|
||||
IgnoreResultList *next = nullptr;
|
||||
};
|
||||
|
||||
static IgnoreResultList *ignoreResultList = 0;
|
||||
static IgnoreResultList *ignoreResultList = nullptr;
|
||||
|
||||
static QVector<QAbstractTestLogger*> loggers;
|
||||
static bool loggerUsingStdout = false;
|
||||
@ -181,7 +181,7 @@ namespace QTest {
|
||||
{
|
||||
if (!ignoreResultList)
|
||||
return false;
|
||||
IgnoreResultList *last = 0;
|
||||
IgnoreResultList *last = nullptr;
|
||||
IgnoreResultList *list = ignoreResultList;
|
||||
while (list) {
|
||||
if (list->matches(type, message)) {
|
||||
@ -191,7 +191,7 @@ namespace QTest {
|
||||
else if (list->next)
|
||||
ignoreResultList = list->next;
|
||||
else
|
||||
ignoreResultList = 0;
|
||||
ignoreResultList = nullptr;
|
||||
|
||||
delete list;
|
||||
return true;
|
||||
@ -438,11 +438,11 @@ void QTestLog::stopLogging()
|
||||
void QTestLog::addLogger(LogMode mode, const char *filename)
|
||||
{
|
||||
if (filename && strcmp(filename, "-") == 0)
|
||||
filename = 0;
|
||||
filename = nullptr;
|
||||
if (!filename)
|
||||
QTest::loggerUsingStdout = true;
|
||||
|
||||
QAbstractTestLogger *logger = 0;
|
||||
QAbstractTestLogger *logger = nullptr;
|
||||
switch (mode) {
|
||||
case QTestLog::Plain:
|
||||
logger = new QPlainTestLogger(filename);
|
||||
|
@ -49,33 +49,33 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *currentAppName = 0;
|
||||
static const char *currentAppName = nullptr;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QTest
|
||||
{
|
||||
static QTestData *currentTestData = 0;
|
||||
static QTestData *currentGlobalTestData = 0;
|
||||
static const char *currentTestFunc = 0;
|
||||
static const char *currentTestObjectName = 0;
|
||||
static QTestData *currentTestData = nullptr;
|
||||
static QTestData *currentGlobalTestData = nullptr;
|
||||
static const char *currentTestFunc = nullptr;
|
||||
static const char *currentTestObjectName = nullptr;
|
||||
static bool failed = false;
|
||||
static bool skipCurrentTest = false;
|
||||
static bool blacklistCurrentTest = false;
|
||||
|
||||
static const char *expectFailComment = 0;
|
||||
static const char *expectFailComment = nullptr;
|
||||
static int expectFailMode = 0;
|
||||
}
|
||||
|
||||
void QTestResult::reset()
|
||||
{
|
||||
QTest::currentTestData = 0;
|
||||
QTest::currentGlobalTestData = 0;
|
||||
QTest::currentTestFunc = 0;
|
||||
QTest::currentTestObjectName = 0;
|
||||
QTest::currentTestData = nullptr;
|
||||
QTest::currentGlobalTestData = nullptr;
|
||||
QTest::currentTestFunc = nullptr;
|
||||
QTest::currentTestObjectName = nullptr;
|
||||
QTest::failed = false;
|
||||
|
||||
QTest::expectFailComment = 0;
|
||||
QTest::expectFailComment = nullptr;
|
||||
QTest::expectFailMode = 0;
|
||||
QTest::blacklistCurrentTest = false;
|
||||
|
||||
@ -127,18 +127,18 @@ static void clearExpectFail()
|
||||
{
|
||||
QTest::expectFailMode = 0;
|
||||
delete [] const_cast<char *>(QTest::expectFailComment);
|
||||
QTest::expectFailComment = 0;
|
||||
QTest::expectFailComment = nullptr;
|
||||
}
|
||||
|
||||
void QTestResult::finishedCurrentTestData()
|
||||
{
|
||||
if (QTest::expectFailMode)
|
||||
addFailure("QEXPECT_FAIL was called without any subsequent verification statements", 0, 0);
|
||||
addFailure("QEXPECT_FAIL was called without any subsequent verification statements", nullptr, 0);
|
||||
clearExpectFail();
|
||||
|
||||
if (!QTest::failed && QTestLog::unhandledIgnoreMessages()) {
|
||||
QTestLog::printUnhandledIgnoreMessages();
|
||||
addFailure("Not all expected messages were received", 0, 0);
|
||||
addFailure("Not all expected messages were received", nullptr, 0);
|
||||
}
|
||||
QTestLog::clearIgnoreMessages();
|
||||
}
|
||||
@ -158,7 +158,7 @@ void QTestResult::finishedCurrentTestDataCleanup()
|
||||
|
||||
void QTestResult::finishedCurrentTestFunction()
|
||||
{
|
||||
QTest::currentTestFunc = 0;
|
||||
QTest::currentTestFunc = nullptr;
|
||||
QTest::failed = false;
|
||||
|
||||
QTestLog::leaveTestFunction();
|
||||
@ -171,14 +171,12 @@ const char *QTestResult::currentTestFunction()
|
||||
|
||||
const char *QTestResult::currentDataTag()
|
||||
{
|
||||
return QTest::currentTestData ? QTest::currentTestData->dataTag()
|
||||
: static_cast<const char *>(0);
|
||||
return QTest::currentTestData ? QTest::currentTestData->dataTag() : nullptr;
|
||||
}
|
||||
|
||||
const char *QTestResult::currentGlobalDataTag()
|
||||
{
|
||||
return QTest::currentGlobalTestData ? QTest::currentGlobalTestData->dataTag()
|
||||
: static_cast<const char *>(0);
|
||||
return QTest::currentGlobalTestData ? QTest::currentGlobalTestData->dataTag() : nullptr;
|
||||
}
|
||||
|
||||
static bool isExpectFailData(const char *dataIndex)
|
||||
|
@ -78,8 +78,8 @@ public:
|
||||
static QTestTable *gTable;
|
||||
};
|
||||
|
||||
QTestTable *QTestTablePrivate::currentTestTable = 0;
|
||||
QTestTable *QTestTablePrivate::gTable = 0;
|
||||
QTestTable *QTestTablePrivate::currentTestTable = nullptr;
|
||||
QTestTable *QTestTablePrivate::gTable = nullptr;
|
||||
|
||||
void QTestTable::addColumn(int type, const char *name)
|
||||
{
|
||||
@ -119,7 +119,7 @@ QTestTable::QTestTable()
|
||||
|
||||
QTestTable::~QTestTable()
|
||||
{
|
||||
QTestTablePrivate::currentTestTable = 0;
|
||||
QTestTablePrivate::currentTestTable = nullptr;
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ QTestTable *QTestTable::globalTestTable()
|
||||
void QTestTable::clearGlobalTestTable()
|
||||
{
|
||||
delete QTestTablePrivate::gTable;
|
||||
QTestTablePrivate::gTable = 0;
|
||||
QTestTablePrivate::gTable = nullptr;
|
||||
}
|
||||
|
||||
QTestTable *QTestTable::currentTestTable()
|
||||
|
@ -129,7 +129,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
|
||||
return;
|
||||
}
|
||||
|
||||
char const* key = 0;
|
||||
char const* key = nullptr;
|
||||
if (attrindex == QTest::AI_Description)
|
||||
key = "message";
|
||||
else if (attrindex != QTest::AI_File && attrindex != QTest::AI_Line)
|
||||
|
@ -148,7 +148,7 @@ void QXunitTestLogger::leaveTestFunction()
|
||||
void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
|
||||
const char *file, int line)
|
||||
{
|
||||
const char *typeBuf = 0;
|
||||
const char *typeBuf = nullptr;
|
||||
char buf[100];
|
||||
|
||||
switch (type) {
|
||||
@ -292,7 +292,7 @@ void QXunitTestLogger::addTag(QTestElement* element)
|
||||
void QXunitTestLogger::addMessage(MessageTypes type, const QString &message, const char *file, int line)
|
||||
{
|
||||
QTestElement *errorElement = new QTestElement(QTest::LET_Error);
|
||||
const char *typeBuf = 0;
|
||||
const char *typeBuf = nullptr;
|
||||
|
||||
switch (type) {
|
||||
case QAbstractTestLogger::Warn:
|
||||
|
Loading…
x
Reference in New Issue
Block a user