QTestLib: Use member initialization
Apply Fixits by Qt Creator with some amendments. Task-number: QTBUG-69413 Change-Id: Iba0834dc89cbfc215acc5873f31fa6eeed74177d Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
parent
fc15cdb4d0
commit
2d8d738657
@ -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];
|
||||
};
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -44,10 +44,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QBenchmarkEvent::QBenchmarkEvent()
|
||||
: eventCounter(0)
|
||||
{
|
||||
}
|
||||
QBenchmarkEvent::QBenchmarkEvent() = default;
|
||||
|
||||
QBenchmarkEvent::~QBenchmarkEvent()
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
static void setCounter(const char *name);
|
||||
static void listCounters();
|
||||
private:
|
||||
int fd;
|
||||
int fd = -1;
|
||||
|
||||
qint64 readValue();
|
||||
};
|
||||
|
@ -74,13 +74,13 @@ class QTestCoreElement: public QTestCoreList<ElementType>
|
||||
QTest::LogElementType elementType() const;
|
||||
|
||||
private:
|
||||
QTestElementAttribute *listOfAttributes;
|
||||
QTestElementAttribute *listOfAttributes = nullptr;
|
||||
QTest::LogElementType type;
|
||||
};
|
||||
|
||||
template<class ElementType>
|
||||
QTestCoreElement<ElementType>::QTestCoreElement(int t)
|
||||
:listOfAttributes(nullptr), type(QTest::LogElementType(t))
|
||||
: type(QTest::LogElementType(t))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QTestElement::QTestElement(int type)
|
||||
: QTestCoreElement<QTestElement>(type)
|
||||
, listOfChildren(0)
|
||||
, parent(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ class QTestElement: public QTestCoreElement<QTestElement>
|
||||
void setParent(const QTestElement *p);
|
||||
|
||||
private:
|
||||
QTestElement *listOfChildren;
|
||||
const QTestElement * parent;
|
||||
QTestElement *listOfChildren = nullptr;
|
||||
const QTestElement * parent = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -104,11 +104,7 @@ QT_BEGIN_NAMESPACE
|
||||
\value LET_SystemError
|
||||
*/
|
||||
|
||||
QTestElementAttribute::QTestElementAttribute()
|
||||
:attributeValue(0),
|
||||
attributeIndex(QTest::AI_Undefined)
|
||||
{
|
||||
}
|
||||
QTestElementAttribute::QTestElementAttribute() = default;
|
||||
|
||||
QTestElementAttribute::~QTestElementAttribute()
|
||||
{
|
||||
|
@ -106,8 +106,8 @@ class QTestElementAttribute: public QTestCoreList<QTestElementAttribute>
|
||||
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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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<Element>;
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user