QTestlib: Speed up comparison of qsizetype
Add a qCompare() overload for qsizetype, preventing it
falling back to the slow code path pre-formatting expected/actual.
toString() should use the correct format from the already present
int-types (see macro TO_STRING_IMPL).
Complements 94aa350621
.
Task-number: QTBUG-38890
Change-Id: Ieb8cea7de086141a2c80f93b4c1be01572be96df
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
cbdf2ba46a
commit
db942d6125
@ -2577,6 +2577,21 @@ bool QTest::qCompare(int t1, int t2, const char *actual, const char *expected,
|
|||||||
t1, t2, actual, expected, file, line);
|
t1, t2, actual, expected, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_POINTER_SIZE == 8
|
||||||
|
/*! \fn bool QTest::qCompare(qsizetype t1, qsizetype t2, const char *actual, const char *expected, const char *file, int line)
|
||||||
|
\internal
|
||||||
|
\since 6.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool QTest::qCompare(qsizetype t1, qsizetype t2, const char *actual, const char *expected,
|
||||||
|
const char *file, int line)
|
||||||
|
{
|
||||||
|
return QTestResult::compare(t1 == t2,
|
||||||
|
"Compared values are not the same",
|
||||||
|
t1, t2, actual, expected, file, line);
|
||||||
|
}
|
||||||
|
#endif // QT_POINTER_SIZE == 8
|
||||||
|
|
||||||
/*! \fn bool QTest::qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected, const char *file, int line)
|
/*! \fn bool QTest::qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected, const char *file, int line)
|
||||||
\internal
|
\internal
|
||||||
\since 5.14
|
\since 5.14
|
||||||
|
@ -377,6 +377,11 @@ namespace QTest
|
|||||||
Q_TESTLIB_EXPORT bool qCompare(int t1, int t2, const char *actual, const char *expected,
|
Q_TESTLIB_EXPORT bool qCompare(int t1, int t2, const char *actual, const char *expected,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
|
|
||||||
|
#if QT_POINTER_SIZE == 8
|
||||||
|
Q_TESTLIB_EXPORT bool qCompare(qsizetype t1, qsizetype t2, const char *actual, const char *expected,
|
||||||
|
const char *file, int line);
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_TESTLIB_EXPORT bool qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected,
|
Q_TESTLIB_EXPORT bool qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
|
|
||||||
|
@ -415,6 +415,16 @@ bool QTestResult::compare(bool success, const char *failureMsg,
|
|||||||
return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
|
return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_POINTER_SIZE == 8
|
||||||
|
bool QTestResult::compare(bool success, const char *failureMsg,
|
||||||
|
qsizetype val1, qsizetype val2,
|
||||||
|
const char *actual, const char *expected,
|
||||||
|
const char *file, int line)
|
||||||
|
{
|
||||||
|
return compareHelper(success, failureMsg, val1, val2, actual, expected, file, line);
|
||||||
|
}
|
||||||
|
#endif // QT_POINTER_SIZE == 8
|
||||||
|
|
||||||
bool QTestResult::compare(bool success, const char *failureMsg,
|
bool QTestResult::compare(bool success, const char *failureMsg,
|
||||||
unsigned val1, unsigned val2,
|
unsigned val1, unsigned val2,
|
||||||
const char *actual, const char *expected,
|
const char *actual, const char *expected,
|
||||||
|
@ -94,6 +94,12 @@ public:
|
|||||||
int val1, int val2,
|
int val1, int val2,
|
||||||
const char *actual, const char *expected,
|
const char *actual, const char *expected,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
|
#if QT_POINTER_SIZE == 8
|
||||||
|
static bool compare(bool success, const char *failureMsg,
|
||||||
|
qsizetype val1, qsizetype val2,
|
||||||
|
const char *actual, const char *expected,
|
||||||
|
const char *file, int line);
|
||||||
|
#endif
|
||||||
static bool compare(bool success, const char *failureMsg,
|
static bool compare(bool success, const char *failureMsg,
|
||||||
unsigned val1, unsigned val2,
|
unsigned val1, unsigned val2,
|
||||||
const char *actual, const char *expected,
|
const char *actual, const char *expected,
|
||||||
|
Loading…
Reference in New Issue
Block a user