1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtTest module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTESTCASE_H
41 #define QTESTCASE_H
42 
43 #include <QtTest/qttestglobal.h>
44 
45 #include <QtCore/qstring.h>
46 #include <QtCore/qnamespace.h>
47 #include <QtCore/qmetatype.h>
48 #include <QtCore/qmetaobject.h>
49 #include <QtCore/qsharedpointer.h>
50 #include <QtCore/qtemporarydir.h>
51 
52 #include <string.h>
53 
54 #ifndef QT_NO_EXCEPTIONS
55 #  include <exception>
56 #endif // QT_NO_EXCEPTIONS
57 
58 QT_BEGIN_NAMESPACE
59 
60 class qfloat16;
61 class QRegularExpression;
62 
63 #define QVERIFY(statement) \
64 do {\
65     if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))\
66         return;\
67 } while (false)
68 
69 #define QFAIL(message) \
70 do {\
71     QTest::qFail(static_cast<const char *>(message), __FILE__, __LINE__);\
72     return;\
73 } while (false)
74 
75 #define QVERIFY2(statement, description) \
76 do {\
77     if (statement) {\
78         if (!QTest::qVerify(true, #statement, static_cast<const char *>(description), __FILE__, __LINE__))\
79             return;\
80     } else {\
81         if (!QTest::qVerify(false, #statement, static_cast<const char *>(description), __FILE__, __LINE__))\
82             return;\
83     }\
84 } while (false)
85 
86 #define QCOMPARE(actual, expected) \
87 do {\
88     if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
89         return;\
90 } while (false)
91 
92 
93 #ifndef QT_NO_EXCEPTIONS
94 
95 #  define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) \
96     do {\
97         QT_TRY {\
98             QT_TRY {\
99                 expression;\
100                 QTest::qFail("Expected exception of type " #exceptiontype " to be thrown" \
101                              " but no exception caught", __FILE__, __LINE__);\
102                 return;\
103             } QT_CATCH (const exceptiontype &) {\
104             }\
105         } QT_CATCH (const std::exception &e) {\
106             QByteArray msg = QByteArray() + "Expected exception of type " #exceptiontype \
107                              " to be thrown but std::exception caught with message: " + e.what(); \
108             QTest::qFail(msg.constData(), __FILE__, __LINE__);\
109             return;\
110         } QT_CATCH (...) {\
111             QTest::qFail("Expected exception of type " #exceptiontype " to be thrown" \
112                          " but unknown exception caught", __FILE__, __LINE__);\
113             return;\
114         }\
115     } while (false)
116 
117 #else // QT_NO_EXCEPTIONS
118 
119 /*
120  * The expression passed to the macro should throw an exception and we can't
121  * catch it because Qt has been compiled without exception support. We can't
122  * skip the expression because it may have side effects and must be executed.
123  * So, users must use Qt with exception support enabled if they use exceptions
124  * in their code.
125  */
126 #  define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) \
127     Q_STATIC_ASSERT_X(false, "Support of exceptions is disabled")
128 
129 #endif // !QT_NO_EXCEPTIONS
130 
131 
132 #define QTRY_LOOP_IMPL(expr, timeoutValue, step) \
133     if (!(expr)) { \
134         QTest::qWait(0); \
135     } \
136     int qt_test_i = 0; \
137     for (; qt_test_i < timeoutValue && !(expr); qt_test_i += step) { \
138         QTest::qWait(step); \
139     }
140 
141 #define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)\
142     if (!(expr)) { \
143         QTRY_LOOP_IMPL((expr), (2 * timeoutValue), step);\
144         if (expr) { \
145             QString msg = QString::fromUtf8("QTestLib: This test case check (\"%1\") failed because the requested timeout (%2 ms) was too short, %3 ms would have been sufficient this time."); \
146             msg = msg.arg(QString::fromUtf8(#expr)).arg(timeoutValue).arg(timeoutValue + qt_test_i); \
147             QFAIL(qPrintable(msg)); \
148         } \
149     }
150 
151 // Ideally we'd use qWaitFor instead of QTRY_LOOP_IMPL, but due
152 // to a compiler bug on MSVC < 2017 we can't (see QTBUG-59096)
153 #define QTRY_IMPL(expr, timeout)\
154     const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \
155     const int qt_test_timeoutValue = timeout; \
156     { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \
157     QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step)\
158 
159 // Will try to wait for the expression to become true while allowing event processing
160 #define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \
161 do { \
162     QTRY_IMPL((expr), timeout);\
163     QVERIFY(expr); \
164 } while (false)
165 
166 #define QTRY_VERIFY(expr) QTRY_VERIFY_WITH_TIMEOUT((expr), 5000)
167 
168 // Will try to wait for the expression to become true while allowing event processing
169 #define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) \
170 do { \
171     QTRY_IMPL((expr), timeout);\
172     QVERIFY2(expr, messageExpression); \
173 } while (false)
174 
175 #define QTRY_VERIFY2(expr, messageExpression) QTRY_VERIFY2_WITH_TIMEOUT((expr), (messageExpression), 5000)
176 
177 // Will try to wait for the comparison to become successful while allowing event processing
178 #define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) \
179 do { \
180     QTRY_IMPL(((expr) == (expected)), timeout);\
181     QCOMPARE((expr), expected); \
182 } while (false)
183 
184 #define QTRY_COMPARE(expr, expected) QTRY_COMPARE_WITH_TIMEOUT((expr), expected, 5000)
185 
186 #define QSKIP_INTERNAL(statement) \
187 do {\
188     QTest::qSkip(static_cast<const char *>(statement), __FILE__, __LINE__);\
189     return;\
190 } while (false)
191 
192 #define QSKIP(statement, ...) QSKIP_INTERNAL(statement)
193 
194 #define QEXPECT_FAIL(dataIndex, comment, mode)\
195 do {\
196     if (!QTest::qExpectFail(dataIndex, static_cast<const char *>(comment), QTest::mode, __FILE__, __LINE__))\
197         return;\
198 } while (false)
199 
200 #define QFETCH(Type, name)\
201     Type name = *static_cast<Type *>(QTest::qData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
202 
203 #define QFETCH_GLOBAL(Type, name)\
204     Type name = *static_cast<Type *>(QTest::qGlobalData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
205 
206 #define QTEST(actual, testElement)\
207 do {\
208     if (!QTest::qTest(actual, testElement, #actual, #testElement, __FILE__, __LINE__))\
209         return;\
210 } while (false)
211 
212 #define QWARN(msg)\
213     QTest::qWarn(static_cast<const char *>(msg), __FILE__, __LINE__)
214 
215 #ifdef QT_TESTCASE_BUILDDIR
216 # define QFINDTESTDATA(basepath)\
217     QTest::qFindTestData(basepath, __FILE__, __LINE__, QT_TESTCASE_BUILDDIR)
218 #else
219 # define QFINDTESTDATA(basepath)\
220     QTest::qFindTestData(basepath, __FILE__, __LINE__)
221 #endif
222 
223 # define QEXTRACTTESTDATA(resourcePath) \
224     QTest::qExtractTestData(resourcePath)
225 
226 class QObject;
227 class QTestData;
228 
229 #define QTEST_COMPARE_DECL(KLASS)\
230     template<> Q_TESTLIB_EXPORT char *toString<KLASS >(const KLASS &);
231 
232 namespace QTest
233 {
234     namespace Internal {
235 
236     template<typename T> // Output registered enums
toString(T e)237     inline typename std::enable_if<QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(T e)
238     {
239         QMetaEnum me = QMetaEnum::fromType<T>();
240         return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes
241     }
242 
243     template <typename T> // Fallback
toString(const T &)244     inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value, char*>::type toString(const T &)
245     {
246         return nullptr;
247     }
248 
249     template<typename F> // Output QFlags of registered enumerations
toString(QFlags<F> f)250     inline typename std::enable_if<QtPrivate::IsQEnumHelper<F>::Value, char*>::type toString(QFlags<F> f)
251     {
252         const QMetaEnum me = QMetaEnum::fromType<F>();
253         return qstrdup(me.valueToKeys(int(f)).constData());
254     }
255 
256     template <typename F> // Fallback: Output hex value
toString(QFlags<F> f)257     inline typename std::enable_if<!QtPrivate::IsQEnumHelper<F>::Value, char*>::type toString(QFlags<F> f)
258     {
259         const size_t space = 3 + 2 * sizeof(unsigned); // 2 for 0x, two hex digits per byte, 1 for '\0'
260         char *msg = new char[space];
261         qsnprintf(msg, space, "0x%x", unsigned(f));
262         return msg;
263     }
264 
265     } // namespace Internal
266 
267     template<typename T>
toString(const T & t)268     inline char *toString(const T &t)
269     {
270         return Internal::toString(t);
271     }
272 
273     template <typename T1, typename T2>
274     inline char *toString(const QPair<T1, T2> &pair);
275 
276     template <typename T1, typename T2>
277     inline char *toString(const std::pair<T1, T2> &pair);
278 
279     template <class... Types>
280     inline char *toString(const std::tuple<Types...> &tuple);
281 
282     Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length);
283     Q_TESTLIB_EXPORT char *toPrettyCString(const char *unicode, int length);
284     Q_TESTLIB_EXPORT char *toPrettyUnicode(QStringView string);
285     Q_TESTLIB_EXPORT char *toString(const char *);
286     Q_TESTLIB_EXPORT char *toString(const void *);
287 
288     Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = nullptr);
289     Q_TESTLIB_EXPORT int qRun();
290     Q_TESTLIB_EXPORT void qCleanup();
291 
292     Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = nullptr);
293     Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments);
294 
295     Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = nullptr);
296 
297     Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description,
298                                  const char *file, int line);
299     Q_TESTLIB_EXPORT void qFail(const char *statementStr, const char *file, int line);
300     Q_TESTLIB_EXPORT void qSkip(const char *message, const char *file, int line);
301     Q_TESTLIB_EXPORT bool qExpectFail(const char *dataIndex, const char *comment, TestFailMode mode,
302                            const char *file, int line);
303     Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = nullptr, int line = 0);
304     Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message);
305 #if QT_CONFIG(regularexpression)
306     Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const QRegularExpression &messagePattern);
307 #endif
308 
309 #if QT_CONFIG(temporaryfile)
310     Q_TESTLIB_EXPORT QSharedPointer<QTemporaryDir> qExtractTestData(const QString &dirName);
311 #endif
312     Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr);
313     Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr);
314 
315     Q_TESTLIB_EXPORT void *qData(const char *tagName, int typeId);
316     Q_TESTLIB_EXPORT void *qGlobalData(const char *tagName, int typeId);
317     Q_TESTLIB_EXPORT void *qElementData(const char *elementName, int metaTypeId);
318     Q_TESTLIB_EXPORT QObject *testObject();
319 
320     Q_TESTLIB_EXPORT const char *currentAppName();
321 
322     Q_TESTLIB_EXPORT const char *currentTestFunction();
323     Q_TESTLIB_EXPORT const char *currentDataTag();
324     Q_TESTLIB_EXPORT bool currentTestFailed();
325 
326     Q_TESTLIB_EXPORT Qt::Key asciiToKey(char ascii);
327     Q_TESTLIB_EXPORT char keyToAscii(Qt::Key key);
328 
329     Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *failureMsg,
330                                          char *val1, char *val2,
331                                          const char *actual, const char *expected,
332                                          const char *file, int line);
333     Q_TESTLIB_EXPORT void qSleep(int ms);
334     Q_TESTLIB_EXPORT void addColumnInternal(int id, const char *name);
335 
336     template <typename T>
337     inline void addColumn(const char *name, T * = nullptr)
338     {
339         using QIsSameTConstChar = std::is_same<T, const char*>;
340         Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
341         addColumnInternal(qMetaTypeId<T>(), name);
342     }
343     Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag);
344     Q_TESTLIB_EXPORT QTestData &addRow(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
345 
346 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
347     // kept after adding implementation of <T1, T2> out of paranoia:
348     template <typename T>
qCompare(T const & t1,T const & t2,const char * actual,const char * expected,const char * file,int line)349     inline bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected,
350                         const char *file, int line)
351     {
352         return compare_helper(t1 == t2, "Compared values are not the same",
353                               toString(t1), toString(t2), actual, expected, file, line);
354     }
355 #endif
356 
357     Q_TESTLIB_EXPORT bool qCompare(qfloat16 const &t1, qfloat16 const &t2,
358                     const char *actual, const char *expected, const char *file, int line);
359 
360     Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2,
361                     const char *actual, const char *expected, const char *file, int line);
362 
363     Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2,
364                     const char *actual, const char *expected, const char *file, int line);
365 
366     Q_TESTLIB_EXPORT bool qCompare(int t1, int t2, const char *actual, const char *expected,
367                                    const char *file, int line);
368 
369     Q_TESTLIB_EXPORT bool qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected,
370                                    const char *file, int line);
371 
372     Q_TESTLIB_EXPORT bool qCompare(QStringView t1, QStringView t2,
373                                    const char *actual, const char *expected,
374                                    const char *file, int line);
375     Q_TESTLIB_EXPORT bool qCompare(QStringView t1, const QLatin1String &t2,
376                                    const char *actual, const char *expected,
377                                    const char *file, int line);
378     Q_TESTLIB_EXPORT bool qCompare(const QLatin1String &t1, QStringView t2,
379                                    const char *actual, const char *expected,
380                                    const char *file, int line);
qCompare(const QString & t1,const QString & t2,const char * actual,const char * expected,const char * file,int line)381     inline bool qCompare(const QString &t1, const QString &t2,
382                          const char *actual, const char *expected,
383                          const char *file, int line)
384     {
385         return qCompare(QStringView(t1), QStringView(t2), actual, expected, file, line);
386     }
qCompare(const QString & t1,const QLatin1String & t2,const char * actual,const char * expected,const char * file,int line)387     inline bool qCompare(const QString &t1, const QLatin1String &t2,
388                          const char *actual, const char *expected,
389                          const char *file, int line)
390     {
391         return qCompare(QStringView(t1), t2, actual, expected, file, line);
392     }
qCompare(const QLatin1String & t1,const QString & t2,const char * actual,const char * expected,const char * file,int line)393     inline bool qCompare(const QLatin1String &t1, const QString &t2,
394                          const char *actual, const char *expected,
395                          const char *file, int line)
396     {
397         return qCompare(t1, QStringView(t2), actual, expected, file, line);
398     }
399 
compare_ptr_helper(const volatile void * t1,const volatile void * t2,const char * actual,const char * expected,const char * file,int line)400     inline bool compare_ptr_helper(const volatile void *t1, const volatile void *t2, const char *actual,
401                                    const char *expected, const char *file, int line)
402     {
403         return compare_helper(t1 == t2, "Compared pointers are not the same",
404                               toString(t1), toString(t2), actual, expected, file, line);
405     }
406 
compare_ptr_helper(const volatile void * t1,std::nullptr_t,const char * actual,const char * expected,const char * file,int line)407     inline bool compare_ptr_helper(const volatile void *t1, std::nullptr_t, const char *actual,
408                                    const char *expected, const char *file, int line)
409     {
410         return compare_helper(t1 == nullptr, "Compared pointers are not the same",
411                               toString(t1), toString(nullptr), actual, expected, file, line);
412     }
413 
compare_ptr_helper(std::nullptr_t,const volatile void * t2,const char * actual,const char * expected,const char * file,int line)414     inline bool compare_ptr_helper(std::nullptr_t, const volatile void *t2, const char *actual,
415                                    const char *expected, const char *file, int line)
416     {
417         return compare_helper(nullptr == t2, "Compared pointers are not the same",
418                               toString(nullptr), toString(t2), actual, expected, file, line);
419     }
420 
421     Q_TESTLIB_EXPORT bool compare_string_helper(const char *t1, const char *t2, const char *actual,
422                                       const char *expected, const char *file, int line);
423 
424     Q_TESTLIB_EXPORT char *formatString(const char *prefix, const char *suffix, size_t numArguments, ...);
425 
426 #ifndef Q_QDOC
427     QTEST_COMPARE_DECL(short)
QTEST_COMPARE_DECL(ushort)428     QTEST_COMPARE_DECL(ushort)
429     QTEST_COMPARE_DECL(int)
430     QTEST_COMPARE_DECL(uint)
431     QTEST_COMPARE_DECL(long)
432     QTEST_COMPARE_DECL(ulong)
433     QTEST_COMPARE_DECL(qint64)
434     QTEST_COMPARE_DECL(quint64)
435 
436     QTEST_COMPARE_DECL(float)
437     QTEST_COMPARE_DECL(double)
438     QTEST_COMPARE_DECL(qfloat16)
439     QTEST_COMPARE_DECL(char)
440     QTEST_COMPARE_DECL(signed char)
441     QTEST_COMPARE_DECL(unsigned char)
442     QTEST_COMPARE_DECL(bool)
443 #endif
444 
445     template <typename T1, typename T2>
446     inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected,
447                          const char *file, int line)
448     {
449         return compare_helper(t1 == t2, "Compared values are not the same",
450                               toString(t1), toString(t2), actual, expected, file, line);
451     }
452 
qCompare(double const & t1,float const & t2,const char * actual,const char * expected,const char * file,int line)453     inline bool qCompare(double const &t1, float const &t2, const char *actual,
454                                  const char *expected, const char *file, int line)
455     {
456         return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
457     }
458 
qCompare(float const & t1,double const & t2,const char * actual,const char * expected,const char * file,int line)459     inline bool qCompare(float const &t1, double const &t2, const char *actual,
460                                  const char *expected, const char *file, int line)
461     {
462         return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
463     }
464 
465     template <typename T>
qCompare(const T * t1,const T * t2,const char * actual,const char * expected,const char * file,int line)466     inline bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected,
467                         const char *file, int line)
468     {
469         return compare_ptr_helper(t1, t2, actual, expected, file, line);
470     }
471     template <typename T>
qCompare(T * t1,T * t2,const char * actual,const char * expected,const char * file,int line)472     inline bool qCompare(T *t1, T *t2, const char *actual, const char *expected,
473                         const char *file, int line)
474     {
475         return compare_ptr_helper(t1, t2, actual, expected, file, line);
476     }
477 
478     template <typename T>
qCompare(T * t1,std::nullptr_t,const char * actual,const char * expected,const char * file,int line)479     inline bool qCompare(T *t1, std::nullptr_t, const char *actual, const char *expected,
480                         const char *file, int line)
481     {
482         return compare_ptr_helper(t1, nullptr, actual, expected, file, line);
483     }
484     template <typename T>
qCompare(std::nullptr_t,T * t2,const char * actual,const char * expected,const char * file,int line)485     inline bool qCompare(std::nullptr_t, T *t2, const char *actual, const char *expected,
486                         const char *file, int line)
487     {
488         return compare_ptr_helper(nullptr, t2, actual, expected, file, line);
489     }
490 
491     template <typename T1, typename T2>
qCompare(const T1 * t1,const T2 * t2,const char * actual,const char * expected,const char * file,int line)492     inline bool qCompare(const T1 *t1, const T2 *t2, const char *actual, const char *expected,
493                         const char *file, int line)
494     {
495         return compare_ptr_helper(t1, static_cast<const T1 *>(t2), actual, expected, file, line);
496     }
497     template <typename T1, typename T2>
qCompare(T1 * t1,T2 * t2,const char * actual,const char * expected,const char * file,int line)498     inline bool qCompare(T1 *t1, T2 *t2, const char *actual, const char *expected,
499                         const char *file, int line)
500     {
501         return compare_ptr_helper(const_cast<const T1 *>(t1),
502                 static_cast<const T1 *>(const_cast<const T2 *>(t2)), actual, expected, file, line);
503     }
qCompare(const char * t1,const char * t2,const char * actual,const char * expected,const char * file,int line)504     inline bool qCompare(const char *t1, const char *t2, const char *actual,
505                                        const char *expected, const char *file, int line)
506     {
507         return compare_string_helper(t1, t2, actual, expected, file, line);
508     }
qCompare(char * t1,char * t2,const char * actual,const char * expected,const char * file,int line)509     inline bool qCompare(char *t1, char *t2, const char *actual, const char *expected,
510                         const char *file, int line)
511     {
512         return compare_string_helper(t1, t2, actual, expected, file, line);
513     }
514 
515     /* The next two overloads are for MSVC that shows problems with implicit
516        conversions
517      */
qCompare(char * t1,const char * t2,const char * actual,const char * expected,const char * file,int line)518     inline bool qCompare(char *t1, const char *t2, const char *actual,
519                          const char *expected, const char *file, int line)
520     {
521         return compare_string_helper(t1, t2, actual, expected, file, line);
522     }
qCompare(const char * t1,char * t2,const char * actual,const char * expected,const char * file,int line)523     inline bool qCompare(const char *t1, char *t2, const char *actual,
524                          const char *expected, const char *file, int line)
525     {
526         return compare_string_helper(t1, t2, actual, expected, file, line);
527     }
528 
529     template <class T>
qTest(const T & actual,const char * elementName,const char * actualStr,const char * expected,const char * file,int line)530     inline bool qTest(const T& actual, const char *elementName, const char *actualStr,
531                      const char *expected, const char *file, int line)
532     {
533         return qCompare(actual, *static_cast<const T *>(QTest::qElementData(elementName,
534                        qMetaTypeId<T>())), actualStr, expected, file, line);
535     }
536 }
537 
538 #undef QTEST_COMPARE_DECL
539 
540 QT_END_NAMESPACE
541 
542 #endif
543