44 #include <QtTest/qttestglobal.h>
45 #include <QtTest/qtestcase.h>
46 #include <QtTest/qtestdata.h>
47 #include <QtTest/qbenchmark.h>
49 #include <QtCore/qbitarray.h>
50 #include <QtCore/qbytearray.h>
51 #include <QtCore/qcborarray.h>
52 #include <QtCore/qcborcommon.h>
53 #include <QtCore/qcbormap.h>
54 #include <QtCore/qcborvalue.h>
55 #include <QtCore/qstring.h>
56 #include <QtCore/qstringlist.h>
57 #include <QtCore/qcborcommon.h>
58 #include <QtCore/qdatetime.h>
59 #if QT_CONFIG(itemmodel)
60 #include <QtCore/qabstractitemmodel.h>
62 #include <QtCore/qobject.h>
63 #include <QtCore/qvariant.h>
64 #include <QtCore/qurl.h>
65 #include <QtCore/quuid.h>
67 #if defined(TESTCASE_LOWDPI)
68 #include <QtCore/qcoreapplication.h>
71 #include <QtCore/qpoint.h>
72 #include <QtCore/qsize.h>
73 #include <QtCore/qrect.h>
75 #include <initializer_list>
106 char *
str =
new char[
size + 1];
113 #if QT_CONFIG(datestring)
132 :
qstrdup(
"Invalid QDateTime");
146 char msg[32] = {
'\0'};
147 qsnprintf(
msg,
sizeof(
msg),
"QChar: '%c' (0x%x)",
char(uc),
unsigned(uc));
153 #if QT_CONFIG(itemmodel)
164 char msg[128] = {
'\0'};
171 char msg[128] = {
'\0'};
178 char msg[256] = {
'\0'};
180 s.left(),
s.top(),
s.width(),
s.height(),
s.right(),
s.bottom());
186 char msg[64] = {
'\0'};
193 char msg[64] = {
'\0'};
200 char msg[256] = {
'\0'};
202 s.left(),
s.top(),
s.width(),
s.height(),
s.right(),
s.bottom());
223 if (
type.isEmpty()) {
230 vstring.
append(
v.toString().toLocal8Bit());
233 vstring.
append(
"<value not representable as string>");
264 int idx = QCborValue::staticMetaObject.indexOfEnumerator(
"Type");
265 return QCborValue::staticMetaObject.enumerator(
idx);
287 return format(
v.type(),
v.toInteger());
289 return format(
v.type(),
v.toByteArray());
291 return format(
v.type(),
v.toString());
301 return qstrdup(
"QCborValue(true)");
303 return qstrdup(
"QCborValue(false)");
305 return qstrdup(
"QCborValue(nullptr)");
307 return qstrdup(
"QCborValue()");
309 return format(
v.type(),
v.toDouble());
313 return format(
v.type(),
v.taggedValue().toString());
315 return format(
v.type(),
v.toUuid());
317 return qstrdup(
"QCborValue(<invalid>)");
320 if (
v.isSimpleType())
328 const char *
comma =
"";
342 const char *
comma =
"";
343 for (
auto pair :
m) {
378 template <
typename T1,
typename T2>
379 inline char *
toString(
const std::pair<T1, T2> &pair)
386 template <
typename Tuple,
int...
I>
388 using UP = std::unique_ptr<char[]>;
393 UP(
toString(std::get<I>(tuple)))..., UP{}
398 template <
class... Types>
399 inline char *
toString(
const std::tuple<Types...> &tuple)
401 static const std::size_t params_count =
sizeof...(Types);
412 const char *expected,
const char *
file,
int line)
418 const char *expected,
const char *
file,
int line)
424 template <
typename ActualIterator,
typename ExpectedIterator>
426 ExpectedIterator expectedBegin, ExpectedIterator expectedEnd,
427 const char *actual,
const char *expected,
433 const qsizetype actualSize = actualEnd - actualIt;
434 const qsizetype expectedSize = expectedEnd - expectedBegin;
435 bool isOk = actualSize == expectedSize;
439 " Actual (%s) size: %zd\n"
440 " Expected (%s) size: %zd", actual, actualSize,
441 expected, expectedSize);
444 for (
auto expectedIt = expectedBegin;
isOk && expectedIt < expectedEnd; ++actualIt, ++expectedIt) {
445 if (!(*actualIt == *expectedIt)) {
452 " Expected (%s): %s",
i, actual, val1 ? val1 :
"<null>",
453 expected, val2 ? val2 :
"<null>");
465 #if defined(TESTCASE_LOWDPI)
466 void disableHighDpi()
468 qputenv(
"QT_ENABLE_HIGHDPI_SCALING",
"0");
475 template <
typename T>
483 template <
typename T,
int N>
485 const char *actual,
const char *expected,
493 template <
typename T,
int N>
495 const char *actual,
const char *expected,
502 template <
typename T>
510 template <
typename T>
520 const char *expected,
const char *
file,
int line)
527 const char *expected,
const char *
file,
int line)
534 const char *expected,
const char *
file,
int line)
541 const char *expected,
const char *
file,
int line)
548 const char *expected,
const char *
file,
int line)
555 const char *expected,
const char *
file,
int line)
561 template <
typename T>
565 using YesType =
char[1];
566 using NoType =
char[2];
568 template <
typename C>
static YesType& test( decltype(&C::initMain) ) ;
569 template <
typename C>
static NoType& test(...);
572 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(YesType) };
591 #ifdef QT_TESTCASE_BUILDDIR
592 # define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__, QT_TESTCASE_BUILDDIR);
594 # define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__);
598 #if QT_CONFIG(testlib_selfcover) && defined(__COVERAGESCANNER__)
599 struct QtCoverageScanner
601 QtCoverageScanner(
const char *
name)
603 __coveragescanner_clear();
604 __coveragescanner_testname(
name);
608 __coveragescanner_save();
609 __coveragescanner_testname(
"");
612 #define TESTLIB_SELFCOVERAGE_START(name) QtCoverageScanner _qtCoverageScanner(name);
614 #define TESTLIB_SELFCOVERAGE_START(name)
620 #define QTEST_MAIN_WRAPPER(TestObject, ...) \
621 int main(int argc, char *argv[]) \
623 TESTLIB_SELFCOVERAGE_START(#TestObject) \
624 QT_PREPEND_NAMESPACE(QTest::Internal::callInitMain)<TestObject>(); \
627 QTEST_SET_MAIN_SOURCE_PATH \
628 return QTest::qExec(&tc, argc, argv); \
632 #define QTEST_APPLESS_MAIN(TestObject) QTEST_MAIN_WRAPPER(TestObject)
634 #include <QtTest/qtestsystem.h>
636 #if defined(QT_NETWORK_LIB)
637 # include <QtTest/qtest_network.h>
641 #define QTEST_QAPP_SETUP(klaz) \
642 klaz app(argc, argv); \
643 app.setAttribute(Qt::AA_Use96Dpi, true);
645 #if defined(QT_WIDGETS_LIB)
646 # include <QtTest/qtest_widgets.h>
647 # ifdef QT_KEYPAD_NAVIGATION
648 # define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setNavigationMode(Qt::NavigationModeNone);
650 # define QTEST_DISABLE_KEYPAD_NAVIGATION
653 # define QTEST_MAIN_SETUP() QTEST_QAPP_SETUP(QApplication) QTEST_DISABLE_KEYPAD_NAVIGATION
654 #elif defined(QT_GUI_LIB)
655 # include <QtTest/qtest_gui.h>
657 # define QTEST_MAIN_SETUP() QTEST_QAPP_SETUP(QGuiApplication)
660 # define QTEST_MAIN_SETUP() QTEST_QAPP_SETUP(QCoreApplication)
664 #define QTEST_MAIN(TestObject) QTEST_MAIN_WRAPPER(TestObject, QTEST_MAIN_SETUP())
667 #define QTEST_GUILESS_MAIN(TestObject) \
668 QTEST_MAIN_WRAPPER(TestObject, QTEST_QAPP_SETUP(QCoreApplication))
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
The QBitArray class provides an array of bits.
The QByteArray class provides an array of bytes.
qsizetype size() const noexcept
const char * constData() const noexcept
qsizetype length() const noexcept
static QByteArray number(int, int base=10)
QByteArray & append(char c)
The QCborArray class is used to hold an array of CBOR elements.
The QCborMap class is used to hold an associative container representable in CBOR.
The QCborValue class encapsulates a value in CBOR.
The QChar class provides a 16-bit Unicode character.
The QDate class provides date functions.
constexpr bool isValid() const
The QDateTime class provides date and time functions.
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
std::conditional< std::is_unsigned< typename std::underlying_type< Enum >::type >::value, unsigned int, signed int >::type Int
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QModelIndex class is used to locate data in a data model.
The QPointF class defines a point in the plane using floating point precision.
The QPoint class defines a point in the plane using integer precision.
The QRectF class defines a finite rectangle in the plane using floating point precision.
The QRect class defines a rectangle in the plane using integer precision.
The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects,...
T * data() const noexcept
The QSizeF class defines the size of a two-dimensional object using floating point precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
static QString number(int, int base=10)
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
The QTime class provides clock time functions.
The QUrl class provides a convenient interface for working with URLs.
QByteArray toEncoded(FormattingOptions options=FullyEncoded) const
QString errorString() const
The QUuid class stores a Universally Unique Identifier (UUID).
QByteArray toByteArray(StringFormat mode=WithBraces) const
The QVariant class acts like a union for the most common Qt data types.
bool isOk(ResultWas::OfType resultType)
std::enable_if< HasInitMain< T >::value, void >::type callInitMain()
bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line)
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *failureMsg, char *val1, char *val2, const char *actual, const char *expected, const char *file, int line)
bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd, ExpectedIterator expectedBegin, ExpectedIterator expectedEnd, const char *actual, const char *expected, const char *file, int line)
char * formatString(const char *prefix, const char *suffix, size_t numArguments,...)
char * toPrettyCString(const char *p, int length)
char * toPrettyUnicode(QStringView string)
char * toString(const MyPoint &point)
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt,...)
Q_CORE_EXPORT char * qstrdup(const char *)
Q_CONSTRUCTOR_FUNCTION(initializeStandardUserDefaults)
EGLOutputLayerEXT EGLint EGLAttrib value
unsigned long long quint64
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
QTextStream out(stdout)
[7]
QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9))
[0]
http get(QUrl::toPercentEncoding("/index.html"))
The QCborError class holds the error condition found while parsing or validating a CBOR stream.
makeIndexSequence< N > Value
XmlOutput::xml_output tag(const QString &name)