Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtestcase.cpp File Reference

(bca424b792fa38de6e5b38e4a9b17269ec2867ec)

#include <QtTest/qtestcase.h>
#include <QtTest/private/qtestcase_p.h>
#include <QtTest/qtestassert.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qdirlisting.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qfloat16.h>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/qlist.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qobject.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qtemporarydir.h>
#include <QtCore/qthread.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/private/qlocking_p.h>
#include <QtCore/private/qtools_p.h>
#include <QtCore/private/qwaitcondition_p.h>
#include <QtCore/qtestsupport_core.h>
#include <QtTest/private/qtestlog_p.h>
#include <QtTest/private/qtesttable_p.h>
#include <QtTest/qtestdata.h>
#include <QtTest/private/qtestresult_p.h>
#include <QtTest/private/qsignaldumper_p.h>
#include <QtTest/private/qbenchmark_p.h>
#include <QtTest/private/cycle_include_p.h>
#include <QtTest/private/qtestblacklist_p.h>
#include <QtTest/private/qtestcrashhandler_p.h>
#include <algorithm>
#include <array>
#include <charconv>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <limits>
#include <memory>
#include <mutex>
#include <numeric>
#include <optional>
#include <stdarg.h>
#include <stdlib.h>
#include <vector>
Include dependency graph for qtestcase.cpp:

Go to the source code of this file.

Classes

class  QTest::TestMethods
struct  QTest::QTestDataSetter
class  QTest::WatchDog

Namespaces

namespace  QTestPrivate
namespace  QTest
 [15]
namespace  QTest::Internal

Macros

#define TO_STRING_IMPL(TYPE, FORMAT)
#define TO_STRING_FLOAT(TYPE)

Functions

static bool installCoverageTool (const char *appname, const char *testname)
static bool isValidSlot (const QMetaMethod &sl)
void QTest::setThrowOnFail (bool enable) noexcept
void QTest::setThrowOnSkip (bool enable) noexcept
static bool QTest::invokeTestMethodIfValid (QMetaMethod m, QObject *obj=QTest::currentTestObject)
static void QTest::invokeTestMethodIfExists (const char *methodName, QObject *obj=QTest::currentTestObject)
int QTest::defaultEventDelay ()
int Q_TESTLIB_EXPORT QTest::defaultMouseDelay ()
int Q_TESTLIB_EXPORT QTest::defaultKeyDelay ()
static bool QTest::qPrintTestSlots (FILE *stream, const char *filter=nullptr, const char *preamble="")
static void QTest::qPrintDataTags (FILE *stream)
static int QTest::qToInt (const char *str)
Q_TESTLIB_EXPORT void QTest::qtest_qParseArgs (int argc, const char *const argv[], bool qml)
Q_TESTLIB_EXPORT void QTest::qtest_qParseArgs (int argc, char *argv[], bool qml)
static QList< QBenchmarkResultQTest::qMedian (const QList< QList< QBenchmarkResult > > &container)
template<typename Functor>
void QTest::runWithWatchdog (std::optional< WatchDog > &watchDog, Functor &&f)
static void QTest::printUnknownDataTagError (QLatin1StringView name, QLatin1StringView tag, const QTestTable &lTable, const QTestTable &gTable)
voidQTest::fetchData (QTestData *data, const char *tagName, int typeId)
char * QTest::formatString (const char *prefix, const char *suffix, size_t numArguments,...)
char * QTest::toHexRepresentation (const char *ba, qsizetype length)
 Returns a pointer to a string that is the string ba represented as a space-separated sequence of hex characters.
char * QTest::toPrettyCString (const char *p, qsizetype length)
static char * QTest::writePrettyUnicodeChar (char16_t ch, char *const buffer)
char * QTest::toPrettyUnicode (QStringView string)
bool QTest::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)
static void initEnvironment ()
template<typename T>
static bool floatingCompare (const T &actual, const T &expected)
template<typename T>
static auto decodeNanPayload (T t)
static bool signbit (qfloat16 f)
template<typename T>
static char * toStringFp (T t)
constexpr char toHexUpper (char32_t value) noexcept
constexpr int fromHex (char32_t c) noexcept
constexpr char toHexUpper (char32_t value) noexcept
constexpr int fromHex (char32_t c) noexcept

Variables

Q_TESTLIB_EXPORT Qt::MouseButtons QTestPrivate::qtestMouseButtons = Qt::NoButton
static Q_CONSTINIT QBasicAtomicInt QTest::g_throwOnFail = Q_BASIC_ATOMIC_INITIALIZER(0)
static Q_CONSTINIT QBasicAtomicInt QTest::g_throwOnSkip = Q_BASIC_ATOMIC_INITIALIZER(0)
Q_TESTLIB_EXPORT int QTest::lastMouseTimestamp = 0
static QObjectQTest::currentTestObject = nullptr
static QString QTest::mainSourcePath
static bool QTest::inTestFunction = false
static int QTest::keyDelay = -1
static int QTest::mouseDelay = -1
static int QTest::eventDelay = -1
static int QTest::repetitions = 1
static bool QTest::skipBlacklisted = false
bool QTest::Internal::noCrashHandler = false
Q_TESTLIB_EXPORT bool QTest::printAvailableFunctions = false
Q_TESTLIB_EXPORT QStringList QTest::testFunctions
Q_TESTLIB_EXPORT QStringList QTest::testTags
constexpr qsizetype QTest::PrettyUnicodeMaxOutputSize = 256
constexpr qsizetype QTest::PrettyUnicodeMaxIncrement = sizeof(R"(\uXXXX"...)")

Macro Definition Documentation

◆ TO_STRING_FLOAT

#define TO_STRING_FLOAT ( TYPE)
Value:
template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE>(const TYPE &t) \
{ \
return toStringFp(t); \
}
char * toString(const MyPoint &point)
GLdouble GLdouble t
Definition qopenglext.h:243
static char * toStringFp(T t)
const char * TYPE

Definition at line 3177 of file qtestcase.cpp.

◆ TO_STRING_IMPL

#define TO_STRING_IMPL ( TYPE,
FORMAT )
Value:
template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE>(const TYPE &t) \
{ \
char *msg = new char[128]; \
std::snprintf(msg, 128, #FORMAT, t); \
return msg; \
}
static constexpr QSSGRenderTextureFormat FORMAT(QSSGRenderTextureFormat::RGBA16F)

Definition at line 3103 of file qtestcase.cpp.

Function Documentation

◆ decodeNanPayload()

template<typename T>
auto decodeNanPayload ( T t)
static

Definition at line 3124 of file qtestcase.cpp.

◆ floatingCompare()

template<typename T>
bool floatingCompare ( const T & actual,
const T & expected )
static

Definition at line 2952 of file qtestcase.cpp.

◆ fromHex() [1/2]

int QtMiscUtils::fromHex ( char32_t c)
inlinenodiscardconstexprnoexcept

Definition at line 44 of file qtools_p.h.

◆ fromHex() [2/2]

int QtMiscUtils::fromHex ( char32_t c)
inlinenodiscardconstexprnoexcept

Definition at line 44 of file qtools_p.h.

◆ initEnvironment()

void initEnvironment ( )
static

Definition at line 1800 of file qtestcase.cpp.

Referenced by QTest::qInit().

Here is the caller graph for this function:

◆ installCoverageTool()

bool installCoverageTool ( const char * appname,
const char * testname )
static

Definition at line 130 of file qtestcase.cpp.

◆ isValidSlot()

bool isValidSlot ( const QMetaMethod & sl)
static

Definition at line 151 of file qtestcase.cpp.

◆ signbit()

bool signbit ( qfloat16 f)
static

Definition at line 3142 of file qtestcase.cpp.

◆ toHexUpper() [1/2]

char QtMiscUtils::toHexUpper ( char32_t value)
inlinenodiscardconstexprnoexcept

Definition at line 27 of file qtools_p.h.

◆ toHexUpper() [2/2]

char QtMiscUtils::toHexUpper ( char32_t value)
inlinenodiscardconstexprnoexcept

Definition at line 27 of file qtools_p.h.

◆ toStringFp()

template<typename T>
char * toStringFp ( T t)
static

Definition at line 3147 of file qtestcase.cpp.