7#include <QtTest/qttestglobal.h>
8#include <QtTest/qtesttostring.h>
10#include <QtCore/qstring.h>
11#include <QtCore/qnamespace.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qmetaobject.h>
14#include <QtCore/qsharedpointer.h>
15#include <QtCore/qtemporarydir.h>
16#include <QtCore/qthread.h>
22#include <QtCore/qxpfunctional.h>
23#include <QtCore/qxptype_traits.h>
24#include <QtCore/q20utility.h>
28#ifndef QT_NO_EXCEPTIONS
34#ifndef QT_NO_EXCEPTIONS
36#ifdef QTEST_THROW_ON_FAIL
37# define QTEST_FAIL_ACTION QTest::Internal::throwOnFail()
39# define QTEST_FAIL_ACTION do { QTest::Internal::maybeThrowOnFail(); return; } while (false)
42#ifdef QTEST_THROW_ON_SKIP
43# define QTEST_SKIP_ACTION QTest::Internal::throwOnSkip()
45# define QTEST_SKIP_ACTION do { QTest::Internal::maybeThrowOnSkip(); return; } while (false)
49# if defined(QTEST_THROW_ON_FAIL) || defined(QTEST_THROW_ON_SKIP)
50# error QTEST_THROW_ON_FAIL/SKIP require exception support enabled.
55# define QTEST_FAIL_ACTION return
59# define QTEST_SKIP_ACTION return
63class QRegularExpression;
65#define QVERIFY(statement) do
67 if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))
69}while (false)
71#define QFAIL(message) do
73 QTest::qFail(static_cast<const char *>(message), __FILE__, __LINE__);
75}while (false)
77#define QVERIFY2(statement, description) do
80 if (!QTest::qVerify(true, #statement, static_cast<const char *>(description), __FILE__, __LINE__))
83 if (!QTest::qVerify(false, #statement, static_cast<const char *>(description), __FILE__, __LINE__))
86}while (false)
88#define QCOMPARE(actual, expected) do
90 if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))
92}while (false)
94#define QCOMPARE_OP_IMPL(lhs, rhs, op, opId) do
96 if (!QTest::qCompareOp<QTest::ComparisonOperation::opId>(lhs, rhs, #lhs, #rhs, __FILE__, __LINE__))
98}while (false)
103#define QCOMPARE_LE(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, <=, LessThanOrEqual)
104#define QCOMPARE_GT(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, >, GreaterThan)
105#define QCOMPARE_GE(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, >=, GreaterThanOrEqual)
107#ifndef QT_NO_EXCEPTIONS
109# define QVERIFY_THROWS_NO_EXCEPTION(...)
115 QTest::qCaught(nullptr, __FILE__, __LINE__);
121#if QT_DEPRECATED_SINCE(6
, 3
)
123QT_DEPRECATED_VERSION_X_6_3(
"Don't use QVERIFY_EXCEPTION_THROWN(expr, type) anymore, "
124 "use QVERIFY_THROWS_EXCEPTION(type, expr...) instead")
125inline void useVerifyThrowsException() {}
127# define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype)
128 QVERIFY_THROWS_EXCEPTION(exceptiontype, QTest::useVerifyThrowsException(); expression)
131# define QVERIFY_THROWS_EXCEPTION(exceptiontype, ...)
133 bool qverify_throws_exception_did_not_throw = false;
136 QTest::qFail("Expected exception of type " #exceptiontype " to be thrown"
137 " but no exception caught", __FILE__, __LINE__);
138 qverify_throws_exception_did_not_throw = true;
139 } QT_CATCH (const exceptiontype &) {
142 QTest::qCaught(#exceptiontype, __FILE__, __LINE__);
145 if (qverify_throws_exception_did_not_throw)
152
153
154
155
156
157
158# define QVERIFY_THROWS_EXCEPTION(...)
159 static_assert(false, "Support for exceptions is disabled")
160# define QVERIFY_THROWS_NO_EXCEPTION(...)
161 static_assert(false, "Support for exceptions is disabled")
166
167
168
169
170
171
172
175#define QTRY_LOOP_IMPL(expr, timeoutValue, step)
179 std::chrono::milliseconds timeoutValueMs(timeoutValue);
180 std::chrono::milliseconds stepMs(step);
181 auto qt_test_i = std::chrono::milliseconds(0
);
182 for (; qt_test_i < timeoutValueMs && !(QTest::runningTest() && QTest::currentTestResolved())
183 && !(expr); qt_test_i += stepMs) {
184 QTest::qWait(stepMs);
188#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)
189 if (!(QTest::runningTest() && QTest::currentTestResolved()) && !(expr)) {
192 QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(
193 u8""
#expr, timeoutValue, timeoutValue + qt_test_i)));
197#define QTRY_IMPL(expr, timeoutAsGiven)
198 const auto qt_test_timeoutAsMs = [&] {
200 using namespace std::chrono_literals;
201 return std::chrono::milliseconds{timeoutAsGiven};
203 const auto qt_test_step = qt_test_timeoutAsMs < std::chrono::milliseconds(350
)
204 ? qt_test_timeoutAsMs / 7
+ std::chrono::milliseconds(1
)
205 : std::chrono::milliseconds(50
);
211#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) do
215}while (false)
218 expr, QTest::defaultTryTimeout.load(std::memory_order_relaxed))
221#define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) do
224 QVERIFY2(expr, messageExpression); \
225}while (false)
227#define QTRY_VERIFY2(expr, messageExpression)
229 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
232#define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) do
236}while (false)
238#define QTRY_COMPARE(expr, expected)
240 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
242#define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(computed, baseline, op, opId, timeout) do
244 using Q_Cmp = QTest::Internal::Compare<QTest::ComparisonOperation::opId>;
245 QTRY_IMPL(Q_Cmp::compare((computed), (baseline)), timeout)
247}while (false)
249#define QTRY_COMPARE_EQ_WITH_TIMEOUT(computed, baseline, timeout)
252#define QTRY_COMPARE_EQ(computed, baseline)
254 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
256#define QTRY_COMPARE_NE_WITH_TIMEOUT(computed, baseline, timeout)
259#define QTRY_COMPARE_NE(computed, baseline)
261 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
263#define QTRY_COMPARE_LT_WITH_TIMEOUT(computed, baseline, timeout)
266#define QTRY_COMPARE_LT(computed, baseline)
268 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
270#define QTRY_COMPARE_LE_WITH_TIMEOUT(computed, baseline, timeout)
273#define QTRY_COMPARE_LE(computed, baseline)
275 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
277#define QTRY_COMPARE_GT_WITH_TIMEOUT(computed, baseline, timeout)
280#define QTRY_COMPARE_GT(computed, baseline)
282 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
284#define QTRY_COMPARE_GE_WITH_TIMEOUT(computed, baseline, timeout)
287#define QTRY_COMPARE_GE(computed, baseline)
289 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
291#define QSKIP_INTERNAL(statement) do
293 QTest::qSkip(static_cast<const char *>(statement), __FILE__, __LINE__);
295}while (false)
299#define QEXPECT_FAIL(dataIndex, comment, mode)do
301 if (!QTest::qExpectFail(dataIndex, static_cast<const char *>(comment), QTest::mode, __FILE__, __LINE__))
303}while (false)
305#define QFETCH(Type, name)
306 Type name = *static_cast<Type *>(QTest::qData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
308#define QFETCH_GLOBAL(Type, name)
309 Type name = *static_cast<Type *>(QTest::qGlobalData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
311#define QTEST(actual, testElement)do
313 if (!QTest::qTest(actual, testElement, #actual, #testElement, __FILE__, __LINE__))
315}while (false)
317#ifdef __cpp_lib_three_way_comparison
318#define QCOMPARE_3WAY(lhs, rhs, order) do
320 if (!QTest::qCompare3Way(lhs, rhs, order, #lhs, #rhs, #order, __FILE__, __LINE__))
322}while (false)
324#define QCOMPARE_3WAY(...)
325 static_assert(false, "QCOMPARE_3WAY test requires C++20 operator<=>()")
328#ifdef QT_TESTCASE_BUILDDIR
330#ifndef QT_TESTCASE_SOURCEDIR
331#define QT_TESTCASE_SOURCEDIR nullptr
334# define QFINDTESTDATA(basepath)
335 QTest::qFindTestData(basepath, __FILE__, __LINE__, QT_TESTCASE_BUILDDIR, QT_TESTCASE_SOURCEDIR)
337# define QFINDTESTDATA(basepath)
338 QTest::qFindTestData(basepath, __FILE__, __LINE__)
341# define QEXTRACTTESTDATA(resourcePath)
342 QTest::qExtractTestData(resourcePath)
360 Q_TESTLIB_EXPORT Q_DECL_COLD_FUNCTION
362 const char *actual,
const char *expected,
363 const char *actualExpr,
364 const char *expectedExpr);
400 using QTest::toString;
401 return toString(*
static_cast<
const T1 *>(arg));
406 using QTest::toString;
407 return toString(
static_cast<
const char *>(arg));
412 return QTest::toString(
nullptr);
417 using QTest::toString;
418 return toString(
static_cast<
const T *>(arg));
433#if QT_CONFIG(batch_test_support) || defined(Q_QDOC)
471 const char *file,
int line);
473 Q_TESTLIB_EXPORT
void qFail(
const char *message,
const char *file,
int line);
476 const char *file,
int line);
478 Q_TESTLIB_EXPORT
void qCaught(
const char *expected,
const char *what,
const char *file,
int line);
480 Q_TESTLIB_EXPORT
void qCaught(
const char *expected,
const char *file,
int line);
481#if QT_DEPRECATED_SINCE(6
, 3
)
486#if QT_CONFIG(regularexpression)
491#if QT_CONFIG(regularexpression)
495#if QT_CONFIG(temporaryfile)
518#if QT_DEPRECATED_SINCE(6
, 4
)
520 "or an overload that takes only failure message, if you "
521 "do not need to stringify the values")
527#if QT_DEPRECATED_SINCE(6
, 8
)
529 "or an overload that takes only failure message, if you "
530 "do not need to stringify the values")
538 const void *actualPtr,
const void *expectedPtr,
539 const char *(*actualFormatter)(
const void *),
540 const char *(*expectedFormatter)(
const void *),
541 const char *actual,
const char *expected,
542 const char *file,
int line);
544 const char *actual,
const char *expected,
545 const char *file,
int line);
548 const void *lhsPtr,
const void *rhsPtr,
549 const char *(*lhsFormatter)(
const void*),
550 const char *(*rhsFormatter)(
const void*),
551 const char *lhsStr,
const char *rhsStr,
552 const char *(*actualOrderFormatter)(
const void *),
553 const char *(*expectedOrderFormatter)(
const void *),
554 const void *actualOrderPtr,
555 const void *expectedOrderPtr,
556 const char *expectedExpression,
557 const char *file,
int line);
561 template <
typename T>
564 using QIsSameTConstChar =
std::is_same<T,
const char*>;
565 static_assert(!QIsSameTConstChar::value,
"const char* is not allowed as a test data format.");
566 addColumnInternal(qMetaTypeId<T>(), name);
572 const char *actual,
const char *expected,
const char *file,
int line);
575 const char *actual,
const char *expected,
const char *file,
int line);
578 const char *actual,
const char *expected,
const char *file,
int line);
581 const char *file,
int line);
583#if QT_POINTER_SIZE == 8
589 const char *file,
int line);
592 const char *actual,
const char *expected,
593 const char *file,
int line);
595 const char *actual,
const char *expected,
596 const char *file,
int line);
598 const char *actual,
const char *expected,
599 const char *file,
int line);
600 inline bool qCompare(
const QString &t1,
const QString &t2,
601 const char *actual,
const char *expected,
602 const char *file,
int line)
604 return qCompare(QStringView(t1), QStringView(t2), actual, expected, file, line);
606 inline bool qCompare(
const QString &t1,
const QLatin1StringView &t2,
607 const char *actual,
const char *expected,
608 const char *file,
int line)
610 return qCompare(QStringView(t1), t2, actual, expected, file, line);
612 inline bool qCompare(
const QLatin1StringView &t1,
const QString &t2,
613 const char *actual,
const char *expected,
614 const char *file,
int line)
616 return qCompare(t1, QStringView(t2), actual, expected, file, line);
620 const char *expected,
const char *file,
int line)
622 auto formatter = Internal::pointerToString<
void>;
623 return compare_helper(t1 == t2,
"Compared pointers are not the same",
624 const_cast<
const void *>(t1),
const_cast<
const void *>(t2),
625 formatter, formatter, actual, expected, file, line);
628 inline bool compare_ptr_helper(
const volatile QObject *t1,
const volatile QObject *t2,
const char *actual,
629 const char *expected,
const char *file,
int line)
631 auto formatter =
Internal::pointerToString<QObject>;
632 return compare_helper(t1 == t2,
"Compared QObject pointers are not the same",
633 const_cast<
const QObject *>(t1),
const_cast<
const QObject *>(t2),
634 formatter, formatter, actual, expected, file, line);
638 const char *expected,
const char *file,
int line)
640 auto lhsFormatter =
Internal::pointerToString<QObject>;
641 auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
642 return compare_helper(t1 ==
nullptr,
"Compared QObject pointers are not the same",
643 const_cast<
const QObject *>(t1),
nullptr,
644 lhsFormatter, rhsFormatter, actual, expected, file, line);
648 const char *expected,
const char *file,
int line)
650 auto lhsFormatter = Internal::genericToString<std::nullptr_t>;
651 auto rhsFormatter =
Internal::pointerToString<QObject>;
652 return compare_helper(
nullptr == t2,
"Compared QObject pointers are not the same",
653 nullptr,
const_cast<
const QObject *>(t2),
654 lhsFormatter, rhsFormatter, actual, expected, file, line);
658 const char *expected,
const char *file,
int line)
660 auto lhsFormatter = Internal::pointerToString<
void>;
661 auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
662 return compare_helper(t1 ==
nullptr,
"Compared pointers are not the same",
663 const_cast<
const void *>(t1),
nullptr,
664 lhsFormatter, rhsFormatter, actual, expected, file, line);
668 const char *expected,
const char *file,
int line)
670 auto lhsFormatter = Internal::genericToString<std::nullptr_t>;
671 auto rhsFormatter = Internal::pointerToString<
void>;
672 return compare_helper(
nullptr == t2,
"Compared pointers are not the same",
673 nullptr,
const_cast<
const void *>(t2),
674 lhsFormatter, rhsFormatter, actual, expected, file, line);
677 template <
typename T1,
typename T2 = T1>
678 inline bool qCompare(
const T1 &t1,
const T2 &t2,
const char *actual,
const char *expected,
679 const char *file,
int line)
682 if constexpr (QtPrivate::is_standard_or_extended_integer_type_v<T1>
683 && QtPrivate::is_standard_or_extended_integer_type_v<T2>) {
684 return compare_helper(q20::cmp_equal(t1, t2),
"Compared values are not the same",
685 std::addressof(t1), std::addressof(t2),
686 genericToString<T1>, genericToString<T2>,
687 actual, expected, file, line);
689 return compare_helper(t1 == t2,
"Compared values are not the same",
690 std::addressof(t1), std::addressof(t2),
691 genericToString<T1>, genericToString<T2>,
692 actual, expected, file, line);
696 inline bool qCompare(
double const &t1,
float const &t2,
const char *actual,
697 const char *expected,
const char *file,
int line)
699 return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
702 inline bool qCompare(
float const &t1,
double const &t2,
const char *actual,
703 const char *expected,
const char *file,
int line)
705 return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
708 template <
typename T>
709 inline bool qCompare(
const T *t1,
const T *t2,
const char *actual,
const char *expected,
710 const char *file,
int line)
712 return compare_ptr_helper(t1, t2, actual, expected, file, line);
714 template <
typename T>
715 inline bool qCompare(T *t1, T *t2,
const char *actual,
const char *expected,
716 const char *file,
int line)
718 return compare_ptr_helper(t1, t2, actual, expected, file, line);
721 template <
typename T>
722 inline bool qCompare(T *t1,
std::nullptr_t,
const char *actual,
const char *expected,
723 const char *file,
int line)
725 return compare_ptr_helper(t1,
nullptr, actual, expected, file, line);
727 template <
typename T>
728 inline bool qCompare(
std::nullptr_t, T *t2,
const char *actual,
const char *expected,
729 const char *file,
int line)
731 return compare_ptr_helper(
nullptr, t2, actual, expected, file, line);
734 template <
typename T1,
typename T2>
735 inline bool qCompare(
const T1 *t1,
const T2 *t2,
const char *actual,
const char *expected,
736 const char *file,
int line)
738 return compare_ptr_helper(t1,
static_cast<
const T1 *>(t2), actual, expected, file, line);
740 template <
typename T1,
typename T2>
741 inline bool qCompare(T1 *t1, T2 *t2,
const char *actual,
const char *expected,
742 const char *file,
int line)
744 return compare_ptr_helper(
const_cast<
const T1 *>(t1),
745 static_cast<
const T1 *>(
const_cast<
const T2 *>(t2)), actual, expected, file, line);
747 inline bool qCompare(
const char *t1,
const char *t2,
const char *actual,
748 const char *expected,
const char *file,
int line)
750 return compare_string_helper(t1, t2, actual, expected, file, line);
752 inline bool qCompare(
char *t1,
char *t2,
const char *actual,
const char *expected,
753 const char *file,
int line)
755 return compare_string_helper(t1, t2, actual, expected, file, line);
759
760
761 inline bool qCompare(
char *t1,
const char *t2,
const char *actual,
762 const char *expected,
const char *file,
int line)
764 return compare_string_helper(t1, t2, actual, expected, file, line);
766 inline bool qCompare(
const char *t1,
char *t2,
const char *actual,
767 const char *expected,
const char *file,
int line)
769 return compare_string_helper(t1, t2, actual, expected, file, line);
773 inline bool qTest(
const T& actual,
const char *elementName,
const char *actualStr,
774 const char *expected,
const char *file,
int line)
776 return qCompare(actual, *
static_cast<
const T *>(QTest::qElementData(elementName,
777 qMetaTypeId<T>())), actualStr, expected, file, line);
780#if QT_DEPRECATED_SINCE(6
, 8
)
789 const char *(*lhsFormatter)(
const void*),
790 const char *(*rhsFormatter)(
const void*),
791 const char *lhsExpr,
const char *rhsExpr,
792 ComparisonOperation op,
const char *file,
int line);
794 template <ComparisonOperation op,
typename T1,
typename T2 = T1>
795 inline bool qCompareOp(T1 &&lhs, T2 &&rhs,
const char *lhsExpr,
const char *rhsExpr,
796 const char *file,
int line)
798 using D1 = std::decay_t<T1>;
799 using D2 = std::decay_t<T2>;
804 auto doReport = [&](
bool result,
const D1 &lhs_,
const D2 &rhs_) {
805 return reportResult(result, std::addressof(lhs_), std::addressof(rhs_),
806 genericToString<D1>, genericToString<D2>,
807 lhsExpr, rhsExpr, op, file, line);
811 bool result = Comparator::compare(
std::forward<T1>(lhs),
std::forward<T2>(rhs));
812 return doReport(result,
std::forward<T1>(lhs),
std::forward<T2>(rhs));
815#if defined(__cpp_lib_three_way_comparison)
823#if defined(__cpp_concepts)
825 "The three-way comparison operator (<=>) is not implemented");
828 "Please provide, as the order parameter, a value "
829 "of one of the Qt::{partial,weak,strong}_ordering or "
830 "std::{partial,weak,strong}_ordering types.");
835 "The expected and actual ordering types should be the same "
836 "strength for proper comparison.");
844 "The result of operator<=>() is not what was expected",
855 template <
typename OrderingType,
typename LHS,
typename RHS = LHS>
857 const char *lhsExpression,
858 const char *rhsExpression,
859 const char *resultExpression,
860 const char *file,
int line) =
delete;
865#define QWARN(msg) QTest::qWarn(static_cast<const char *>(msg), __FILE__, __LINE__)
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
const char * pointerToString(const void *arg)
Q_TESTLIB_EXPORT void maybeThrowOnFail()
Q_TESTLIB_EXPORT void throwOnFail()
Q_TESTLIB_EXPORT void maybeThrowOnSkip()
Q_TESTLIB_EXPORT void throwOnSkip()
const char * genericToString(const void *arg)
const char * genericToString< char * >(const void *arg)
Q_TESTLIB_EXPORT Q_DECL_COLD_FUNCTION const char * formatPropertyTestHelperFailure(char *msg, size_t maxMsgLen, const char *actual, const char *expected, const char *actualExpr, const char *expectedExpr)
void qCompare3Way(LHS &&lhs, RHS &&rhs, OrderingType order, const char *lhsExpression, const char *rhsExpression, const char *resultExpression, const char *file, int line)=delete
Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool qCompare(std::nullptr_t, T *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT int qRun()
Q_TESTLIB_EXPORT bool currentTestResolved()
bool reportResult(bool success, const void *lhs, const void *rhs, const char *(*lhsFormatter)(const void *), const char *(*rhsFormatter)(const void *), const char *lhsExpr, const char *rhsExpr, ComparisonOperation op, const char *file, int line)
Q_TESTLIB_EXPORT bool qCompare(unsigned t1, unsigned t2, const char *actual, const char *expected, const char *file, int line)
bool qCompare(const T1 *t1, const T2 *t2, const char *actual, const char *expected, const char *file, int line)
bool qCompareOp(T1 &&lhs, T2 &&rhs, const char *lhsExpr, const char *rhsExpr, const char *file, int line)
Q_TESTLIB_EXPORT bool compare_3way_helper(bool success, const char *failureMsg, const void *lhsPtr, const void *rhsPtr, const char *(*lhsFormatter)(const void *), const char *(*rhsFormatter)(const void *), const char *lhsStr, const char *rhsStr, const char *(*actualOrderFormatter)(const void *), const char *(*expectedOrderFormatter)(const void *), const void *actualOrderPtr, const void *expectedOrderPtr, const char *expectedExpression, const char *file, int line)
Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description, const char *file, int line)
bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line)
bool qCompare(T1 *t1, T2 *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT QTestData Q_TESTLIB_EXPORT bool qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT const char * currentTestFunction()
Returns the name of the test function that is currently executed.
Q_TESTLIB_EXPORT char keyToAscii(Qt::Key key)
Q_TESTLIB_EXPORT bool runningTest()
bool qCompare(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir=nullptr)
bool compare_ptr_helper(const volatile QObject *t1, const volatile QObject *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void * qElementData(const char *elementName, int metaTypeId)
bool qCompare(char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT bool qCompare(int t1, int t2, const char *actual, const char *expected, const char *file, int line)
bool qCompare(const char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
void setThrowOnFail(bool enable) noexcept
bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected, 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 * qData(const char *tagName, int typeId)
Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT bool currentTestFailed()
Returns true if the current test function has failed, otherwise false.
Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc=0, char **argv=nullptr)
void setThrowOnSkip(bool enable) noexcept
bool qCompare(T *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
bool compare_ptr_helper(std::nullptr_t, const volatile void *t2, const char *actual, const char *expected, const char *file, int line)
bool qTest(const T &actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT bool qCompare(const QLatin1StringView &t1, QStringView t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT const char * currentGlobalDataTag()
Returns the name of the current global test data.
Q_TESTLIB_EXPORT void failOnWarning()
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qCaught(const char *expected, const char *what, const char *file, int line)
bool compare_ptr_helper(const volatile QObject *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message)
Ignores messages created by qDebug(), qInfo() or qWarning().
bool compare_ptr_helper(const volatile void *t1, const volatile void *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void failOnWarning(const char *message)
bool compare_ptr_helper(const volatile void *t1, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void qSkip(const char *message, const char *file, int line)
bool qCompare(QString const &t1, QLatin1StringView const &t2, const char *actual, const char *expected, const char *file, int line)
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qCaught(const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT const char * currentDataTag()
Returns the name of the current test data.
bool qCompare(T *t1, T *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc=0, char **argv=nullptr)
Executes tests declared in testObject.
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *failureMsg, const void *actualPtr, const void *expectedPtr, const char *(*actualFormatter)(const void *), const char *(*expectedFormatter)(const void *), const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *failureMsg, const char *actual, const char *expected, const char *file, int line)
bool qCompare(char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void qCleanup()
Q_TESTLIB_EXPORT void addColumnInternal(int id, const char *name)
Q_DECL_COLD_FUNCTION Q_TESTLIB_EXPORT void qFail(const char *message, const char *file, int line)
bool qCompare(float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT void * qGlobalData(const char *tagName, int typeId)
Q_TESTLIB_EXPORT bool qCompare(QStringView t1, const QLatin1StringView &t2, const char *actual, const char *expected, const char *file, int line)
bool qCompare(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
bool compare_ptr_helper(std::nullptr_t, const volatile QObject *t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT const char * currentAppName()
Returns the name of the binary that is currently executed.
void addColumn(const char *name, T *=nullptr)
Adds a column with type {T} to the current test data.
#define QTRY_COMPARE_LE_WITH_TIMEOUT(computed, baseline, timeout)
#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)
#define QSKIP_INTERNAL(statement)
#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout)
#define QTRY_LOOP_IMPL(expr, timeoutValue, step)
#define QTRY_COMPARE_GE_WITH_TIMEOUT(computed, baseline, timeout)
#define QTRY_COMPARE_NE_WITH_TIMEOUT(computed, baseline, timeout)
#define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout)
#define QTRY_COMPARE_LT_WITH_TIMEOUT(computed, baseline, timeout)
#define QTRY_COMPARE_GT_WITH_TIMEOUT(computed, baseline, timeout)
#define QTEST_FAIL_ACTION
#define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout)
#define QCOMPARE_OP_IMPL(lhs, rhs, op, opId)
#define QCOMPARE(actual, expected)
#define QVERIFY(statement)
#define QTRY_COMPARE_EQ_WITH_TIMEOUT(computed, baseline, timeout)
#define QVERIFY2(statement, description)
#define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(computed, baseline, op, opId, timeout)
#define QTEST_SKIP_ACTION
#define QTRY_IMPL(expr, timeoutAsGiven)