diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-09 09:58:56 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-22 12:11:39 +0100 |
commit | db942d61252ee909c480629d4900ef155e158712 (patch) | |
tree | 0a6b4e34b67a72f32557e3ff56b44376a0fc6847 /src/testlib/qtestcase.cpp | |
parent | cbdf2ba46aed53d002b90d4d9683c28306f8e0a9 (diff) |
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 94aa350621e8a5c4ad3b438c10fc1c0a9ed3bc8a.
Task-number: QTBUG-38890
Change-Id: Ieb8cea7de086141a2c80f93b4c1be01572be96df
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3227a66c05..7c2de877da 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2577,6 +2577,21 @@ bool QTest::qCompare(int t1, int t2, const char *actual, const char *expected, 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) \internal \since 5.14 |