diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index 9bb1d1e80c..e5a1404c16 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -117,8 +117,7 @@ struct QTestCharBuffer { enum { InitialSize = 512 }; - inline QTestCharBuffer() - : _size(InitialSize), buf(staticBuf) + inline QTestCharBuffer() : buf(staticBuf) { staticBuf[0] = '\0'; } @@ -170,7 +169,7 @@ struct QTestCharBuffer } private: - int _size; + int _size = InitialSize; char* buf; char staticBuf[InitialSize]; }; diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index cbc009c993..19abd16284 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -51,14 +51,6 @@ QT_BEGIN_NAMESPACE QBenchmarkGlobalData *QBenchmarkGlobalData::current; QBenchmarkGlobalData::QBenchmarkGlobalData() - : measurer(0) - , walltimeMinimum(-1) - , iterationCount(-1) - , medianIterationCount(-1) - , createChart(false) - , verboseOutput(false) - , minimumTotal(-1) - , mode_(WallTime) { setMode(mode_); } @@ -116,10 +108,7 @@ int QBenchmarkGlobalData::adjustMedianIterationCount() QBenchmarkTestMethodData *QBenchmarkTestMethodData::current; -QBenchmarkTestMethodData::QBenchmarkTestMethodData() -:resultAccepted(false), runOnce(false), iterationCount(-1) -{ -} +QBenchmarkTestMethodData::QBenchmarkTestMethodData() = default; QBenchmarkTestMethodData::~QBenchmarkTestMethodData() { diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 49868ac23a..93b5becb2b 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -81,7 +81,7 @@ struct QBenchmarkContext QString slotName; QString tag; // from _data() function - int checkpointIndex; + int checkpointIndex = -1; QString toString() const { @@ -89,7 +89,7 @@ struct QBenchmarkContext .arg(slotName, tag, QString::number(checkpointIndex)); } - QBenchmarkContext() : checkpointIndex(-1) {} + QBenchmarkContext() = default; }; Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_MOVABLE_TYPE); @@ -97,19 +97,13 @@ class QBenchmarkResult { public: QBenchmarkContext context; - qreal value; - int iterations; - QTest::QBenchmarkMetric metric; - bool setByMacro; - bool valid; + qreal value = -1; + int iterations = -1; + QTest::QBenchmarkMetric metric = QTest::FramesPerSecond; + bool setByMacro = true; + bool valid = false; - QBenchmarkResult() - : value(-1) - , iterations(-1) - , metric(QTest::FramesPerSecond) - , setByMacro(true) - , valid(false) - { } + QBenchmarkResult() = default; QBenchmarkResult( const QBenchmarkContext &context, const qreal value, const int iterations, @@ -147,17 +141,17 @@ public: QBenchmarkMeasurerBase *createMeasurer(); int adjustMedianIterationCount(); - QBenchmarkMeasurerBase *measurer; + QBenchmarkMeasurerBase *measurer = nullptr; QBenchmarkContext context; - int walltimeMinimum; - int iterationCount; - int medianIterationCount; - bool createChart; - bool verboseOutput; + int walltimeMinimum = -1; + int iterationCount = -1; + int medianIterationCount = -1; + bool createChart = false; + bool verboseOutput = false; QString callgrindOutFileBase; - int minimumTotal; + int minimumTotal = -1; private: - Mode mode_; + Mode mode_ = WallTime; }; /* @@ -184,9 +178,9 @@ public: void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true); QBenchmarkResult result; - bool resultAccepted; - bool runOnce; - int iterationCount; + bool resultAccepted = false; + bool runOnce = false; + int iterationCount = -1; }; // low-level API: diff --git a/src/testlib/qbenchmarkevent.cpp b/src/testlib/qbenchmarkevent.cpp index a8270219e4..41be9fa468 100644 --- a/src/testlib/qbenchmarkevent.cpp +++ b/src/testlib/qbenchmarkevent.cpp @@ -44,10 +44,7 @@ QT_BEGIN_NAMESPACE -QBenchmarkEvent::QBenchmarkEvent() - : eventCounter(0) -{ -} +QBenchmarkEvent::QBenchmarkEvent() = default; QBenchmarkEvent::~QBenchmarkEvent() { diff --git a/src/testlib/qbenchmarkevent_p.h b/src/testlib/qbenchmarkevent_p.h index 0f47aa475c..9fe3daa33b 100644 --- a/src/testlib/qbenchmarkevent_p.h +++ b/src/testlib/qbenchmarkevent_p.h @@ -76,7 +76,7 @@ public: #else bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; #endif - qint64 eventCounter; + qint64 eventCounter = 0; }; QT_END_NAMESPACE diff --git a/src/testlib/qbenchmarkperfevents.cpp b/src/testlib/qbenchmarkperfevents.cpp index 91f0792338..ea27f29711 100644 --- a/src/testlib/qbenchmarkperfevents.cpp +++ b/src/testlib/qbenchmarkperfevents.cpp @@ -500,10 +500,7 @@ void QBenchmarkPerfEventsMeasurer::listCounters() "Attributes can be combined, for example: -perfcounter branch-mispredicts:kh\n"); } -QBenchmarkPerfEventsMeasurer::QBenchmarkPerfEventsMeasurer() - : fd(-1) -{ -} +QBenchmarkPerfEventsMeasurer::QBenchmarkPerfEventsMeasurer() = default; QBenchmarkPerfEventsMeasurer::~QBenchmarkPerfEventsMeasurer() { diff --git a/src/testlib/qbenchmarkperfevents_p.h b/src/testlib/qbenchmarkperfevents_p.h index 86ba556549..47af4db9f8 100644 --- a/src/testlib/qbenchmarkperfevents_p.h +++ b/src/testlib/qbenchmarkperfevents_p.h @@ -76,7 +76,7 @@ public: static void setCounter(const char *name); static void listCounters(); private: - int fd; + int fd = -1; qint64 readValue(); }; diff --git a/src/testlib/qtestcoreelement_p.h b/src/testlib/qtestcoreelement_p.h index 84406fed85..a101ab5ea3 100644 --- a/src/testlib/qtestcoreelement_p.h +++ b/src/testlib/qtestcoreelement_p.h @@ -74,13 +74,13 @@ class QTestCoreElement: public QTestCoreList QTest::LogElementType elementType() const; private: - QTestElementAttribute *listOfAttributes; + QTestElementAttribute *listOfAttributes = nullptr; QTest::LogElementType type; }; template QTestCoreElement::QTestCoreElement(int t) - :listOfAttributes(nullptr), type(QTest::LogElementType(t)) + : type(QTest::LogElementType(t)) { } diff --git a/src/testlib/qtestdata.cpp b/src/testlib/qtestdata.cpp index a8ee130a7d..3a1c6d7e7b 100644 --- a/src/testlib/qtestdata.cpp +++ b/src/testlib/qtestdata.cpp @@ -51,12 +51,10 @@ QT_BEGIN_NAMESPACE class QTestDataPrivate { public: - QTestDataPrivate() : tag(0), parent(0), data(0), dataCount(0) {} - - char *tag; - QTestTable *parent; - void **data; - int dataCount; + char *tag = nullptr; + QTestTable *parent = nullptr; + void **data = nullptr; + int dataCount = 0; }; QTestData::QTestData(const char *tag, QTestTable *parent) diff --git a/src/testlib/qtestelement.cpp b/src/testlib/qtestelement.cpp index 622e5344f3..b468295917 100644 --- a/src/testlib/qtestelement.cpp +++ b/src/testlib/qtestelement.cpp @@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE QTestElement::QTestElement(int type) : QTestCoreElement(type) - , listOfChildren(0) - , parent(0) { } diff --git a/src/testlib/qtestelement_p.h b/src/testlib/qtestelement_p.h index dacbe6c106..a6b2791a42 100644 --- a/src/testlib/qtestelement_p.h +++ b/src/testlib/qtestelement_p.h @@ -69,8 +69,8 @@ class QTestElement: public QTestCoreElement void setParent(const QTestElement *p); private: - QTestElement *listOfChildren; - const QTestElement * parent; + QTestElement *listOfChildren = nullptr; + const QTestElement * parent = nullptr; }; diff --git a/src/testlib/qtestelementattribute.cpp b/src/testlib/qtestelementattribute.cpp index 9d752bf26a..1aa54d767f 100644 --- a/src/testlib/qtestelementattribute.cpp +++ b/src/testlib/qtestelementattribute.cpp @@ -104,11 +104,7 @@ QT_BEGIN_NAMESPACE \value LET_SystemError */ -QTestElementAttribute::QTestElementAttribute() - :attributeValue(0), - attributeIndex(QTest::AI_Undefined) -{ -} +QTestElementAttribute::QTestElementAttribute() = default; QTestElementAttribute::~QTestElementAttribute() { diff --git a/src/testlib/qtestelementattribute_p.h b/src/testlib/qtestelementattribute_p.h index cb4dbb5f16..f3815b72d1 100644 --- a/src/testlib/qtestelementattribute_p.h +++ b/src/testlib/qtestelementattribute_p.h @@ -106,8 +106,8 @@ class QTestElementAttribute: public QTestCoreList bool setPair(QTest::AttributeIndex attributeIndex, const char *value); private: - char *attributeValue; - QTest::AttributeIndex attributeIndex; + char *attributeValue = nullptr; + QTest::AttributeIndex attributeIndex = QTest::AI_Undefined; }; QT_END_NAMESPACE diff --git a/src/testlib/qtesteventloop.h b/src/testlib/qtesteventloop.h index a77b47cd7f..b194e24c3a 100644 --- a/src/testlib/qtesteventloop.h +++ b/src/testlib/qtesteventloop.h @@ -56,8 +56,7 @@ class Q_TESTLIB_EXPORT QTestEventLoop : public QObject Q_OBJECT public: - inline QTestEventLoop(QObject *aParent = nullptr) - : QObject(aParent), inLoop(false), _timeout(false), timerId(-1), loop(nullptr) {} + using QObject::QObject; inline void enterLoopMSecs(int ms); inline void enterLoop(int secs) { enterLoopMSecs(secs * 1000); } @@ -84,10 +83,10 @@ protected: private: Q_DECL_UNUSED_MEMBER bool inLoop; // ### Qt 6: remove - bool _timeout; - int timerId; + bool _timeout = false; + int timerId = -1; - QEventLoop *loop; + QEventLoop *loop = nullptr; }; inline void QTestEventLoop::enterLoopMSecs(int ms) diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 14543c3cde..ddebf1105f 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -111,7 +111,7 @@ namespace QTest { struct IgnoreResultList { inline IgnoreResultList(QtMsgType tp, const QVariant &patternIn) - : type(tp), pattern(patternIn), next(0) {} + : type(tp), pattern(patternIn) {} static inline void clearList(IgnoreResultList *&list) { @@ -163,7 +163,7 @@ namespace QTest { QtMsgType type; QVariant pattern; - IgnoreResultList *next; + IgnoreResultList *next = nullptr; }; static IgnoreResultList *ignoreResultList = 0; diff --git a/src/testlib/qtesttable.cpp b/src/testlib/qtesttable.cpp index 20e0702d44..e2e72b125f 100644 --- a/src/testlib/qtesttable.cpp +++ b/src/testlib/qtesttable.cpp @@ -58,11 +58,11 @@ public: } struct Element { - Element() : name(nullptr), type(0) {} + Element() = default; Element(const char *n, int t) : name(n), type(t) {} - const char *name; - int type; + const char *name = nullptr; + int type = 0; }; using ElementList = std::vector; diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp index 336edb5994..cae959a349 100644 --- a/src/testlib/qxunittestlogger.cpp +++ b/src/testlib/qxunittestlogger.cpp @@ -59,13 +59,6 @@ QT_BEGIN_NAMESPACE QXunitTestLogger::QXunitTestLogger(const char *filename) : QAbstractTestLogger(filename) - , listOfTestcases(0) - , currentLogElement(0) - , errorLogElement(0) - , logFormatter(0) - , testCounter(0) - , failureCounter(0) - , errorCounter(0) { } diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h index 48f07ddcf2..518ba098f4 100644 --- a/src/testlib/qxunittestlogger_p.h +++ b/src/testlib/qxunittestlogger_p.h @@ -79,14 +79,14 @@ class QXunitTestLogger : public QAbstractTestLogger const char *file = nullptr, int line = 0) override; private: - QTestElement *listOfTestcases; - QTestElement *currentLogElement; - QTestElement *errorLogElement; - QTestXunitStreamer *logFormatter; + QTestElement *listOfTestcases = nullptr; + QTestElement *currentLogElement = nullptr; + QTestElement *errorLogElement = nullptr; + QTestXunitStreamer *logFormatter = nullptr; - int testCounter; - int failureCounter; - int errorCounter; + int testCounter = 0; + int failureCounter = 0; + int errorCounter = 0; }; QT_END_NAMESPACE