diff options
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index a59eb4ecb3..f38f7ed4df 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -147,6 +147,8 @@ do {\ } \ } +// Ideally we'd use qWaitFor instead of QTRY_LOOP_IMPL, but due +// to a compiler bug on MSVC < 2017 we can't (see QTBUG-59096) #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = 50; \ const int qt_test_timeoutValue = timeout; \ @@ -248,7 +250,7 @@ namespace QTest template <typename T> // Fallback inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(const T &) { - return Q_NULLPTR; + return nullptr; } } // namespace Internal @@ -259,16 +261,26 @@ namespace QTest return Internal::toString(t); } + template <typename T1, typename T2> + inline char *toString(const QPair<T1, T2> &pair); + + template <typename T1, typename T2> + inline char *toString(const std::pair<T1, T2> &pair); + Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length); Q_TESTLIB_EXPORT char *toPrettyCString(const char *unicode, int length); - Q_TESTLIB_EXPORT char *toPrettyUnicode(const ushort *unicode, int length); + Q_TESTLIB_EXPORT char *toPrettyUnicode(QStringView string); Q_TESTLIB_EXPORT char *toString(const char *); Q_TESTLIB_EXPORT char *toString(const void *); - Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = Q_NULLPTR); + Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = nullptr); + Q_TESTLIB_EXPORT int qRun(); + Q_TESTLIB_EXPORT void qCleanup(); + + Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = nullptr); Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments); - Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = Q_NULLPTR); + Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = nullptr); Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description, const char *file, int line); @@ -276,7 +288,7 @@ namespace QTest Q_TESTLIB_EXPORT void qSkip(const char *message, const char *file, int line); Q_TESTLIB_EXPORT bool qExpectFail(const char *dataIndex, const char *comment, TestFailMode mode, const char *file, int line); - Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = Q_NULLPTR, int line = 0); + Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = nullptr, int line = 0); Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message); #ifndef QT_NO_REGULAREXPRESSION Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const QRegularExpression &messagePattern); @@ -285,8 +297,8 @@ namespace QTest #if QT_CONFIG(temporaryfile) Q_TESTLIB_EXPORT QSharedPointer<QTemporaryDir> qExtractTestData(const QString &dirName); #endif - Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); - Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); + Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr); + Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr); Q_TESTLIB_EXPORT void *qData(const char *tagName, int typeId); Q_TESTLIB_EXPORT void *qGlobalData(const char *tagName, int typeId); @@ -319,6 +331,8 @@ namespace QTest Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag); Q_TESTLIB_EXPORT QTestData &addRow(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // kept after adding implementation of <T1, T2> out of paranoia: template <typename T> inline bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line) @@ -326,6 +340,7 @@ namespace QTest return compare_helper(t1 == t2, "Compared values are not the same", toString(t1), toString(t2), actual, expected, file, line); } +#endif Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line); @@ -376,7 +391,12 @@ namespace QTest #endif template <typename T1, typename T2> - bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); + inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected, + const char *file, int line) + { + return compare_helper(t1 == t2, "Compared values are not the same", + toString(t1), toString(t2), actual, expected, file, line); + } inline bool qCompare(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) |