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>
21#include <QtCore/qxpfunctional.h>
22#include <QtCore/qxptype_traits.h>
23#include <QtCore/q20utility.h>
27#ifndef QT_NO_EXCEPTIONS
33#ifndef QT_NO_EXCEPTIONS
35#ifdef QTEST_THROW_ON_FAIL
36# define QTEST_FAIL_ACTION QTest::Internal::throwOnFail()
38# define QTEST_FAIL_ACTION do { QTest::Internal::maybeThrowOnFail(); return; } while (false)
41#ifdef QTEST_THROW_ON_SKIP
42# define QTEST_SKIP_ACTION QTest::Internal::throwOnSkip()
44# define QTEST_SKIP_ACTION do { QTest::Internal::maybeThrowOnSkip(); return; } while (false)
48# if defined(QTEST_THROW_ON_FAIL) || defined(QTEST_THROW_ON_SKIP)
49# error QTEST_THROW_ON_FAIL/SKIP require exception support enabled.
54# define QTEST_FAIL_ACTION return
58# define QTEST_SKIP_ACTION return
62class QRegularExpression;
64#define QVERIFY(statement) do
66 if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))
68}while (false)
70#define QFAIL(message) do
72 QTest::qFail(static_cast<const char *>(message), __FILE__, __LINE__);
74}while (false)
76#define QVERIFY2(statement, description) do
79 if (!QTest::qVerify(true, #statement, static_cast<const char *>(description), __FILE__, __LINE__))
82 if (!QTest::qVerify(false, #statement, static_cast<const char *>(description), __FILE__, __LINE__))
85}while (false)
87#define QCOMPARE(actual, expected) do
89 if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))
91}while (false)
93#define QCOMPARE_OP_IMPL(lhs, rhs, op, opId) do
95 if (!QTest::qCompareOp<QTest::ComparisonOperation::opId>(lhs, rhs, #lhs, #rhs, __FILE__, __LINE__))
97}while (false)
102#define QCOMPARE_LE(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, <=, LessThanOrEqual)
103#define QCOMPARE_GT(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, >, GreaterThan)
104#define QCOMPARE_GE(computed, baseline) QCOMPARE_OP_IMPL(computed, baseline, >=, GreaterThanOrEqual)
106#ifndef QT_NO_EXCEPTIONS
108# define QVERIFY_THROWS_NO_EXCEPTION(...)
114 QTest::qCaught(nullptr, __FILE__, __LINE__);
120#if QT_DEPRECATED_SINCE(6
, 3
)
122QT_DEPRECATED_VERSION_X_6_3(
"Don't use QVERIFY_EXCEPTION_THROWN(expr, type) anymore, "
123 "use QVERIFY_THROWS_EXCEPTION(type, expr...) instead")
124inline void useVerifyThrowsException() {}
126# define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype)
127 QVERIFY_THROWS_EXCEPTION(exceptiontype, QTest::useVerifyThrowsException(); expression)
130# define QVERIFY_THROWS_EXCEPTION(exceptiontype, ...)
132 bool qverify_throws_exception_did_not_throw = false;
135 QTest::qFail("Expected exception of type " #exceptiontype " to be thrown"
136 " but no exception caught", __FILE__, __LINE__);
137 qverify_throws_exception_did_not_throw = true;
138 } QT_CATCH (const exceptiontype &) {
141 QTest::qCaught(#exceptiontype, __FILE__, __LINE__);
144 if (qverify_throws_exception_did_not_throw)
151
152
153
154
155
156
157# define QVERIFY_THROWS_EXCEPTION(...)
158 static_assert(false, "Support for exceptions is disabled")
159# define QVERIFY_THROWS_NO_EXCEPTION(...)
160 static_assert(false, "Support for exceptions is disabled")
165
166
167
168
169
170
171
174#define QTRY_LOOP_IMPL(expr, timeoutValue, step)
178 std::chrono::milliseconds timeoutValueMs(timeoutValue);
179 std::chrono::milliseconds stepMs(step);
180 auto qt_test_i = std::chrono::milliseconds(0
);
181 for (; qt_test_i < timeoutValueMs && !(QTest::runningTest() && QTest::currentTestResolved())
182 && !(expr); qt_test_i += stepMs) {
183 QTest::qWait(stepMs);
187#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)
188 if (!(QTest::runningTest() && QTest::currentTestResolved()) && !(expr)) {
191 QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(
192 u8""
#expr, timeoutValue, timeoutValue + qt_test_i)));
196#define QTRY_IMPL(expr, timeoutAsGiven)
197 const auto qt_test_timeoutAsMs = [&] {
199 using namespace std::chrono_literals;
200 return std::chrono::milliseconds{timeoutAsGiven};
202 const auto qt_test_step = qt_test_timeoutAsMs < std::chrono::milliseconds(350
)
203 ? qt_test_timeoutAsMs / 7
+ std::chrono::milliseconds(1
)
204 : std::chrono::milliseconds(50
);
210#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) do
214}while (false)
217 expr, QTest::defaultTryTimeout.load(std::memory_order_relaxed))
220#define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) do
223 QVERIFY2(expr, messageExpression); \
224}while (false)
226#define QTRY_VERIFY2(expr, messageExpression)
228 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
231#define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) do
235}while (false)
237#define QTRY_COMPARE(expr, expected)
239 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
241#define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(computed, baseline, op, opId, timeout) do
243 using Q_Cmp = QTest::Internal::Compare<QTest::ComparisonOperation::opId>;
244 QTRY_IMPL(Q_Cmp::compare((computed), (baseline)), timeout)
246}while (false)
248#define QTRY_COMPARE_EQ_WITH_TIMEOUT(computed, baseline, timeout)
251#define QTRY_COMPARE_EQ(computed, baseline)
253 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
255#define QTRY_COMPARE_NE_WITH_TIMEOUT(computed, baseline, timeout)
258#define QTRY_COMPARE_NE(computed, baseline)
260 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
262#define QTRY_COMPARE_LT_WITH_TIMEOUT(computed, baseline, timeout)
265#define QTRY_COMPARE_LT(computed, baseline)
267 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
269#define QTRY_COMPARE_LE_WITH_TIMEOUT(computed, baseline, timeout)
272#define QTRY_COMPARE_LE(computed, baseline)
274 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
276#define QTRY_COMPARE_GT_WITH_TIMEOUT(computed, baseline, timeout)
279#define QTRY_COMPARE_GT(computed, baseline)
281 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
283#define QTRY_COMPARE_GE_WITH_TIMEOUT(computed, baseline, timeout)
286#define QTRY_COMPARE_GE(computed, baseline)
288 QTest::defaultTryTimeout.load(std::memory_order_relaxed))
290#define QSKIP_INTERNAL(statement) do
292 QTest::qSkip(static_cast<const char *>(statement), __FILE__, __LINE__);
294}while (false)
298#define QEXPECT_FAIL(dataIndex, comment, mode)do
300 if (!QTest::qExpectFail(dataIndex, static_cast<const char *>(comment), QTest::mode, __FILE__, __LINE__))
302}while (false)
304#define QFETCH(Type, name)
305 Type name = *static_cast<Type *>(QTest::qData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
307#define QFETCH_GLOBAL(Type, name)
308 Type name = *static_cast<Type *>(QTest::qGlobalData(#name, ::qMetaTypeId<typename std::remove_cv<Type >::type>()))
310#define QTEST(actual, testElement)do
312 if (!QTest::qTest(actual, testElement, #actual, #testElement, __FILE__, __LINE__))
314}while (false)
316#ifdef __cpp_lib_three_way_comparison
317#define QCOMPARE_3WAY(lhs, rhs, order) do
319 if (!QTest::qCompare3Way(lhs, rhs, order, #lhs, #rhs, #order, __FILE__, __LINE__))
321}while (false)
323#define QCOMPARE_3WAY(...)
324 static_assert(false, "QCOMPARE_3WAY test requires C++20 operator<=>()")
327#ifdef QT_TESTCASE_BUILDDIR
329#ifndef QT_TESTCASE_SOURCEDIR
330#define QT_TESTCASE_SOURCEDIR nullptr
333# define QFINDTESTDATA(basepath)
334 QTest::qFindTestData(basepath, __FILE__, __LINE__, QT_TESTCASE_BUILDDIR, QT_TESTCASE_SOURCEDIR)
336# define QFINDTESTDATA(basepath)
337 QTest::qFindTestData(basepath, __FILE__, __LINE__)
340# define QEXTRACTTESTDATA(resourcePath)
341 QTest::qExtractTestData(resourcePath)
359 Q_TESTLIB_EXPORT Q_DECL_COLD_FUNCTION
361 const char *actual,
const char *expected,
362 const char *actualExpr,
363 const char *expectedExpr);
399 using QTest::toString;
400 return toString(*
static_cast<
const T1 *>(arg));
405 using QTest::toString;
406 return toString(
static_cast<
const char *>(arg));
411 return QTest::toString(
nullptr);
416 using QTest::toString;
417 return toString(
static_cast<
const T *>(arg));
432#if QT_CONFIG(batch_test_support) || defined(Q_QDOC)
470 const char *file,
int line);
472 Q_TESTLIB_EXPORT
void qFail(
const char *message,
const char *file,
int line);
475 const char *file,
int line);
477 Q_TESTLIB_EXPORT
void qCaught(
const char *expected,
const char *what,
const char *file,
int line);
479 Q_TESTLIB_EXPORT
void qCaught(
const char *expected,
const char *file,
int line);
480#if QT_DEPRECATED_SINCE(6
, 3
)
485#if QT_CONFIG(regularexpression)
490#if QT_CONFIG(regularexpression)
494#if QT_CONFIG(temporaryfile)
517#if QT_DEPRECATED_SINCE(6
, 4
)
519 "or an overload that takes only failure message, if you "
520 "do not need to stringify the values")
526#if QT_DEPRECATED_SINCE(6
, 8
)
528 "or an overload that takes only failure message, if you "
529 "do not need to stringify the values")
537 const void *actualPtr,
const void *expectedPtr,
538 const char *(*actualFormatter)(
const void *),
539 const char *(*expectedFormatter)(
const void *),
540 const char *actual,
const char *expected,
541 const char *file,
int line);
543 const char *actual,
const char *expected,
544 const char *file,
int line);
547 const void *lhsPtr,
const void *rhsPtr,
548 const char *(*lhsFormatter)(
const void*),
549 const char *(*rhsFormatter)(
const void*),
550 const char *lhsStr,
const char *rhsStr,
551 const char *(*actualOrderFormatter)(
const void *),
552 const char *(*expectedOrderFormatter)(
const void *),
553 const void *actualOrderPtr,
554 const void *expectedOrderPtr,
555 const char *expectedExpression,
556 const char *file,
int line);
560 template <
typename T>
563 using QIsSameTConstChar =
std::is_same<T,
const char*>;
564 static_assert(!QIsSameTConstChar::value,
"const char* is not allowed as a test data format.");
565 addColumnInternal(qMetaTypeId<T>(), name);
571 const char *actual,
const char *expected,
const char *file,
int line);
574 const char *actual,
const char *expected,
const char *file,
int line);
577 const char *actual,
const char *expected,
const char *file,
int line);
580 const char *file,
int line);
582#if QT_POINTER_SIZE == 8
588 const char *file,
int line);
591 const char *actual,
const char *expected,
592 const char *file,
int line);
594 const char *actual,
const char *expected,
595 const char *file,
int line);
597 const char *actual,
const char *expected,
598 const char *file,
int line);
599 inline bool qCompare(
const QString &t1,
const QString &t2,
600 const char *actual,
const char *expected,
601 const char *file,
int line)
603 return qCompare(QStringView(t1), QStringView(t2), actual, expected, file, line);
605 inline bool qCompare(
const QString &t1,
const QLatin1StringView &t2,
606 const char *actual,
const char *expected,
607 const char *file,
int line)
609 return qCompare(QStringView(t1), t2, actual, expected, file, line);
611 inline bool qCompare(
const QLatin1StringView &t1,
const QString &t2,
612 const char *actual,
const char *expected,
613 const char *file,
int line)
615 return qCompare(t1, QStringView(t2), actual, expected, file, line);
619 const char *expected,
const char *file,
int line)
621 auto formatter = Internal::pointerToString<
void>;
622 return compare_helper(t1 == t2,
"Compared pointers are not the same",
623 const_cast<
const void *>(t1),
const_cast<
const void *>(t2),
624 formatter, formatter, actual, expected, file, line);
627 inline bool compare_ptr_helper(
const volatile QObject *t1,
const volatile QObject *t2,
const char *actual,
628 const char *expected,
const char *file,
int line)
630 auto formatter =
Internal::pointerToString<QObject>;
631 return compare_helper(t1 == t2,
"Compared QObject pointers are not the same",
632 const_cast<
const QObject *>(t1),
const_cast<
const QObject *>(t2),
633 formatter, formatter, actual, expected, file, line);
637 const char *expected,
const char *file,
int line)
639 auto lhsFormatter =
Internal::pointerToString<QObject>;
640 auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
641 return compare_helper(t1 ==
nullptr,
"Compared QObject pointers are not the same",
642 const_cast<
const QObject *>(t1),
nullptr,
643 lhsFormatter, rhsFormatter, actual, expected, file, line);
647 const char *expected,
const char *file,
int line)
649 auto lhsFormatter = Internal::genericToString<std::nullptr_t>;
650 auto rhsFormatter =
Internal::pointerToString<QObject>;
651 return compare_helper(
nullptr == t2,
"Compared QObject pointers are not the same",
652 nullptr,
const_cast<
const QObject *>(t2),
653 lhsFormatter, rhsFormatter, actual, expected, file, line);
657 const char *expected,
const char *file,
int line)
659 auto lhsFormatter = Internal::pointerToString<
void>;
660 auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
661 return compare_helper(t1 ==
nullptr,
"Compared pointers are not the same",
662 const_cast<
const void *>(t1),
nullptr,
663 lhsFormatter, rhsFormatter, actual, expected, file, line);
667 const char *expected,
const char *file,
int line)
669 auto lhsFormatter = Internal::genericToString<std::nullptr_t>;
670 auto rhsFormatter = Internal::pointerToString<
void>;
671 return compare_helper(
nullptr == t2,
"Compared pointers are not the same",
672 nullptr,
const_cast<
const void *>(t2),
673 lhsFormatter, rhsFormatter, actual, expected, file, line);
676 template <
typename T1,
typename T2 = T1>
677 inline bool qCompare(
const T1 &t1,
const T2 &t2,
const char *actual,
const char *expected,
678 const char *file,
int line)
681 if constexpr (QtPrivate::is_standard_or_extended_integer_type_v<T1>
682 && QtPrivate::is_standard_or_extended_integer_type_v<T2>) {
683 return compare_helper(q20::cmp_equal(t1, t2),
"Compared values are not the same",
684 std::addressof(t1), std::addressof(t2),
685 genericToString<T1>, genericToString<T2>,
686 actual, expected, file, line);
688 return compare_helper(t1 == t2,
"Compared values are not the same",
689 std::addressof(t1), std::addressof(t2),
690 genericToString<T1>, genericToString<T2>,
691 actual, expected, file, line);
695 inline bool qCompare(
double const &t1,
float const &t2,
const char *actual,
696 const char *expected,
const char *file,
int line)
698 return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
701 inline bool qCompare(
float const &t1,
double const &t2,
const char *actual,
702 const char *expected,
const char *file,
int line)
704 return qCompare(qreal(t1), qreal(t2), actual, expected, file, line);
707 template <
typename T>
708 inline bool qCompare(
const T *t1,
const T *t2,
const char *actual,
const char *expected,
709 const char *file,
int line)
711 return compare_ptr_helper(t1, t2, actual, expected, file, line);
713 template <
typename T>
714 inline bool qCompare(T *t1, T *t2,
const char *actual,
const char *expected,
715 const char *file,
int line)
717 return compare_ptr_helper(t1, t2, actual, expected, file, line);
720 template <
typename T>
721 inline bool qCompare(T *t1,
std::nullptr_t,
const char *actual,
const char *expected,
722 const char *file,
int line)
724 return compare_ptr_helper(t1,
nullptr, actual, expected, file, line);
726 template <
typename T>
727 inline bool qCompare(
std::nullptr_t, T *t2,
const char *actual,
const char *expected,
728 const char *file,
int line)
730 return compare_ptr_helper(
nullptr, t2, actual, expected, file, line);
733 template <
typename T1,
typename T2>
734 inline bool qCompare(
const T1 *t1,
const T2 *t2,
const char *actual,
const char *expected,
735 const char *file,
int line)
737 return compare_ptr_helper(t1,
static_cast<
const T1 *>(t2), actual, expected, file, line);
739 template <
typename T1,
typename T2>
740 inline bool qCompare(T1 *t1, T2 *t2,
const char *actual,
const char *expected,
741 const char *file,
int line)
743 return compare_ptr_helper(
const_cast<
const T1 *>(t1),
744 static_cast<
const T1 *>(
const_cast<
const T2 *>(t2)), actual, expected, file, line);
746 inline bool qCompare(
const char *t1,
const char *t2,
const char *actual,
747 const char *expected,
const char *file,
int line)
749 return compare_string_helper(t1, t2, actual, expected, file, line);
751 inline bool qCompare(
char *t1,
char *t2,
const char *actual,
const char *expected,
752 const char *file,
int line)
754 return compare_string_helper(t1, t2, actual, expected, file, line);
758
759
760 inline bool qCompare(
char *t1,
const char *t2,
const char *actual,
761 const char *expected,
const char *file,
int line)
763 return compare_string_helper(t1, t2, actual, expected, file, line);
765 inline bool qCompare(
const char *t1,
char *t2,
const char *actual,
766 const char *expected,
const char *file,
int line)
768 return compare_string_helper(t1, t2, actual, expected, file, line);
772 inline bool qTest(
const T& actual,
const char *elementName,
const char *actualStr,
773 const char *expected,
const char *file,
int line)
775 return qCompare(actual, *
static_cast<
const T *>(QTest::qElementData(elementName,
776 qMetaTypeId<T>())), actualStr, expected, file, line);
779#if QT_DEPRECATED_SINCE(6
, 8
)
788 const char *(*lhsFormatter)(
const void*),
789 const char *(*rhsFormatter)(
const void*),
790 const char *lhsExpr,
const char *rhsExpr,
791 ComparisonOperation op,
const char *file,
int line);
793 template <ComparisonOperation op,
typename T1,
typename T2 = T1>
794 inline bool qCompareOp(T1 &&lhs, T2 &&rhs,
const char *lhsExpr,
const char *rhsExpr,
795 const char *file,
int line)
797 using D1 = std::decay_t<T1>;
798 using D2 = std::decay_t<T2>;
803 auto doReport = [&](
bool result,
const D1 &lhs_,
const D2 &rhs_) {
804 return reportResult(result, std::addressof(lhs_), std::addressof(rhs_),
805 genericToString<D1>, genericToString<D2>,
806 lhsExpr, rhsExpr, op, file, line);
810 bool result = Comparator::compare(
std::forward<T1>(lhs),
std::forward<T2>(rhs));
811 return doReport(result,
std::forward<T1>(lhs),
std::forward<T2>(rhs));
814#if defined(__cpp_lib_three_way_comparison)
822#if defined(__cpp_concepts)
824 "The three-way comparison operator (<=>) is not implemented");
827 "Please provide, as the order parameter, a value "
828 "of one of the Qt::{partial,weak,strong}_ordering or "
829 "std::{partial,weak,strong}_ordering types.");
834 "The expected and actual ordering types should be the same "
835 "strength for proper comparison.");
843 "The result of operator<=>() is not what was expected",
854 template <
typename OrderingType,
typename LHS,
typename RHS = LHS>
856 const char *lhsExpression,
857 const char *rhsExpression,
858 const char *resultExpression,
859 const char *file,
int line) =
delete;
864#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)