1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTESTDATA_H
5#define QTESTDATA_H
6
7#include <QtTest/qttestglobal.h>
8
9#include <QtCore/qmetatype.h>
10#include <QtCore/qstring.h>
11
12QT_BEGIN_NAMESPACE
13
14
15class QTestTable;
16class QTestDataPrivate;
17
18class Q_TESTLIB_EXPORT QTestData
19{
20public:
21 ~QTestData();
22
23 void append(int type, const void *data);
24 void *data(int index) const;
25 const char *dataTag() const;
26 QTestTable *parent() const;
27 int dataCount() const;
28
29private:
30 friend class QTestTable;
31 QTestData(const char *tag, QTestTable *parent);
32
33 Q_DISABLE_COPY(QTestData)
34
35 QTestDataPrivate *d;
36};
37
38template<typename T>
39QTestData &operator<<(QTestData &data, const T &value)
40{
41 data.append(type: qMetaTypeId<T>(), data: &value);
42 return data;
43}
44
45inline QTestData &operator<<(QTestData &data, const char * value)
46{
47 QString str = QString::fromUtf8(utf8: value);
48 data.append(type: QMetaType::QString, data: &str);
49 return data;
50}
51
52#ifdef __cpp_char8_t
53Q_WEAK_OVERLOAD
54inline QTestData &operator<<(QTestData &data, const char8_t *value)
55{
56 return data << reinterpret_cast<const char *>(value);
57}
58#endif
59
60#ifdef QT_USE_QSTRINGBUILDER
61template<typename A, typename B>
62inline QTestData &operator<<(QTestData &data, const QStringBuilder<A, B> &value)
63{
64 return data << typename QConcatenable<QStringBuilder<A, B> >::ConvertTo(value);
65}
66#endif
67
68QT_END_NAMESPACE
69
70#endif
71

source code of qtbase/src/testlib/qtestdata.h