diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-07-06 16:15:23 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-07-07 11:48:45 +0200 |
commit | 989fca660c3556fa957ed9a3f7cd3b948a4166a2 (patch) | |
tree | 8479b302afd3458cd2583dffc9e5dc52e512d9a1 /tests/auto/corelib/kernel | |
parent | d33655a9531b750e1574742ff575f871c19ed808 (diff) |
Use QList instead of QVector in corelib tests
Task-number: QTBUG-84469
Change-Id: Ic80fde5517aed363f17d0da55cadcc958c3c8895
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel')
8 files changed, 63 insertions, 69 deletions
diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp index dbc0716463..057f61e6c1 100644 --- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp +++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp @@ -648,7 +648,7 @@ void tst_QMetaMethod::method() QCOMPARE(method.parameterType(i), parameterTypes.at(i)); { - QVector<int> actualParameterTypes(parameterTypes.size()); + QList<int> actualParameterTypes(parameterTypes.size()); method.getParameterTypes(actualParameterTypes.data()); for (int i = 0; i < parameterTypes.size(); ++i) QCOMPARE(actualParameterTypes.at(i), parameterTypes.at(i)); diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index a8f6914115..4711e5999b 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -518,7 +518,7 @@ public slots: void slotWithRegistrableArgument(QtTestObject *o1, QPointer<QtTestObject> o2, QSharedPointer<QtTestObject> o3, QWeakPointer<QtTestObject> o4, - QVector<QtTestObject *> o5, QList<QtTestObject *> o6) + QList<QtTestObject *> o5, QList<QtTestObject *> o6) { slotResult = QLatin1String("slotWithRegistrableArgument:") + o1->slotResult + o2->slotResult + o3->slotResult + o4.toStrongRef()->slotResult + QString::number(o5.size()) @@ -1297,7 +1297,7 @@ void tst_QMetaObject::invokeQueuedAutoRegister() &obj, "slotWithRegistrableArgument", Qt::QueuedConnection, Q_ARG(QtTestObject *, shared.data()), Q_ARG(QPointer<QtTestObject>, shared.data()), Q_ARG(QSharedPointer<QtTestObject>, shared), Q_ARG(QWeakPointer<QtTestObject>, shared), - Q_ARG(QVector<QtTestObject *>, QVector<QtTestObject *>()), + Q_ARG(QList<QtTestObject *>, QList<QtTestObject *>()), Q_ARG(QList<QtTestObject *>, QList<QtTestObject *>()))); QVERIFY(obj.slotResult.isEmpty()); qApp->processEvents(QEventLoop::AllEvents); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 48b46dd98f..8d4cc05eb9 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -66,7 +66,7 @@ public: void setProp(const QList<QVariant> &list) { propList = list; } private: - void registerGadget(const char * name, const QVector<GadgetPropertyType> &gadgetProperties); + void registerGadget(const char * name, const QList<GadgetPropertyType> &gadgetProperties); QList<QVariant> propList; private slots: @@ -183,7 +183,7 @@ struct GenericGadgetType : BaseGenericType for (auto &prop : properties) in >> prop; } - QVector<QVariant> properties; + QList<QVariant> properties; }; struct GenericPODType : BaseGenericType @@ -287,7 +287,7 @@ class GadgetDerivedAndTyped : public CustomGadget {}; Q_DECLARE_METATYPE(GadgetDerivedAndTyped<int>) Q_DECLARE_METATYPE(GadgetDerivedAndTyped<int>*) -void tst_QMetaType::registerGadget(const char *name, const QVector<GadgetPropertyType> &gadgetProperties) +void tst_QMetaType::registerGadget(const char *name, const QList<GadgetPropertyType> &gadgetProperties) { QMetaObjectBuilder gadgetBuilder; gadgetBuilder.setClassName(name); @@ -581,13 +581,13 @@ void tst_QMetaType::typeName_data() QTest::newRow("124125534") << 124125534 << QString(); // automatic registration - 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<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QList<QMap<int,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("QList<QMap<int,int>>") << ::qMetaTypeId<QList<QMap<int, int>>>() << QString::fromLatin1("QList<QMap<int,int>>"); - // automatic registration with automatic QList to QVector aliasing - QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QList<int>"); - QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QList<QList<int>>"); + // automatic registration with automatic QList to QList aliasing + QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int>>() << QString::fromLatin1("QList<int>"); + QTest::newRow("QList<QList<int>>") << ::qMetaTypeId<QList<QList<int>>>() << QString::fromLatin1("QList<QList<int>>"); QTest::newRow("CustomQObject*") << ::qMetaTypeId<CustomQObject*>() << QString::fromLatin1("CustomQObject*"); QTest::newRow("CustomGadget") << ::qMetaTypeId<CustomGadget>() << QString::fromLatin1("CustomGadget"); @@ -1109,7 +1109,7 @@ FOR_EACH_CORE_METATYPE(RETURN_CONSTRUCT_FUNCTION) void tst_QMetaType::typedConstruct() { - auto testMetaObjectWriteOnGadget = [](QVariant &gadget, const QVector<GadgetPropertyType> &properties) + auto testMetaObjectWriteOnGadget = [](QVariant &gadget, const QList<GadgetPropertyType> &properties) { auto metaObject = QMetaType::metaObjectForType(gadget.userType()); QVERIFY(metaObject != nullptr); @@ -1123,7 +1123,7 @@ void tst_QMetaType::typedConstruct() } }; - auto testMetaObjectReadOnGadget = [](QVariant gadget, const QVector<GadgetPropertyType> &properties) + auto testMetaObjectReadOnGadget = [](QVariant gadget, const QList<GadgetPropertyType> &properties) { auto metaObject = QMetaType::metaObjectForType(gadget.userType()); QVERIFY(metaObject != nullptr); @@ -1138,7 +1138,7 @@ void tst_QMetaType::typedConstruct() } }; - QVector<GadgetPropertyType> dynamicGadget1 = { + QList<GadgetPropertyType> dynamicGadget1 = { {"int", "int_prop", 34526}, {"float", "float_prop", 1.23f}, {"QString", "string_prop", QString{"Test QString"}} @@ -1150,7 +1150,7 @@ void tst_QMetaType::typedConstruct() testMetaObjectReadOnGadget(testGadget1, dynamicGadget1); - QVector<GadgetPropertyType> dynamicGadget2 = { + QList<GadgetPropertyType> dynamicGadget2 = { {"int", "int_prop", 512}, {"double", "double_prop", 4.56}, {"QString", "string_prop", QString{"Another String"}}, @@ -1510,9 +1510,9 @@ void tst_QMetaType::automaticTemplateRegistration() CONTAINER<VALUE_TYPE> innerContainer; \ innerContainer.push_back(42); \ QVERIFY(*QVariant::fromValue(innerContainer).value<CONTAINER<VALUE_TYPE> >().begin() == 42); \ - QVector<CONTAINER<VALUE_TYPE> > outerContainer; \ + QList<CONTAINER<VALUE_TYPE> > outerContainer; \ outerContainer << innerContainer; \ - QVERIFY(*QVariant::fromValue(outerContainer).value<QVector<CONTAINER<VALUE_TYPE> > >().first().begin() == 42); \ + QVERIFY(*QVariant::fromValue(outerContainer).value<QList<CONTAINER<VALUE_TYPE> > >().first().begin() == 42); \ } TEST_SEQUENTIAL_CONTAINER(QList, int) @@ -1524,19 +1524,19 @@ void tst_QMetaType::automaticTemplateRegistration() vecbool.push_back(true); vecbool.push_back(false); vecbool.push_back(true); - QVERIFY(QVariant::fromValue(vecbool).value<std::vector<bool> >().front() == true); - QVector<std::vector<bool> > vectorList; + QVERIFY(QVariant::fromValue(vecbool).value<std::vector<bool>>().front() == true); + QList<std::vector<bool>> vectorList; vectorList << vecbool; - QVERIFY(QVariant::fromValue(vectorList).value<QVector<std::vector<bool> > >().first().front() == true); + QVERIFY(QVariant::fromValue(vectorList).value<QList<std::vector<bool>>>().first().front() == true); } { QList<unsigned> unsignedList; unsignedList << 123; - QVERIFY(QVariant::fromValue(unsignedList).value<QList<unsigned> >().first() == 123); - QVector<QList<unsigned> > vectorList; + QVERIFY(QVariant::fromValue(unsignedList).value<QList<unsigned>>().first() == 123); + QList<QList<unsigned>> vectorList; vectorList << unsignedList; - QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<unsigned> > >().first().first() == 123); + QVERIFY(QVariant::fromValue(vectorList).value<QList<QList<unsigned>>>().first().first() == 123); } QCOMPARE(::qMetaTypeId<QVariantList>(), (int)QMetaType::QVariantList); @@ -1550,10 +1550,10 @@ void tst_QMetaType::automaticTemplateRegistration() QList<QSharedPointer<QObject> > sharedPointerList; QObject *testObject = new QObject; sharedPointerList << QSharedPointer<QObject>(testObject); - QVERIFY(QVariant::fromValue(sharedPointerList).value<QList<QSharedPointer<QObject> > >().first() == testObject); - QVector<QList<QSharedPointer<QObject> > > vectorList; + QVERIFY(QVariant::fromValue(sharedPointerList).value<QList<QSharedPointer<QObject>>>().first() == testObject); + QList<QList<QSharedPointer<QObject>>> vectorList; vectorList << sharedPointerList; - QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QSharedPointer<QObject> > > >().first().first() == testObject); + QVERIFY(QVariant::fromValue(vectorList).value<QList<QList<QSharedPointer<QObject>>>>().first().first() == testObject); } { IntIntHash intIntHash; @@ -1714,9 +1714,6 @@ void tst_QMetaType::automaticTemplateRegistration() #define FOR_EACH_1ARG_TEMPLATE_TYPE(F, TYPE) \ F(QList, TYPE) \ - F(QVector, TYPE) \ - F(QVector, TYPE) \ - F(QVector, TYPE) \ F(QQueue, TYPE) \ F(QStack, TYPE) \ F(QSet, TYPE) @@ -1736,7 +1733,7 @@ void tst_QMetaType::automaticTemplateRegistration() FOR_EACH_STATIC_PRIMITIVE_TYPE2(PRINT_2ARG_TEMPLATE_INTERNAL, RealName) #define REGISTER_TYPEDEF(TYPE, ARG1, ARG2) \ - qRegisterMetaType<TYPE <ARG1, ARG2> >(#TYPE "<" #ARG1 "," #ARG2 ">"); + qRegisterMetaType<TYPE <ARG1, ARG2>>(#TYPE "<" #ARG1 "," #ARG2 ">"); REGISTER_TYPEDEF(QHash, int, uint) REGISTER_TYPEDEF(QMap, int, uint) @@ -1749,9 +1746,9 @@ void tst_QMetaType::automaticTemplateRegistration() PRINT_2ARG_TEMPLATE ) - CREATE_AND_VERIFY_CONTAINER(QList, QList<QMap<int, QHash<char, QList<QVariant> > > >) - CREATE_AND_VERIFY_CONTAINER(QVector, void*) - CREATE_AND_VERIFY_CONTAINER(QVector, const void*) + CREATE_AND_VERIFY_CONTAINER(QList, QList<QMap<int, QHash<char, QList<QVariant>>>>) + CREATE_AND_VERIFY_CONTAINER(QList, void*) + CREATE_AND_VERIFY_CONTAINER(QList, const void*) CREATE_AND_VERIFY_CONTAINER(QList, void*) CREATE_AND_VERIFY_CONTAINER(std::pair, void*, void*) CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*) @@ -2548,16 +2545,16 @@ void tst_QMetaType::operatorEq_data() QTest::newRow("String") << QMetaType(QMetaType::QString) << QMetaType::fromType<const QString &>() << true; - QTest::newRow("void1") << QMetaType(QMetaType::UnknownType) << QMetaType::fromType<void>() - << false; - QTest::newRow("void2") << QMetaType::fromType<const void>() << QMetaType::fromType<void>() - << true; - QTest::newRow("vec1") << QMetaType::fromType<QVector<const int *>>() - << QMetaType::fromType<QVector<const int *>>() << true; - QTest::newRow("vec2") << QMetaType::fromType<QVector<const int *>>() - << QMetaType::fromType<QVector<int *>>() << false; - QTest::newRow("char1") << QMetaType::fromType<CharTemplate<'>'>>() - << QMetaType::fromType<CharTemplate<'>', void>>() << true; + QTest::newRow("void1") << QMetaType(QMetaType::UnknownType) << QMetaType::fromType<void>() + << false; + QTest::newRow("void2") << QMetaType::fromType<const void>() << QMetaType::fromType<void>() + << true; + QTest::newRow("list1") << QMetaType::fromType<QList<const int *>>() + << QMetaType::fromType<QList<const int *>>() << true; + QTest::newRow("list2") << QMetaType::fromType<QList<const int *>>() + << QMetaType::fromType<QList<int *>>() << false; + QTest::newRow("char1") << QMetaType::fromType<CharTemplate<'>'>>() + << QMetaType::fromType<CharTemplate<'>', void>>() << true; QTest::newRow("annon1") << QMetaType::fromType<decltype(CharTemplate<'>'>::x)>() << QMetaType::fromType<decltype(CharTemplate<'>'>::x)>() << true; QTest::newRow("annon2") << QMetaType::fromType<decltype(CharTemplate<'>'>::x)>() diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index cafc193257..96cf6da4bb 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -381,7 +381,7 @@ void tst_QProperty::moveCtor() void tst_QProperty::changeHandler() { QProperty<int> testProperty(0); - QVector<int> recordedValues; + QList<int> recordedValues; { auto handler = testProperty.onValueChanged([&]() { @@ -424,7 +424,7 @@ void tst_QProperty::propertyChangeHandlerApi() void tst_QProperty::subscribe() { QProperty<int> testProperty(42); - QVector<int> recordedValues; + QList<int> recordedValues; { auto handler = testProperty.subscribe([&]() { @@ -754,7 +754,7 @@ void tst_QProperty::propertyAlias() struct ClassWithNotifiedProperty { - QVector<int> recordedValues; + QList<int> recordedValues; void callback() { recordedValues << property.value(); } @@ -763,7 +763,7 @@ struct ClassWithNotifiedProperty struct ClassWithNotifiedProperty2 { - QVector<int> recordedValues; + QList<int> recordedValues; void callback(int oldValue) { recordedValues << oldValue; } @@ -852,7 +852,7 @@ void tst_QProperty::notifiedPropertyWithOldValueCallback() instance.property.setBinding(&instance, [](){return 2;}); instance.property.setBinding(&instance, [](){return 3;}); instance.property.setValue(&instance, 4); - QVector<int> expected {0, 1, 2, 3}; + QList<int> expected {0, 1, 2, 3}; QCOMPARE(instance.recordedValues, expected); QCOMPARE(instance.property.value(), 4); } @@ -860,7 +860,7 @@ void tst_QProperty::notifiedPropertyWithOldValueCallback() struct ClassWithNotifiedPropertyWithGuard { using This = ClassWithNotifiedPropertyWithGuard; - QVector<int> recordedValues; + QList<int> recordedValues; void callback() { recordedValues << property.value(); } void callback2() { recordedValues << property2.value(); } @@ -968,7 +968,7 @@ void tst_QProperty::notifiedPropertyWithGuard() // properties' value. At that point we then evaluate the binding, and // notice that the value is in fact disallowed. Thus we return the old // value. - QVector<int> expected {1, 1, 2, 3}; + QList<int> expected {1, 1, 2, 3}; QCOMPARE(instance2.recordedValues, expected); } diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp index 5f010ae3d1..496e214b8f 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/tst_qsystemsemaphore.cpp @@ -27,8 +27,8 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <QtCore/QList> #include <QtCore/QSystemSemaphore> -#include <QtCore/QVector> #include <QtCore/QTemporaryDir> #define EXISTING_SHARE "existing" @@ -207,7 +207,7 @@ void tst_QSystemSemaphore::processes() QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); QFETCH(int, processes); - QVector<QString> scripts(processes, "acquirerelease"); + QList<QString> scripts(processes, "acquirerelease"); QList<QProcess*> consumers; for (int i = 0; i < scripts.count(); ++i) { diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 1bd27cd0ce..ae61075169 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -1055,7 +1055,7 @@ public: FunctorNoCtx }; Q_ENUM(CallType) - QVector<CallType> calls; + QList<CallType> calls; void triggerCall(CallType callType) { @@ -1087,7 +1087,7 @@ Q_DECLARE_METATYPE(OrderHelper::CallType) void tst_QTimer::timerOrder() { - QFETCH(QVector<OrderHelper::CallType>, calls); + QFETCH(QList<OrderHelper::CallType>, calls); OrderHelper helper; @@ -1099,9 +1099,9 @@ void tst_QTimer::timerOrder() void tst_QTimer::timerOrder_data() { - QTest::addColumn<QVector<OrderHelper::CallType>>("calls"); + QTest::addColumn<QList<OrderHelper::CallType>>("calls"); - QVector<OrderHelper::CallType> calls = { + QList<OrderHelper::CallType> calls = { OrderHelper::String, OrderHelper::PMF, OrderHelper::Functor, OrderHelper::FunctorNoCtx }; @@ -1135,7 +1135,7 @@ struct StaticSingleShotUser } OrderHelper helper; - static QVector<OrderHelper::CallType> calls() + static QList<OrderHelper::CallType> calls() { return {OrderHelper::String, OrderHelper::PMF, OrderHelper::Functor, OrderHelper::FunctorNoCtx}; diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index c9a60c44e6..192a75d7ae 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -285,7 +285,7 @@ private: void saveQVariantFromDataStream(QDataStream::Version version); CustomNonQObject *customNonQObjectPointer; - QVector<QObject*> objectPointerTestData; + QList<QObject*> objectPointerTestData; }; const qlonglong intMax1 = (qlonglong)INT_MAX + 1; @@ -3472,9 +3472,9 @@ void tst_QVariant::moreCustomTypes() } { - QList<QVector<int> > data; + QList<QList<int> > data; PLAY_WITH_VARIANT(data, false, QString(), 0, false); - data << (QVector<int>() << 42); + data << (QList<int>() << 42); PLAY_WITH_VARIANT(data, false, QString(), 0, false); } @@ -4173,9 +4173,6 @@ void tst_QVariant::iterateContainerElements() TEST_SEQUENTIAL_ITERATION_ON_FULL_NAME(CONTAINER<VALUE_TYPE > ) - TEST_SEQUENTIAL_ITERATION(QVector, int) - TEST_SEQUENTIAL_ITERATION(QVector, QVariant) - TEST_SEQUENTIAL_ITERATION(QVector, QString) TEST_SEQUENTIAL_ITERATION(QQueue, int) TEST_SEQUENTIAL_ITERATION(QQueue, QVariant) TEST_SEQUENTIAL_ITERATION(QQueue, QString) @@ -4668,14 +4665,14 @@ void tst_QVariant::sequentialIterableEndianessSanityCheck() void tst_QVariant::sequentialIterableAppend() { { - QVector<int> container {1, 2}; + QList<int> container { 1, 2 }; auto variant = QVariant::fromValue(container); QVERIFY(variant.canConvert<QtMetaTypePrivate::QSequentialIterableImpl>()); auto asIterable = variant.value<QtMetaTypePrivate::QSequentialIterableImpl>(); const int i = 3, j = 4; asIterable.append(&i); asIterable.append(&j); - QCOMPARE(variant.value<QVector<int>>(), QVector<int> ({1, 2, 3, 4})); + QCOMPARE(variant.value<QList<int>>(), QList<int> ({ 1, 2, 3, 4 })); } { QSet<QByteArray> container { QByteArray{"hello"}, QByteArray{"world"} }; diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index ac8aaa1327..cd9268d736 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -27,10 +27,10 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <qwineventnotifier.h> +#include <qlist.h> #include <qtimer.h> #include <qvarlengtharray.h> -#include <qvector.h> +#include <qwineventnotifier.h> #include <qt_windows.h> #include <algorithm> @@ -208,7 +208,7 @@ void tst_QWinEventNotifier::manyNotifiers() })); } -using Indices = QVector<int>; +using Indices = QList<int>; void tst_QWinEventNotifier::disableNotifiersInActivatedSlot_data() { |