summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp242
1 files changed, 2 insertions, 240 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index fbb6a30917..caceda86be 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -30,6 +30,7 @@
#include <QtCore>
#include <QtTest/QtTest>
+#include "tst_qmetatype.h"
#include "tst_qvariant_common.h"
#ifdef Q_OS_LINUX
@@ -464,18 +465,6 @@ void tst_QMetaType::type_fromSubString()
QCOMPARE(QMetaType::type(ba), expectedType);
}
-#define FOR_EACH_PRIMITIVE_METATYPE(F) \
- QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \
- QT_FOR_EACH_STATIC_CORE_POINTER(F) \
-
-#define FOR_EACH_COMPLEX_CORE_METATYPE(F) \
- QT_FOR_EACH_STATIC_CORE_CLASS(F) \
- QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)
-
-#define FOR_EACH_CORE_METATYPE(F) \
- FOR_EACH_PRIMITIVE_METATYPE(F) \
- FOR_EACH_COMPLEX_CORE_METATYPE(F) \
-
namespace {
template <typename T>
struct static_assert_trigger {
@@ -495,234 +484,6 @@ Q_STATIC_ASSERT((!QMetaTypeId2<QList<int> >::IsBuiltIn));
Q_STATIC_ASSERT((!QMetaTypeId2<QMap<int,int> >::IsBuiltIn));
Q_STATIC_ASSERT((!QMetaTypeId2<QMetaType::Type>::IsBuiltIn));
-template <int ID>
-struct MetaEnumToType {};
-
-#define DEFINE_META_ENUM_TO_TYPE(MetaTypeName, MetaTypeId, RealType) \
-template<> \
-struct MetaEnumToType<QMetaType::MetaTypeName> { \
- typedef RealType Type; \
-};
-FOR_EACH_CORE_METATYPE(DEFINE_META_ENUM_TO_TYPE)
-#undef DEFINE_META_ENUM_TO_TYPE
-
-template <int ID>
-struct DefaultValueFactory
-{
- typedef typename MetaEnumToType<ID>::Type Type;
- static Type *create() { return new Type; }
-};
-
-template <>
-struct DefaultValueFactory<QMetaType::Void>
-{
- typedef MetaEnumToType<QMetaType::Void>::Type Type;
- static Type *create() { return 0; }
-};
-
-template <int ID>
-struct DefaultValueTraits
-{
- // By default we assume that a default-constructed value (new T) is
- // initialized; e.g. QCOMPARE(*(new T), *(new T)) should succeed
- enum { IsInitialized = true };
-};
-
-#define DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS(MetaTypeName, MetaTypeId, RealType) \
-template<> struct DefaultValueTraits<QMetaType::MetaTypeName> { \
- enum { IsInitialized = false }; \
-};
-// Primitive types (int et al) aren't initialized
-FOR_EACH_PRIMITIVE_METATYPE(DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS)
-#undef DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS
-
-template <int ID>
-struct TestValueFactory {};
-
-template<> struct TestValueFactory<QMetaType::Void> {
- static void *create() { return 0; }
-};
-
-template<> struct TestValueFactory<QMetaType::QString> {
- static QString *create() { return new QString(QString::fromLatin1("QString")); }
-};
-template<> struct TestValueFactory<QMetaType::Int> {
- static int *create() { return new int(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::UInt> {
- static uint *create() { return new uint(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::Bool> {
- static bool *create() { return new bool(true); }
-};
-template<> struct TestValueFactory<QMetaType::Double> {
- static double *create() { return new double(3.14); }
-};
-template<> struct TestValueFactory<QMetaType::QByteArray> {
- static QByteArray *create() { return new QByteArray(QByteArray("QByteArray")); }
-};
-template<> struct TestValueFactory<QMetaType::QByteArrayList> {
- static QByteArrayList *create() { return new QByteArrayList(QByteArrayList() << "Q" << "Byte" << "Array" << "List"); }
-};
-template<> struct TestValueFactory<QMetaType::QVariantMap> {
- static QVariantMap *create() { return new QVariantMap(); }
-};
-template<> struct TestValueFactory<QMetaType::QVariantHash> {
- static QVariantHash *create() { return new QVariantHash(); }
-};
-template<> struct TestValueFactory<QMetaType::QVariantList> {
- static QVariantList *create() { return new QVariantList(QVariantList() << 123 << "Q" << "Variant" << "List"); }
-};
-template<> struct TestValueFactory<QMetaType::QChar> {
- static QChar *create() { return new QChar(QChar('q')); }
-};
-template<> struct TestValueFactory<QMetaType::Long> {
- static long *create() { return new long(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::Short> {
- static short *create() { return new short(0x1234); }
-};
-template<> struct TestValueFactory<QMetaType::Char> {
- static char *create() { return new char('c'); }
-};
-template<> struct TestValueFactory<QMetaType::ULong> {
- static ulong *create() { return new ulong(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::UShort> {
- static ushort *create() { return new ushort(0x1234); }
-};
-template<> struct TestValueFactory<QMetaType::SChar> {
- static signed char *create() { return new signed char(-12); }
-};
-template<> struct TestValueFactory<QMetaType::UChar> {
- static uchar *create() { return new uchar('u'); }
-};
-template<> struct TestValueFactory<QMetaType::Float> {
- static float *create() { return new float(3.14f); }
-};
-template<> struct TestValueFactory<QMetaType::QObjectStar> {
- static QObject * *create() { return new QObject *(0); }
-};
-template<> struct TestValueFactory<QMetaType::VoidStar> {
- static void * *create() { return new void *(0); }
-};
-template<> struct TestValueFactory<QMetaType::LongLong> {
- static qlonglong *create() { return new qlonglong(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::ULongLong> {
- static qulonglong *create() { return new qulonglong(0x12345678); }
-};
-template<> struct TestValueFactory<QMetaType::QStringList> {
- static QStringList *create() { return new QStringList(QStringList() << "Q" << "t"); }
-};
-template<> struct TestValueFactory<QMetaType::QBitArray> {
- static QBitArray *create() { return new QBitArray(QBitArray(256, true)); }
-};
-template<> struct TestValueFactory<QMetaType::QDate> {
- static QDate *create() { return new QDate(QDate::currentDate()); }
-};
-template<> struct TestValueFactory<QMetaType::QTime> {
- static QTime *create() { return new QTime(QTime::currentTime()); }
-};
-template<> struct TestValueFactory<QMetaType::QDateTime> {
- static QDateTime *create() { return new QDateTime(QDateTime::currentDateTime()); }
-};
-template<> struct TestValueFactory<QMetaType::QUrl> {
- static QUrl *create() { return new QUrl("http://www.example.org"); }
-};
-template<> struct TestValueFactory<QMetaType::QLocale> {
- static QLocale *create() { return new QLocale(QLocale::c()); }
-};
-template<> struct TestValueFactory<QMetaType::QRect> {
- static QRect *create() { return new QRect(10, 20, 30, 40); }
-};
-template<> struct TestValueFactory<QMetaType::QRectF> {
- static QRectF *create() { return new QRectF(10, 20, 30, 40); }
-};
-template<> struct TestValueFactory<QMetaType::QSize> {
- static QSize *create() { return new QSize(10, 20); }
-};
-template<> struct TestValueFactory<QMetaType::QSizeF> {
- static QSizeF *create() { return new QSizeF(10, 20); }
-};
-template<> struct TestValueFactory<QMetaType::QLine> {
- static QLine *create() { return new QLine(10, 20, 30, 40); }
-};
-template<> struct TestValueFactory<QMetaType::QLineF> {
- static QLineF *create() { return new QLineF(10, 20, 30, 40); }
-};
-template<> struct TestValueFactory<QMetaType::QPoint> {
- static QPoint *create() { return new QPoint(10, 20); }
-};
-template<> struct TestValueFactory<QMetaType::QPointF> {
- static QPointF *create() { return new QPointF(10, 20); }
-};
-template<> struct TestValueFactory<QMetaType::QEasingCurve> {
- static QEasingCurve *create() { return new QEasingCurve(QEasingCurve::InOutElastic); }
-};
-template<> struct TestValueFactory<QMetaType::QUuid> {
- static QUuid *create() { return new QUuid(); }
-};
-template<> struct TestValueFactory<QMetaType::QModelIndex> {
- static QModelIndex *create() { return new QModelIndex(); }
-};
-template<> struct TestValueFactory<QMetaType::QPersistentModelIndex> {
- static QPersistentModelIndex *create() { return new QPersistentModelIndex(); }
-};
-template<> struct TestValueFactory<QMetaType::QRegExp> {
- static QRegExp *create()
- {
-#ifndef QT_NO_REGEXP
- return new QRegExp("A*");
-#else
- return 0;
-#endif
- }
-};
-template<> struct TestValueFactory<QMetaType::QRegularExpression> {
- static QRegularExpression *create()
- {
-#ifndef QT_NO_REGEXP
- return new QRegularExpression("abc.*def");
-#else
- return 0;
-#endif
- }
-};
-template<> struct TestValueFactory<QMetaType::QJsonValue> {
- static QJsonValue *create() { return new QJsonValue(123.); }
-};
-template<> struct TestValueFactory<QMetaType::QJsonObject> {
- static QJsonObject *create() {
- QJsonObject *o = new QJsonObject();
- o->insert("a", 123.);
- o->insert("b", true);
- o->insert("c", QJsonValue::Null);
- o->insert("d", QLatin1String("ciao"));
- return o;
- }
-};
-template<> struct TestValueFactory<QMetaType::QJsonArray> {
- static QJsonArray *create() {
- QJsonArray *a = new QJsonArray();
- a->append(123.);
- a->append(true);
- a->append(QJsonValue::Null);
- a->append(QLatin1String("ciao"));
- return a;
- }
-};
-template<> struct TestValueFactory<QMetaType::QJsonDocument> {
- static QJsonDocument *create() {
- return new QJsonDocument(
- QJsonDocument::fromJson("{ 'foo': 123, 'bar': [true, null, 'ciao'] }")
- );
- }
-};
-template<> struct TestValueFactory<QMetaType::QVariant> {
- static QVariant *create() { return new QVariant(QStringList(QStringList() << "Q" << "t")); }
-};
-
void tst_QMetaType::create_data()
{
QTest::addColumn<int>("type");
@@ -1798,6 +1559,7 @@ DECLARE_NONSTREAMABLE(QJsonArray)
DECLARE_NONSTREAMABLE(QJsonDocument)
DECLARE_NONSTREAMABLE(QObject*)
DECLARE_NONSTREAMABLE(QWidget*)
+DECLARE_NONSTREAMABLE(std::nullptr_t)
#define DECLARE_GUI_CLASS_NONSTREAMABLE(MetaTypeName, MetaTypeId, RealType) \
DECLARE_NONSTREAMABLE(RealType)