diff options
Diffstat (limited to 'tests/auto/corelib/kernel')
5 files changed, 30 insertions, 542 deletions
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 60000316cc..c83e7af503 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -1320,13 +1320,13 @@ void tst_QMetaObject::normalizedSignature_data() QTest::newRow("function ptr spaces") << "void foo( void ( * ) ( void ))" << "void foo(void(*)())"; QTest::newRow("function ptr void*") << "void foo(void(*)(void*))" << "void foo(void(*)(void*))"; QTest::newRow("function ptr void* spaces") << "void foo( void ( * ) ( void * ))" << "void foo(void(*)(void*))"; - QTest::newRow("template args") << " void foo( QMap<a, a>, QList<b>) " - << "void foo(QMap<a,a>,QList<b>)"; + QTest::newRow("template args") << " void foo( QMap<a, a>, QVector<b>) " + << "void foo(QMap<a,a>,QVector<b>)"; QTest::newRow("void template args") << " void foo( Foo<void>, Bar<void> ) " << "void foo(Foo<void>,Bar<void>)"; QTest::newRow("void* template args") << " void foo( Foo<void*>, Bar<void *> ) " << "void foo(Foo<void*>,Bar<void*>)"; - QTest::newRow("rettype") << "QList<int, int> foo()" << "QList<int,int>foo()"; + QTest::newRow("rettype") << "QVector<int, int> foo()" << "QVector<int,int>foo()"; QTest::newRow("rettype void template") << "Foo<void> foo()" << "Foo<void>foo()"; QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()"; QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()"; @@ -1337,15 +1337,16 @@ void tst_QMetaObject::normalizedSignature_data() QTest::newRow("const4") << "void foo(const int)" << "void foo(int)"; QTest::newRow("const5") << "void foo(const int, int const, const int &, int const &)" << "void foo(int,int,int,int)"; - QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)"; - QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)"; - QTest::newRow("const8") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)"; + QTest::newRow("const6") << "void foo(QVector<const int>)" << "void foo(QVector<const int>)"; + QTest::newRow("const7") << "void foo(QVector<const int*>)" << "void foo(QVector<const int*>)"; + QTest::newRow("const8") << "void foo(QVector<int const*>)" << "void foo(QVector<const int*>)"; QTest::newRow("const9") << "void foo(const Foo<Bar>)" << "void foo(Foo<Bar>)"; QTest::newRow("const10") << "void foo(Foo<Bar>const)" << "void foo(Foo<Bar>)"; QTest::newRow("const11") << "void foo(Foo<Bar> *const)" << "void foo(Foo<Bar>*const)"; QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(Foo<Bar>*const*const)"; QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)"; QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)"; + QTest::newRow("QList") << "void foo(QList<int>)" << "void foo(QVector<int>)"; QTest::newRow("invalid1") << "a( b" << "a(b"; } @@ -1367,13 +1368,13 @@ void tst_QMetaObject::normalizedType_data() QTest::newRow("white") << " int " << "int"; QTest::newRow("const1") << "int const *" << "const int*"; QTest::newRow("const2") << "const int *" << "const int*"; - QTest::newRow("template1") << "QList<int const *>" << "QList<const int*>"; - QTest::newRow("template2") << "QList<const int *>" << "QList<const int*>"; + QTest::newRow("template1") << "QVector<int const *>" << "QVector<const int*>"; + QTest::newRow("template2") << "QVector<const int *>" << "QVector<const int*>"; QTest::newRow("template3") << "QMap<QString, int>" << "QMap<QString,int>"; QTest::newRow("template4") << "const QMap<QString, int> &" << "QMap<QString,int>"; - QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList< ::Foo::Bar>"; - QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>"; - QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int> >"; + QTest::newRow("template5") << "QVector< ::Foo::Bar>" << "QVector< ::Foo::Bar>"; + QTest::newRow("template6") << "QVector<::Foo::Bar>" << "QVector<::Foo::Bar>"; + QTest::newRow("template7") << "QVector<QVector<int> >" << "QVector<QVector<int> >"; QTest::newRow("template8") << "QMap<const int, const short*>" << "QMap<const int,const short*>"; QTest::newRow("template9") << "QPair<const QPair<int, int const *> , QPair<QHash<int, const char*> > >" << "QPair<const QPair<int,const int*>,QPair<QHash<int,const char*> > >"; QTest::newRow("value1") << "const QString &" << "QString"; @@ -1387,6 +1388,7 @@ void tst_QMetaObject::normalizedType_data() QTest::newRow("struct2") << "struct foo const*" << "const foo*"; QTest::newRow("enum") << "enum foo" << "foo"; QTest::newRow("void") << "void" << "void"; + QTest::newRow("QList") << "QList<int>" << "QVector<int>"; } void tst_QMetaObject::normalizedType() diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 9fe7d63727..14719f36f8 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1702,9 +1702,10 @@ void tst_QMetaObjectBuilder::classNameFirstInStringData() builder.setClassName(QByteArrayLiteral("TestClass")); QMetaObject *mo = builder.toMetaObject(); - QByteArrayDataPtr header; - header.ptr = const_cast<QByteArrayData*>(mo->d.stringdata); - QCOMPARE(QByteArray(header), QByteArrayLiteral("TestClass")); + uint offset = mo->d.stringdata[0]; + uint len = mo->d.stringdata[1]; + QByteArray className(reinterpret_cast<const char *>(mo->d.stringdata) + offset, len); + QCOMPARE(className, QByteArrayLiteral("TestClass")); free(mo); } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 19b3289390..4e30f210b1 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -120,8 +120,6 @@ private slots: void constRefs(); void convertCustomType_data(); void convertCustomType(); - void compareCustomType_data(); - void compareCustomType(); void compareCustomEqualOnlyType(); void customDebugStream(); void unknownType(); @@ -574,12 +572,14 @@ void tst_QMetaType::typeName_data() QTest::newRow("124125534") << 124125534 << QString(); // automatic registration - QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QList<int>"); QTest::newRow("QHash<int,int>") << ::qMetaTypeId<QHash<int, int> >() << QString::fromLatin1("QHash<int,int>"); QTest::newRow("QMap<int,int>") << ::qMetaTypeId<QMap<int, int> >() << QString::fromLatin1("QMap<int,int>"); - QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QVector<QList<int> >"); QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QVector<QMap<int,int> >"); + // automatic registration with automatic QList to QVector aliasing + QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QVector<int>"); + QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QVector<QVector<int> >"); + QTest::newRow("CustomQObject*") << ::qMetaTypeId<CustomQObject*>() << QString::fromLatin1("CustomQObject*"); QTest::newRow("CustomGadget") << ::qMetaTypeId<CustomGadget>() << QString::fromLatin1("CustomGadget"); QTest::newRow("CustomGadget*") << ::qMetaTypeId<CustomGadget*>() << QString::fromLatin1("CustomGadget*"); @@ -1032,9 +1032,9 @@ static void testConstructHelper() typedef typename MetaEnumToType<ID>::Type Type; QMetaType info(ID); int size = info.sizeOf(); - void *storage1 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage1 = qMallocAligned(size, alignof(Type)); void *actual1 = QMetaType::construct(ID, storage1, /*copy=*/0); - void *storage2 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage2 = qMallocAligned(size, alignof(Type)); void *actual2 = info.construct(storage2, /*copy=*/0); QCOMPARE(actual1, storage1); QCOMPARE(actual2, storage2); @@ -1186,9 +1186,9 @@ static void testConstructCopyHelper() QMetaType info(ID); int size = QMetaType::sizeOf(ID); QCOMPARE(info.sizeOf(), size); - void *storage1 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage1 = qMallocAligned(size, alignof(Type)); void *actual1 = QMetaType::construct(ID, storage1, expected); - void *storage2 = qMallocAligned(size, Q_ALIGNOF(Type)); + void *storage2 = qMallocAligned(size, alignof(Type)); void *actual2 = info.construct(storage2, expected); QCOMPARE(actual1, storage1); QCOMPARE(actual2, storage2); @@ -2017,7 +2017,7 @@ void tst_QMetaType::metaObject_data() QTest::newRow("MyGadget") << ::qMetaTypeId<MyGadget>() << &MyGadget::staticMetaObject << true << false << false; QTest::newRow("MyGadget*") << ::qMetaTypeId<MyGadget*>() << &MyGadget::staticMetaObject << false << true << false; QTest::newRow("MyEnum") << ::qMetaTypeId<MyGadget::MyEnum>() << &MyGadget::staticMetaObject << false << false << false; - QTest::newRow("Qt::ScrollBarPolicy") << ::qMetaTypeId<Qt::ScrollBarPolicy>() << &QObject::staticQtMetaObject << false << false << false; + QTest::newRow("Qt::ScrollBarPolicy") << ::qMetaTypeId<Qt::ScrollBarPolicy>() << &Qt::staticMetaObject << false << false << false; QTest::newRow("MyQObjectFromGadget*") << ::qMetaTypeId<MyQObjectFromGadget*>() << &MyQObjectFromGadget::staticMetaObject << false << false << true; QTest::newRow("GadgetDerivedAndTyped<int>") << ::qMetaTypeId<GadgetDerivedAndTyped<int>>() << &GadgetDerivedAndTyped<int>::staticMetaObject << true << false << false; @@ -2139,7 +2139,7 @@ struct CustomConvertibleType }; bool operator<(const CustomConvertibleType &lhs, const CustomConvertibleType &rhs) -{ return lhs.m_foo < rhs.m_foo; } +{ return lhs.m_foo.toString() < rhs.m_foo.toString(); } bool operator==(const CustomConvertibleType &lhs, const CustomConvertibleType &rhs) { return lhs.m_foo == rhs.m_foo; } bool operator!=(const CustomConvertibleType &lhs, const CustomConvertibleType &rhs) @@ -2429,43 +2429,6 @@ void tst_QMetaType::convertCustomType() QCOMPARE(v.value<CustomConvertibleType2>().m_foo, testCustom.m_foo); } -void tst_QMetaType::compareCustomType_data() -{ - QMetaType::registerComparators<CustomConvertibleType>(); - - QTest::addColumn<QVariantList>("unsorted"); - QTest::addColumn<QVariantList>("sorted"); - - QTest::newRow("int") << (QVariantList() << 37 << 458 << 1 << 243 << -4 << 383) - << (QVariantList() << -4 << 1 << 37 << 243 << 383 << 458); - - QTest::newRow("dobule") << (QVariantList() << 4934.93 << 0.0 << 302.39 << -39.0) - << (QVariantList() << -39.0 << 0.0 << 302.39 << 4934.93); - - QTest::newRow("QString") << (QVariantList() << "Hello" << "World" << "this" << "is" << "a" << "test") - << (QVariantList() << "a" << "Hello" << "is" << "test" << "this" << "World"); - - QTest::newRow("QTime") << (QVariantList() << QTime(14, 39) << QTime(0, 0) << QTime(18, 18) << QTime(9, 27)) - << (QVariantList() << QTime(0, 0) << QTime(9, 27) << QTime(14, 39) << QTime(18, 18)); - - QTest::newRow("QDate") << (QVariantList() << QDate(2013, 3, 23) << QDate(1900, 12, 1) << QDate(2001, 2, 2) << QDate(1982, 12, 16)) - << (QVariantList() << QDate(1900, 12, 1) << QDate(1982, 12, 16) << QDate(2001, 2, 2) << QDate(2013, 3, 23)); - - QTest::newRow("mixed") << (QVariantList() << "Hello" << "World" << QChar('a') << 38 << QChar('z') << -39 << 4.6) - << (QVariantList() << -39 << 4.6 << 38 << QChar('a') << "Hello" << "World" << QChar('z')); - - QTest::newRow("custom") << (QVariantList() << QVariant::fromValue(CustomConvertibleType(1)) << QVariant::fromValue(CustomConvertibleType(100)) << QVariant::fromValue(CustomConvertibleType(50))) - << (QVariantList() << QVariant::fromValue(CustomConvertibleType(1)) << QVariant::fromValue(CustomConvertibleType(50)) << QVariant::fromValue(CustomConvertibleType(100))); -} - -void tst_QMetaType::compareCustomType() -{ - QFETCH(QVariantList, unsorted); - QFETCH(QVariantList, sorted); - std::sort(unsorted.begin(), unsorted.end()); - QCOMPARE(unsorted, sorted); -} - void tst_QMetaType::compareCustomEqualOnlyType() { int metaTypeId = qRegisterMetaType<CustomEqualsOnlyType>(); @@ -2487,11 +2450,6 @@ void tst_QMetaType::compareCustomEqualOnlyType() QCOMPARE(variant100, variant100x); QCOMPARE(variant100, variant100); - // compare always fails - QVERIFY(!(variant50 < variant50)); - QVERIFY(!(variant50 < variant100)); - QVERIFY(!(variant100 < variant50)); - // check QMetaType::compare works/doesn't crash for equals only comparators bool wasSuccess = QMetaType::compare(variant50.constData(), variant50.constData(), metaTypeId, &result); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 21615d6ec4..5ce70f7a0e 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,9 +81,6 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); -#ifndef QT_NO_USERDATA - void testUserData(); -#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -463,7 +460,7 @@ void tst_QObject::connectSlotsByName() sender.setObjectName("Sender"); QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: No matching signal for on_child_signal()"); - QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: Connecting slot on_Sender_signalManyParams() with the first of the following compatible signals: (\"signalManyParams(int,int,int,QString,bool)\", \"signalManyParams(int,int,int,QString,bool,bool)\")"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: Connecting slot on_Sender_signalManyParams() with the first of the following compatible signals: QVector(\"signalManyParams(int,int,int,QString,bool)\", \"signalManyParams(int,int,int,QString,bool,bool)\")"); QMetaObject::connectSlotsByName(&receiver); receiver.called_slots.clear(); @@ -2341,51 +2338,6 @@ void tst_QObject::declareInterface() } -#ifndef QT_NO_USERDATA -class CustomData : public QObjectUserData -{ -public: - int id; -}; - -void tst_QObject::testUserData() -{ - const int USER_DATA_COUNT = 100; - int user_data_ids[USER_DATA_COUNT]; - - // Register a few - for (int i=0; i<USER_DATA_COUNT; ++i) { - user_data_ids[i] = QObject::registerUserData(); - } - - // Randomize the table a bit - for (int i=0; i<100; ++i) { - int p1 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - int p2 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - - int tmp = user_data_ids[p1]; - user_data_ids[p1] = user_data_ids[p2]; - user_data_ids[p2] = tmp; - } - - // insert the user data into an object - QObject my_test_object; - for (int i=0; i<USER_DATA_COUNT; ++i) { - CustomData *data = new CustomData; - data->id = user_data_ids[i]; - my_test_object.setUserData(data->id, data); - } - - // verify that all ids and positions are matching - for (int i=0; i<USER_DATA_COUNT; ++i) { - int id = user_data_ids[i]; - CustomData *data = static_cast<CustomData *>(my_test_object.userData(id)); - QVERIFY(data != nullptr); - QCOMPARE(data->id, id); - } -} -#endif // QT_NO_USERDATA - class DestroyedListener : public QObject { Q_OBJECT @@ -6974,8 +6926,7 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction() QObject *parent = new QObject; QObject *child = new QObject; - QAbstractDeclarativeDataImpl dummy; - dummy.ownedByQml1 = false; + QAbstractDeclarativeData dummy; QObjectPrivate::get(child)->declarativeData = &dummy; parentChangeCalled = false; diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 45eb61f6e4..9f022b3b14 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -190,8 +190,6 @@ private slots: void operator_eq_eq_data(); void operator_eq_eq(); void operator_eq_eq_rhs(); - void compareNumbers_data() const; - void compareNumbers() const; void typeName_data(); void typeName(); @@ -270,9 +268,6 @@ private slots: void enums(); void metaEnums(); - void compareSanity_data(); - void compareSanity(); - void compareRich(); void nullConvert(); @@ -1730,344 +1725,6 @@ void tst_QVariant::operator_eq_eq_rhs() #endif } -void tst_QVariant::compareNumbers_data() const -{ - typedef signed char schar; - QTest::addColumn<QVariant>("v1"); - QTest::addColumn<QVariant>("v2"); - QTest::addColumn<int>("expected"); - - // sanity checking: same types - QTest::newRow("bool1") << QVariant(false) << QVariant(false) << 0; - QTest::newRow("bool2") << QVariant(true) << QVariant(true) << 0; - QTest::newRow("bool3") << QVariant(false) << QVariant(true) << -1; - QTest::newRow("bool4") << QVariant(true) << QVariant(false) << +1; - - QTest::newRow("char1") << QVariant::fromValue(char(0)) << QVariant::fromValue(char(0)) << 0; - QTest::newRow("char2") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(CHAR_MAX) << 0; - QTest::newRow("char3") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(CHAR_MIN) << 0; - QTest::newRow("char4") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(CHAR_MAX) << -1; - QTest::newRow("char5") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(CHAR_MIN) << +1; - - QTest::newRow("schar1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(schar(0)) << 0; - QTest::newRow("schar2") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(SCHAR_MAX) << 0; - QTest::newRow("schar3") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(SCHAR_MIN) << 0; - QTest::newRow("schar4") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(SCHAR_MAX) << -1; - QTest::newRow("schar5") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(SCHAR_MIN) << +1; - - QTest::newRow("uchar1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(uchar(0)) << 0; - QTest::newRow("uchar2") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(UCHAR_MAX) << 0; - QTest::newRow("uchar3") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(UCHAR_MAX) << -1; - QTest::newRow("uchar4") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(uchar(0)) << +1; - - QTest::newRow("short1") << QVariant::fromValue(short(0)) << QVariant::fromValue(short(0)) << 0; - QTest::newRow("short2") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(SHRT_MAX) << 0; - QTest::newRow("short3") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(SHRT_MIN) << 0; - QTest::newRow("short4") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(SHRT_MAX) << -1; - QTest::newRow("short5") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(SHRT_MIN) << +1; - - QTest::newRow("ushort1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(ushort(0)) << 0; - QTest::newRow("ushort2") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(USHRT_MAX) << 0; - QTest::newRow("ushort3") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(USHRT_MAX) << -1; - QTest::newRow("ushort4") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(ushort(0)) << +1; - - QTest::newRow("int1") << QVariant::fromValue(int(0)) << QVariant::fromValue(int(0)) << 0; - QTest::newRow("int2") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(INT_MAX) << 0; - QTest::newRow("int3") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(INT_MIN) << 0; - QTest::newRow("int4") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("int5") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(INT_MIN) << +1; - - QTest::newRow("uint1") << QVariant::fromValue(uint(0)) << QVariant::fromValue(uint(0)) << 0; - QTest::newRow("uint2") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(UINT_MAX) << 0; - QTest::newRow("uint3") << QVariant::fromValue(uint(0)) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("uint4") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(uint(0)) << +1; - - QTest::newRow("long1") << QVariant::fromValue(long(0)) << QVariant::fromValue(long(0)) << 0; - QTest::newRow("long2") << QVariant::fromValue(LONG_MAX) << QVariant::fromValue(LONG_MAX) << 0; - QTest::newRow("long3") << QVariant::fromValue(LONG_MIN) << QVariant::fromValue(LONG_MIN) << 0; - QTest::newRow("long4") << QVariant::fromValue(LONG_MIN) << QVariant::fromValue(LONG_MAX) << -1; - QTest::newRow("long5") << QVariant::fromValue(LONG_MAX) << QVariant::fromValue(LONG_MIN) << +1; - - QTest::newRow("ulong1") << QVariant::fromValue(ulong(0)) << QVariant::fromValue(ulong(0)) << 0; - QTest::newRow("ulong2") << QVariant::fromValue(ULONG_MAX) << QVariant::fromValue(ULONG_MAX) << 0; - QTest::newRow("ulong3") << QVariant::fromValue(ulong(0)) << QVariant::fromValue(ULONG_MAX) << -1; - QTest::newRow("ulong4") << QVariant::fromValue(ULONG_MAX) << QVariant::fromValue(ulong(0)) << +1; - - QTest::newRow("llong1") << QVariant::fromValue(qlonglong(0)) << QVariant::fromValue(qlonglong(0)) << 0; - QTest::newRow("llong2") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(LLONG_MAX) << 0; - QTest::newRow("llong3") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(LLONG_MIN) << 0; - QTest::newRow("llong4") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(LLONG_MAX) << -1; - QTest::newRow("llong5") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(LLONG_MIN) << +1; - - QTest::newRow("ullong1") << QVariant::fromValue(qulonglong(0)) << QVariant::fromValue(qulonglong(0)) << 0; - QTest::newRow("ullong2") << QVariant::fromValue(ULLONG_MAX) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("ullong3") << QVariant::fromValue(qulonglong(0)) << QVariant::fromValue(ULLONG_MAX) << -1; - QTest::newRow("ullong4") << QVariant::fromValue(ULLONG_MAX) << QVariant::fromValue(qulonglong(0)) << +1; - - QTest::newRow("float1") << QVariant::fromValue(0.f) << QVariant::fromValue(0.f) << 0; - QTest::newRow("float2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0.f) << -1; - QTest::newRow("float3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1.f) << +1; - QTest::newRow("float4") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(0.f) << -1; - QTest::newRow("float5") << QVariant::fromValue(0.f) << QVariant::fromValue(-float(qInf())) << +1; - QTest::newRow("float6") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(-float(qInf())) << 0; - QTest::newRow("float7") << QVariant::fromValue(float(qInf())) << QVariant::fromValue(float(qInf())) << 0; - - QTest::newRow("double1") << QVariant::fromValue(0.) << QVariant::fromValue(0.) << 0; - QTest::newRow("double2") << QVariant::fromValue(-1.) << QVariant::fromValue(0.) << -1; - QTest::newRow("double3") << QVariant::fromValue(0.) << QVariant::fromValue(-1.) << +1; - QTest::newRow("double4") << QVariant::fromValue(-qInf()) << QVariant::fromValue(0.) << -1; - QTest::newRow("double5") << QVariant::fromValue(0.) << QVariant::fromValue(-qInf()) << +1; - QTest::newRow("double6") << QVariant::fromValue(-double(qInf())) << QVariant::fromValue(-qInf()) << 0; - QTest::newRow("double7") << QVariant::fromValue(qInf()) << QVariant::fromValue(qInf()) << 0; - QTest::newRow("double8") << QVariant::fromValue(-qInf()) << QVariant::fromValue(qInf()) << -1; - QTest::newRow("double9") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(0.) << INT_MAX; - QTest::newRow("double10") << QVariant::fromValue(0.) << QVariant::fromValue(qQNaN()) << INT_MAX; - QTest::newRow("double11") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(qQNaN()) << INT_MAX; - - // mixed comparisons - // fp + fp - QTest::newRow("float+double1") << QVariant::fromValue(0.f) << QVariant::fromValue(0.) << 0; - QTest::newRow("float+double2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0.) << -1; - QTest::newRow("float+double3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1.) << +1; - QTest::newRow("float+double4") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(0.) << -1; - QTest::newRow("float+double5") << QVariant::fromValue(0.f) << QVariant::fromValue(-qInf()) << +1; - QTest::newRow("float+double6") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(-qInf()) << 0; - QTest::newRow("float+double7") << QVariant::fromValue(float(qInf())) << QVariant::fromValue(qInf()) << 0; - QTest::newRow("float+double8") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(qInf()) << -1; - QTest::newRow("float+double9") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(0.) << INT_MAX; - QTest::newRow("float+double10") << QVariant::fromValue(0.) << QVariant::fromValue(qQNaN()) << INT_MAX; - QTest::newRow("float+double11") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(qQNaN()) << INT_MAX; - - // fp + int - QTest::newRow("float+int1") << QVariant::fromValue(0.f) << QVariant::fromValue(0) << 0; - QTest::newRow("double+int1") << QVariant::fromValue(0.) << QVariant::fromValue(0) << 0; - QTest::newRow("float+int2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0) << -1; - QTest::newRow("double+int2") << QVariant::fromValue(-1.) << QVariant::fromValue(0) << -1; - QTest::newRow("float+int3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1) << +1; - QTest::newRow("double+int3") << QVariant::fromValue(0.) << QVariant::fromValue(-1) << +1; - QTest::newRow("float+int4") << QVariant::fromValue(1.5f) << QVariant::fromValue(1) << +1; - QTest::newRow("double+int4") << QVariant::fromValue(1.5) << QVariant::fromValue(1) << +1; - QTest::newRow("double+int5") << QVariant::fromValue(qInf()) << QVariant::fromValue(1) << +1; - - // fp + uint - QTest::newRow("float+uint1") << QVariant::fromValue(0.f) << QVariant::fromValue(0U) << 0; - QTest::newRow("double+uint1") << QVariant::fromValue(0.) << QVariant::fromValue(0U) << 0; - QTest::newRow("float+uint2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0U) << -1; - QTest::newRow("double+uint2") << QVariant::fromValue(-1.) << QVariant::fromValue(0U) << -1; - QTest::newRow("float+uint3") << QVariant::fromValue(0.f) << QVariant::fromValue(1U) << -1; - QTest::newRow("double+uint3") << QVariant::fromValue(0.) << QVariant::fromValue(1U) << -1; - QTest::newRow("float+uint4") << QVariant::fromValue(1.5f) << QVariant::fromValue(1U) << +1; - QTest::newRow("double+uint4") << QVariant::fromValue(1.5) << QVariant::fromValue(1U) << +1; - - // lower ranked + int - QTest::newRow("bool+int1") << QVariant::fromValue(false) << QVariant::fromValue(0) << 0; - QTest::newRow("bool+int2") << QVariant::fromValue(false) << QVariant::fromValue(1) << -1; - QTest::newRow("bool+int3") << QVariant::fromValue(true) << QVariant::fromValue(0) << +1; - QTest::newRow("bool+int4") << QVariant::fromValue(true) << QVariant::fromValue(1) << 0; - QTest::newRow("bool+int5") << QVariant::fromValue(true) << QVariant::fromValue(2) << -1; - - QTest::newRow("char+int1") << QVariant::fromValue(char(0)) << QVariant::fromValue(0) << 0; - QTest::newRow("char+int2") << QVariant::fromValue(char(0)) << QVariant::fromValue(1) << -1; - QTest::newRow("char+int3") << QVariant::fromValue(char(1)) << QVariant::fromValue(0) << +1; - QTest::newRow("char+int4") << QVariant::fromValue(char(1)) << QVariant::fromValue(1) << 0; - if (std::numeric_limits<char>::is_signed) { - QTest::newRow("char+int5") << QVariant::fromValue(char(-1)) << QVariant::fromValue(0) << -1; - QTest::newRow("char+int6") << QVariant::fromValue(char(-1)) << QVariant::fromValue(-1) << 0; - } - - QTest::newRow("schar+int1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(0) << 0; - QTest::newRow("schar+int2") << QVariant::fromValue(schar(0)) << QVariant::fromValue(1) << -1; - QTest::newRow("schar+int3") << QVariant::fromValue(schar(1)) << QVariant::fromValue(0) << +1; - QTest::newRow("schar+int4") << QVariant::fromValue(schar(1)) << QVariant::fromValue(1) << 0; - QTest::newRow("schar+int5") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(0) << -1; - QTest::newRow("schar+int6") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(-1) << 0; - - QTest::newRow("uchar+int1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(0) << 0; - QTest::newRow("uchar+int2") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(1) << -1; - QTest::newRow("uchar+int3") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(0) << +1; - QTest::newRow("uchar+int4") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(1) << 0; - - QTest::newRow("short+int1") << QVariant::fromValue(short(0)) << QVariant::fromValue(0) << 0; - QTest::newRow("short+int2") << QVariant::fromValue(short(0)) << QVariant::fromValue(1) << -1; - QTest::newRow("short+int3") << QVariant::fromValue(short(1)) << QVariant::fromValue(0) << +1; - QTest::newRow("short+int4") << QVariant::fromValue(short(1)) << QVariant::fromValue(1) << 0; - QTest::newRow("short+int5") << QVariant::fromValue(short(-1)) << QVariant::fromValue(0) << -1; - QTest::newRow("short+int6") << QVariant::fromValue(short(-1)) << QVariant::fromValue(-1) << 0; - - QTest::newRow("ushort+int1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(0) << 0; - QTest::newRow("ushort+int2") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(1) << -1; - QTest::newRow("ushort+int3") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(0) << +1; - QTest::newRow("ushort+int4") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(1) << 0; - - // lower ranked + uint (without sign change) - QTest::newRow("bool+uint1") << QVariant::fromValue(false) << QVariant::fromValue(0U) << 0; - QTest::newRow("bool+uint2") << QVariant::fromValue(false) << QVariant::fromValue(1U) << -1; - QTest::newRow("bool+uint3") << QVariant::fromValue(true) << QVariant::fromValue(0U) << +1; - QTest::newRow("bool+uint4") << QVariant::fromValue(true) << QVariant::fromValue(1U) << 0; - QTest::newRow("bool+uint5") << QVariant::fromValue(true) << QVariant::fromValue(2U) << -1; - - QTest::newRow("char+uint1") << QVariant::fromValue(char(0)) << QVariant::fromValue(0U) << 0; - QTest::newRow("char+uint2") << QVariant::fromValue(char(0)) << QVariant::fromValue(1U) << -1; - QTest::newRow("char+uint3") << QVariant::fromValue(char(1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("char+uint4") << QVariant::fromValue(char(1)) << QVariant::fromValue(1U) << 0; - - QTest::newRow("schar+uint1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(0U) << 0; - QTest::newRow("schar+uint2") << QVariant::fromValue(schar(0)) << QVariant::fromValue(1U) << -1; - QTest::newRow("schar+uint3") << QVariant::fromValue(schar(1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("schar+uint4") << QVariant::fromValue(schar(1)) << QVariant::fromValue(1U) << 0; - - QTest::newRow("uchar+uint1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(0U) << 0; - QTest::newRow("uchar+uint2") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(1U) << -1; - QTest::newRow("uchar+uint3") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("uchar+uint4") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(1U) << 0; - - QTest::newRow("short+uint1") << QVariant::fromValue(short(0)) << QVariant::fromValue(0U) << 0; - QTest::newRow("short+uint2") << QVariant::fromValue(short(0)) << QVariant::fromValue(1U) << -1; - QTest::newRow("short+uint3") << QVariant::fromValue(short(1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("short+uint4") << QVariant::fromValue(short(1)) << QVariant::fromValue(1U) << 0; - - QTest::newRow("ushort+uint1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(0U) << 0; - QTest::newRow("ushort+uint2") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(1U) << -1; - QTest::newRow("ushort+uint3") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("ushort+uint4") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(1U) << 0; - - // int + qlonglong - QTest::newRow("int+qlonglong1") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(0)) << 0; - QTest::newRow("int+qlonglong2") << QVariant::fromValue(1) << QVariant::fromValue(Q_INT64_C(0)) << +1; - QTest::newRow("int+qlonglong3") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(1)) << -1; - QTest::newRow("int+qlonglong4") << QVariant::fromValue(1) << QVariant::fromValue(Q_INT64_C(1)) << 0; - QTest::newRow("int+qlonglong5") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(-1)) << +1; - QTest::newRow("int+qlonglong6") << QVariant::fromValue(-1) << QVariant::fromValue(Q_INT64_C(0)) << -1; - QTest::newRow("int+qlonglong7") << QVariant::fromValue(-1) << QVariant::fromValue(Q_INT64_C(-1)) << 0; - - // uint + qulonglong - QTest::newRow("uint+qulonglong1") << QVariant::fromValue(0U) << QVariant::fromValue(Q_UINT64_C(0)) << 0; - QTest::newRow("uint+qulonglong2") << QVariant::fromValue(1U) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("uint+qulonglong3") << QVariant::fromValue(0U) << QVariant::fromValue(Q_UINT64_C(1)) << -1; - QTest::newRow("uint+qulonglong4") << QVariant::fromValue(1U) << QVariant::fromValue(Q_UINT64_C(1)) << 0; - - // int + uint (without sign change) - QTest::newRow("int+uint1") << QVariant::fromValue(0) << QVariant::fromValue(0U) << 0; - QTest::newRow("int+uint2") << QVariant::fromValue(1) << QVariant::fromValue(0U) << +1; - QTest::newRow("int+uint3") << QVariant::fromValue(0) << QVariant::fromValue(1U) << -1; - QTest::newRow("int+uint4") << QVariant::fromValue(1) << QVariant::fromValue(1U) << 0; - - // uint + qlonglong - QTest::newRow("uint+qlonglong1") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(0)) << 0; - QTest::newRow("uint+qlonglong2") << QVariant::fromValue(1U) << QVariant::fromValue(Q_INT64_C(0)) << +1; - QTest::newRow("uint+qlonglong3") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(1)) << -1; - QTest::newRow("uint+qlonglong4") << QVariant::fromValue(1U) << QVariant::fromValue(Q_INT64_C(1)) << 0; - QTest::newRow("uint+qlonglong5") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(-1)) << +1; - - // boundary conditions - QTest::newRow("charmax+intmax") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("charmax+uintmax") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("scharmax+intmax") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("scharmax+uintmax") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("ucharmax+intmax") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("ucharmax+uintmax") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("shortmax+intmax") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("shortmax+uintmax") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("ushortmax+intmax") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(INT_MAX) << -1; - QTest::newRow("ushortmax+uintmax") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(UINT_MAX) << -1; - - QTest::newRow("intmin+qlonglongmin") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(LLONG_MIN) << +1; - QTest::newRow("intmax+uintmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(UINT_MAX) << -1; - QTest::newRow("intmax+qlonglongmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(LLONG_MAX) << -1; - QTest::newRow("uintmax+qlonglongmax") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(LLONG_MAX) << -1; - QTest::newRow("intmax+qulonglongmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(ULLONG_MAX) << -1; - QTest::newRow("qlonglongmax+qulonglongmax") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(ULLONG_MAX) << -1; - QTest::newRow("uintmax+qlonglongmin") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(LLONG_MIN) << +1; - - // check for no sign-extension issues - QTest::newRow("ushortmax+intzero") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(0) << +1; - QTest::newRow("ushortmax+qlonglongzero") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(Q_INT64_C(0)) << +1; - QTest::newRow("uintmax+qlonglongzero") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(Q_INT64_C(0)) << +1; - - // sign changes - // the tests below check that a signed negative number sign-changes to a non-zero unsigned number and that - // signed -1 sign-changes to unsigned maximum (all bits set, ~0). This works on two's complement machines - // (all that Qt supports), and would also work on one's complement. - if (std::numeric_limits<char>::is_signed) { - QTest::newRow("signchange-char+uint") << QVariant::fromValue(char(-1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-char+uintmax") << QVariant::fromValue(char(-1)) << QVariant::fromValue(UINT_MAX) << 0; - QTest::newRow("signchange-charmin+uint") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-char+qulonglong") << QVariant::fromValue(char(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-char+qulonglongmax") << QVariant::fromValue(char(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-charmin+qulonglong") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - } - QTest::newRow("signchange-schar+uint") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-schar+uintmax") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(UINT_MAX) << 0; - QTest::newRow("signchange-scharmin+uint") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-schar+qulonglong") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-schar+qulonglongmax") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-scharmin+qulonglong") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-short+uint") << QVariant::fromValue(short(-1)) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-short+uintmax") << QVariant::fromValue(short(-1)) << QVariant::fromValue(UINT_MAX) << 0; - QTest::newRow("signchange-shortmin+uint") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-short+qulonglong") << QVariant::fromValue(short(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-short+qulonglongmax") << QVariant::fromValue(short(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-shortmin+qulonglong") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-int+uint") << QVariant::fromValue(-1) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-int+uintmax") << QVariant::fromValue(-1) << QVariant::fromValue(UINT_MAX) << 0; - QTest::newRow("signchange-intmin+uint") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(0U) << +1; - QTest::newRow("signchange-int+qulonglong") << QVariant::fromValue(-1) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-int+qulonglongmax") << QVariant::fromValue(-1) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-intmin+qulonglong") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - // no qlonglong+uint, since that should promote to qlonglong and then the comparison is signed (tested above) - QTest::newRow("signchange-qlonglong+qulonglong") << QVariant::fromValue(Q_INT64_C(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-qlonglong+qulonglongmax") << QVariant::fromValue(Q_INT64_C(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-qlonglongmin+qulonglong") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; -} - -void tst_QVariant::compareNumbers() const -{ - QFETCH(QVariant, v1); - QFETCH(QVariant, v2); - QFETCH(int, expected); - - if (expected == -1) { - QVERIFY(v1 < v2); - QVERIFY(v1 <= v2); - QVERIFY(!(v1 == v2)); - QVERIFY(!(v1 > v2)); - QVERIFY(!(v1 >= v2)); - - QVERIFY(!(v2 < v1)); - QVERIFY(!(v2 <= v1)); - QVERIFY(!(v2 == v1)); - QVERIFY(v2 >= v1); - QVERIFY(v2 > v1); - } else if (expected == 0) { - QVERIFY(!(v1 < v2)); - QVERIFY(v1 <= v2); - QCOMPARE(v1, v2); - QVERIFY(!(v1 > v2)); - QVERIFY(v1 >= v2); - - QVERIFY(!(v2 < v1)); - QVERIFY(v2 <= v1); - QCOMPARE(v2, v1); - QVERIFY(v2 >= v1); - QVERIFY(!(v2 > v1)); - } else if (expected == +1) { - QVERIFY(!(v1 < v2)); - QVERIFY(!(v1 <= v2)); - QVERIFY(!(v1 == v2)); - QVERIFY(v1 > v2); - QVERIFY(v1 >= v2); - - QVERIFY(v2 < v1); - QVERIFY(v2 <= v1); - QVERIFY(!(v2 == v1)); - QVERIFY(!(v2 >= v1)); - QVERIFY(!(v2 > v1)); - } else { - // unorderable (NaN) - QVERIFY(!(v1 == v2)); - } -} - void tst_QVariant::typeName_data() { QTest::addColumn<int>("type"); @@ -3961,8 +3618,7 @@ Q_DECLARE_METATYPE(Convertible); struct BigConvertible { double d; - double dummy; - double dummy2; + double dummy[sizeof(QVariant) / sizeof(double)]; operator int() const { return (int)d; } operator double() const { return d; } operator QString() const { return QString::number(d); } @@ -4863,86 +4519,6 @@ void tst_QVariant::metaEnums() METAENUMS_TEST(MetaEnumTest_Enum8_value); } -void tst_QVariant::compareSanity_data() -{ - QTest::addColumn<QVariant>("value1"); - QTest::addColumn<QVariant>("value2"); - - QTest::newRow( "int <>/== QUrl" ) << QVariant( 97 ) << QVariant(QUrl("a")); - QTest::newRow( "int <>/== QChar" ) << QVariant( 97 ) << QVariant(QChar('a')); - QTest::newRow( "int <>/== QString" ) << QVariant( 97 ) << QVariant(QString("a")); - QTest::newRow( "QUrl <>/== QChar" ) << QVariant(QUrl("a")) << QVariant(QChar('a')); - QTest::newRow( "QUrl <>/== QString" ) << QVariant(QUrl("a")) << QVariant(QString("a")); - QTest::newRow( "QChar <>/== QString" ) << QVariant(QChar('a')) << QVariant(QString("a")); -} - -void tst_QVariant::compareSanity() -{ - QFETCH(QVariant, value1); - QFETCH(QVariant, value2); - - if (value1 == value2) { - QVERIFY(!(value1 < value2) && !(value1 > value2)); - } else { - QVERIFY(value1 != value2); - QVERIFY((value1 < value2) || (value1 > value2)); - } -} - -static void richComparison(const QVariant& less, const QVariant& more) -{ - QVERIFY(less.type() == more.type()); - - QVERIFY(less < more); - QVERIFY(!(more < less)); - - QVERIFY(more > less); - QVERIFY(!(less > more)); - - QVERIFY(less <= more); - QVERIFY(!(more <= less)); - QVERIFY(less <= less); - - QVERIFY(more >= less); - QVERIFY(!(less >= more)); - QVERIFY(more >= more); -} - -void tst_QVariant::compareRich() -{ - richComparison(QUuid("{49d8ad2a-2ee8-4c3d-949f-1b5a3765ddf0}"), - QUuid("{f6d56824-16e9-4543-a375-add2877c2d05}")); - richComparison(QByteArray::fromRawData("a", 1), - QByteArray::fromRawData("b", 1)); - richComparison(QStringLiteral("a"), QStringLiteral("b")); - richComparison(QLatin1String("a"), QLatin1String("b")); - richComparison(QChar('a'), QChar('b')); - richComparison(QDate(2016, 7, 23), QDate(2016, 7, 24)); - richComparison(QTime(0, 0), QTime(0, 1)); - richComparison(QDateTime(QDate(2016, 7, 23), QTime(0, 0)), - QDateTime(QDate(2016, 7, 23), QTime(0, 1))); - - richComparison(QStringList(), QStringList() << QStringLiteral("a")); - richComparison(QStringList(), QStringList() << QStringLiteral("a") - << QStringLiteral("b")); - richComparison(QStringList() << QStringLiteral("a"), - QStringList() << QStringLiteral("b")); - richComparison(QStringList() << QStringLiteral("a"), - QStringList() << QStringLiteral("b") - << QStringLiteral("c")); - richComparison(QStringList() << QStringLiteral("a") - << QStringLiteral("c"), - QStringList() << QStringLiteral("b")); - richComparison(QStringList() << QStringLiteral("a") - << QStringLiteral("c"), - QStringList() << QStringLiteral("b") - << QStringLiteral("d")); - richComparison(QStringList() << QStringLiteral("a") - << QStringLiteral("c"), - QStringList() << QStringLiteral("a") - << QStringLiteral("d")); -} - void tst_QVariant::nullConvert() { // Test quirks with QVariants different types of null states. |