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 };
|
enum { InitialSize = 512 };
|
||||||
|
|
||||||
inline QTestCharBuffer()
|
inline QTestCharBuffer() : buf(staticBuf)
|
||||||
: _size(InitialSize), buf(staticBuf)
|
|
||||||
{
|
{
|
||||||
staticBuf[0] = '\0';
|
staticBuf[0] = '\0';
|
||||||
}
|
}
|
||||||
@ -170,7 +169,7 @@ struct QTestCharBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _size;
|
int _size = InitialSize;
|
||||||
char* buf;
|
char* buf;
|
||||||
char staticBuf[InitialSize];
|
char staticBuf[InitialSize];
|
||||||
};
|
};
|
||||||
|
@ -51,14 +51,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
QBenchmarkGlobalData *QBenchmarkGlobalData::current;
|
QBenchmarkGlobalData *QBenchmarkGlobalData::current;
|
||||||
|
|
||||||
QBenchmarkGlobalData::QBenchmarkGlobalData()
|
QBenchmarkGlobalData::QBenchmarkGlobalData()
|
||||||
: measurer(0)
|
|
||||||
, walltimeMinimum(-1)
|
|
||||||
, iterationCount(-1)
|
|
||||||
, medianIterationCount(-1)
|
|
||||||
, createChart(false)
|
|
||||||
, verboseOutput(false)
|
|
||||||
, minimumTotal(-1)
|
|
||||||
, mode_(WallTime)
|
|
||||||
{
|
{
|
||||||
setMode(mode_);
|
setMode(mode_);
|
||||||
}
|
}
|
||||||
@ -116,10 +108,7 @@ int QBenchmarkGlobalData::adjustMedianIterationCount()
|
|||||||
|
|
||||||
QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;
|
QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;
|
||||||
|
|
||||||
QBenchmarkTestMethodData::QBenchmarkTestMethodData()
|
QBenchmarkTestMethodData::QBenchmarkTestMethodData() = default;
|
||||||
:resultAccepted(false), runOnce(false), iterationCount(-1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
|
QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ struct QBenchmarkContext
|
|||||||
QString slotName;
|
QString slotName;
|
||||||
QString tag; // from _data() function
|
QString tag; // from _data() function
|
||||||
|
|
||||||
int checkpointIndex;
|
int checkpointIndex = -1;
|
||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ struct QBenchmarkContext
|
|||||||
.arg(slotName, tag, QString::number(checkpointIndex));
|
.arg(slotName, tag, QString::number(checkpointIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
QBenchmarkContext() : checkpointIndex(-1) {}
|
QBenchmarkContext() = default;
|
||||||
};
|
};
|
||||||
Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QBenchmarkContext, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
@ -97,19 +97,13 @@ class QBenchmarkResult
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QBenchmarkContext context;
|
QBenchmarkContext context;
|
||||||
qreal value;
|
qreal value = -1;
|
||||||
int iterations;
|
int iterations = -1;
|
||||||
QTest::QBenchmarkMetric metric;
|
QTest::QBenchmarkMetric metric = QTest::FramesPerSecond;
|
||||||
bool setByMacro;
|
bool setByMacro = true;
|
||||||
bool valid;
|
bool valid = false;
|
||||||
|
|
||||||
QBenchmarkResult()
|
QBenchmarkResult() = default;
|
||||||
: value(-1)
|
|
||||||
, iterations(-1)
|
|
||||||
, metric(QTest::FramesPerSecond)
|
|
||||||
, setByMacro(true)
|
|
||||||
, valid(false)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
QBenchmarkResult(
|
QBenchmarkResult(
|
||||||
const QBenchmarkContext &context, const qreal value, const int iterations,
|
const QBenchmarkContext &context, const qreal value, const int iterations,
|
||||||
@ -147,17 +141,17 @@ public:
|
|||||||
QBenchmarkMeasurerBase *createMeasurer();
|
QBenchmarkMeasurerBase *createMeasurer();
|
||||||
int adjustMedianIterationCount();
|
int adjustMedianIterationCount();
|
||||||
|
|
||||||
QBenchmarkMeasurerBase *measurer;
|
QBenchmarkMeasurerBase *measurer = nullptr;
|
||||||
QBenchmarkContext context;
|
QBenchmarkContext context;
|
||||||
int walltimeMinimum;
|
int walltimeMinimum = -1;
|
||||||
int iterationCount;
|
int iterationCount = -1;
|
||||||
int medianIterationCount;
|
int medianIterationCount = -1;
|
||||||
bool createChart;
|
bool createChart = false;
|
||||||
bool verboseOutput;
|
bool verboseOutput = false;
|
||||||
QString callgrindOutFileBase;
|
QString callgrindOutFileBase;
|
||||||
int minimumTotal;
|
int minimumTotal = -1;
|
||||||
private:
|
private:
|
||||||
Mode mode_;
|
Mode mode_ = WallTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -184,9 +178,9 @@ public:
|
|||||||
void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true);
|
void setResult(qreal value, QTest::QBenchmarkMetric metric, bool setByMacro = true);
|
||||||
|
|
||||||
QBenchmarkResult result;
|
QBenchmarkResult result;
|
||||||
bool resultAccepted;
|
bool resultAccepted = false;
|
||||||
bool runOnce;
|
bool runOnce = false;
|
||||||
int iterationCount;
|
int iterationCount = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// low-level API:
|
// low-level API:
|
||||||
|
@ -44,10 +44,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QBenchmarkEvent::QBenchmarkEvent()
|
QBenchmarkEvent::QBenchmarkEvent() = default;
|
||||||
: eventCounter(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QBenchmarkEvent::~QBenchmarkEvent()
|
QBenchmarkEvent::~QBenchmarkEvent()
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
||||||
#endif
|
#endif
|
||||||
qint64 eventCounter;
|
qint64 eventCounter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -500,10 +500,7 @@ void QBenchmarkPerfEventsMeasurer::listCounters()
|
|||||||
"Attributes can be combined, for example: -perfcounter branch-mispredicts:kh\n");
|
"Attributes can be combined, for example: -perfcounter branch-mispredicts:kh\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
QBenchmarkPerfEventsMeasurer::QBenchmarkPerfEventsMeasurer()
|
QBenchmarkPerfEventsMeasurer::QBenchmarkPerfEventsMeasurer() = default;
|
||||||
: fd(-1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QBenchmarkPerfEventsMeasurer::~QBenchmarkPerfEventsMeasurer()
|
QBenchmarkPerfEventsMeasurer::~QBenchmarkPerfEventsMeasurer()
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
static void setCounter(const char *name);
|
static void setCounter(const char *name);
|
||||||
static void listCounters();
|
static void listCounters();
|
||||||
private:
|
private:
|
||||||
int fd;
|
int fd = -1;
|
||||||
|
|
||||||
qint64 readValue();
|
qint64 readValue();
|
||||||
};
|
};
|
||||||
|
@ -74,13 +74,13 @@ class QTestCoreElement: public QTestCoreList<ElementType>
|
|||||||
QTest::LogElementType elementType() const;
|
QTest::LogElementType elementType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTestElementAttribute *listOfAttributes;
|
QTestElementAttribute *listOfAttributes = nullptr;
|
||||||
QTest::LogElementType type;
|
QTest::LogElementType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ElementType>
|
template<class ElementType>
|
||||||
QTestCoreElement<ElementType>::QTestCoreElement(int t)
|
QTestCoreElement<ElementType>::QTestCoreElement(int t)
|
||||||
:listOfAttributes(nullptr), type(QTest::LogElementType(t))
|
: type(QTest::LogElementType(t))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QTestDataPrivate
|
class QTestDataPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTestDataPrivate() : tag(0), parent(0), data(0), dataCount(0) {}
|
char *tag = nullptr;
|
||||||
|
QTestTable *parent = nullptr;
|
||||||
char *tag;
|
void **data = nullptr;
|
||||||
QTestTable *parent;
|
int dataCount = 0;
|
||||||
void **data;
|
|
||||||
int dataCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QTestData::QTestData(const char *tag, QTestTable *parent)
|
QTestData::QTestData(const char *tag, QTestTable *parent)
|
||||||
|
@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QTestElement::QTestElement(int type)
|
QTestElement::QTestElement(int type)
|
||||||
: QTestCoreElement<QTestElement>(type)
|
: QTestCoreElement<QTestElement>(type)
|
||||||
, listOfChildren(0)
|
|
||||||
, parent(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ class QTestElement: public QTestCoreElement<QTestElement>
|
|||||||
void setParent(const QTestElement *p);
|
void setParent(const QTestElement *p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTestElement *listOfChildren;
|
QTestElement *listOfChildren = nullptr;
|
||||||
const QTestElement * parent;
|
const QTestElement * parent = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,11 +104,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
\value LET_SystemError
|
\value LET_SystemError
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QTestElementAttribute::QTestElementAttribute()
|
QTestElementAttribute::QTestElementAttribute() = default;
|
||||||
:attributeValue(0),
|
|
||||||
attributeIndex(QTest::AI_Undefined)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QTestElementAttribute::~QTestElementAttribute()
|
QTestElementAttribute::~QTestElementAttribute()
|
||||||
{
|
{
|
||||||
|
@ -106,8 +106,8 @@ class QTestElementAttribute: public QTestCoreList<QTestElementAttribute>
|
|||||||
bool setPair(QTest::AttributeIndex attributeIndex, const char *value);
|
bool setPair(QTest::AttributeIndex attributeIndex, const char *value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *attributeValue;
|
char *attributeValue = nullptr;
|
||||||
QTest::AttributeIndex attributeIndex;
|
QTest::AttributeIndex attributeIndex = QTest::AI_Undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -56,8 +56,7 @@ class Q_TESTLIB_EXPORT QTestEventLoop : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline QTestEventLoop(QObject *aParent = nullptr)
|
using QObject::QObject;
|
||||||
: QObject(aParent), inLoop(false), _timeout(false), timerId(-1), loop(nullptr) {}
|
|
||||||
|
|
||||||
inline void enterLoopMSecs(int ms);
|
inline void enterLoopMSecs(int ms);
|
||||||
inline void enterLoop(int secs) { enterLoopMSecs(secs * 1000); }
|
inline void enterLoop(int secs) { enterLoopMSecs(secs * 1000); }
|
||||||
@ -84,10 +83,10 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECL_UNUSED_MEMBER bool inLoop; // ### Qt 6: remove
|
Q_DECL_UNUSED_MEMBER bool inLoop; // ### Qt 6: remove
|
||||||
bool _timeout;
|
bool _timeout = false;
|
||||||
int timerId;
|
int timerId = -1;
|
||||||
|
|
||||||
QEventLoop *loop;
|
QEventLoop *loop = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void QTestEventLoop::enterLoopMSecs(int ms)
|
inline void QTestEventLoop::enterLoopMSecs(int ms)
|
||||||
|
@ -111,7 +111,7 @@ namespace QTest {
|
|||||||
struct IgnoreResultList
|
struct IgnoreResultList
|
||||||
{
|
{
|
||||||
inline IgnoreResultList(QtMsgType tp, const QVariant &patternIn)
|
inline IgnoreResultList(QtMsgType tp, const QVariant &patternIn)
|
||||||
: type(tp), pattern(patternIn), next(0) {}
|
: type(tp), pattern(patternIn) {}
|
||||||
|
|
||||||
static inline void clearList(IgnoreResultList *&list)
|
static inline void clearList(IgnoreResultList *&list)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ namespace QTest {
|
|||||||
|
|
||||||
QtMsgType type;
|
QtMsgType type;
|
||||||
QVariant pattern;
|
QVariant pattern;
|
||||||
IgnoreResultList *next;
|
IgnoreResultList *next = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static IgnoreResultList *ignoreResultList = 0;
|
static IgnoreResultList *ignoreResultList = 0;
|
||||||
|
@ -58,11 +58,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Element {
|
struct Element {
|
||||||
Element() : name(nullptr), type(0) {}
|
Element() = default;
|
||||||
Element(const char *n, int t) : name(n), type(t) {}
|
Element(const char *n, int t) : name(n), type(t) {}
|
||||||
|
|
||||||
const char *name;
|
const char *name = nullptr;
|
||||||
int type;
|
int type = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ElementList = std::vector<Element>;
|
using ElementList = std::vector<Element>;
|
||||||
|
@ -59,13 +59,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QXunitTestLogger::QXunitTestLogger(const char *filename)
|
QXunitTestLogger::QXunitTestLogger(const char *filename)
|
||||||
: QAbstractTestLogger(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;
|
const char *file = nullptr, int line = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTestElement *listOfTestcases;
|
QTestElement *listOfTestcases = nullptr;
|
||||||
QTestElement *currentLogElement;
|
QTestElement *currentLogElement = nullptr;
|
||||||
QTestElement *errorLogElement;
|
QTestElement *errorLogElement = nullptr;
|
||||||
QTestXunitStreamer *logFormatter;
|
QTestXunitStreamer *logFormatter = nullptr;
|
||||||
|
|
||||||
int testCounter;
|
int testCounter = 0;
|
||||||
int failureCounter;
|
int failureCounter = 0;
|
||||||
int errorCounter;
|
int errorCounter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user