Use QList instead of QVector in corelib tests

Task-number: QTBUG-84469
Change-Id: Ic80fde5517aed363f17d0da55cadcc958c3c8895
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Jarek Kobus 2020-07-06 16:15:23 +02:00
parent d33655a953
commit 989fca660c
50 changed files with 375 additions and 426 deletions

View File

@ -508,7 +508,7 @@ public:
void setOle(int v) { o = v; values << v; }
int o;
QVector<int> values;
QList<int> values;
};
void tst_QPropertyAnimation::noStartValue()

View File

@ -563,7 +563,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
}
typedef QVector<QAbstractAnimation::State> StateList;
using StateList = QList<QAbstractAnimation::State>;
static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates)
{

View File

@ -93,7 +93,7 @@ void tst_QGlobal::qIsNull()
void tst_QGlobal::for_each()
{
QVector<int> list;
QList<int> list;
list << 0 << 1 << 2 << 3 << 4 << 5;
int counter = 0;
@ -112,7 +112,7 @@ void tst_QGlobal::for_each()
// check whether we can pass a constructor as container argument
counter = 0;
foreach (int i, QVector<int>(list)) {
foreach (int i, QList<int>(list)) {
QCOMPARE(i, counter++);
}
QCOMPARE(counter, list.count());

View File

@ -81,7 +81,7 @@ void tst_QHooks::testAddRemoveObject()
QCOMPARE(objectCount, 0);
}
static QVector<QString> hookOrder;
static QList<QString> hookOrder;
static QHooks::AddQObjectCallback existingAddHook = 0;
static QHooks::RemoveQObjectCallback existingRemoveHook = 0;

View File

@ -27,9 +27,9 @@
****************************************************************************/
#include <QtTest>
#include <qlist.h>
#include <qobject.h>
#include <qrandom.h>
#include <qvector.h>
#include <private/qrandom_p.h>
#include <algorithm>
@ -621,7 +621,7 @@ void tst_QRandomGenerator::boundedQuality()
{
// test the quality of the generator
QVector<quint32> buffer(BufferCount, 0xcdcdcdcd);
QList<quint32> buffer(BufferCount, 0xcdcdcdcd);
generate(buffer.begin(), buffer.end(), [&] { return rng.bounded(Bound); });
for (quint32 value : qAsConst(buffer)) {

View File

@ -127,7 +127,7 @@ private:
QFile largeFile;
QVector<QByteArray> generatedBlocks;
QByteArrayList generatedBlocks;
int fd_;
FILE *stream_;

View File

@ -886,14 +886,14 @@ void tst_QDir::entryListWithTestFiles()
#if defined(Q_OS_WIN)
// ### Sadly, this is a platform difference right now.
// Note we are using capital L in entryList on one side here, to test case-insensitivity
const QVector<QPair<QString, QString> > symLinks =
const QList<QPair<QString, QString> > symLinks =
{
{m_dataPath + "/entryList/file", entrylistPath + "linktofile.lnk"},
{m_dataPath + "/entryList/directory", entrylistPath + "linktodirectory.lnk"},
{m_dataPath + "/entryList/nothing", entrylistPath + "brokenlink.lnk"}
};
#else
const QVector<QPair<QString, QString> > symLinks =
const QList<QPair<QString, QString> > symLinks =
{
{"file", entrylistPath + "linktofile.lnk"},
{"directory", entrylistPath + "linktodirectory.lnk"},

View File

@ -1231,7 +1231,7 @@ void tst_QProcess::processesInMultipleThreads()
if (i > 7)
threadCount = qMax(threadCount, QThread::idealThreadCount() + 2);
QVector<TestThread *> threads(threadCount);
QList<TestThread *> threads(threadCount);
for (int j = 0; j < threadCount; ++j)
threads[j] = new TestThread;
for (int j = 0; j < threadCount; ++j)

View File

@ -4048,7 +4048,7 @@ public:
for (int i = 0 ; i < m_urls.size(); ++i)
m_urls[i] = QUrl::fromEncoded("http://www.kde.org", QUrl::StrictMode);
}
QVector<QUrl> m_urls;
QList<QUrl> m_urls;
};
static const UrlStorage * s_urlStorage = nullptr;

View File

@ -122,7 +122,7 @@ class QtTestModel: public QAbstractItemModel
{
public:
QtTestModel(int rows, int columns, QObject *parent = 0);
QtTestModel(const QVector<QVector<QString> > tbl, QObject *parent = 0);
QtTestModel(const QList<QList<QString> > tbl, QObject *parent = 0);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &) const;
int rowCount(const QModelIndex &parent) const;
@ -146,7 +146,7 @@ public:
int cCount, rCount;
mutable bool wrongIndex;
QVector<QVector<QString> > table;
QList<QList<QString> > table;
};
Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint);
@ -163,7 +163,7 @@ QtTestModel::QtTestModel(int rows, int columns, QObject *parent)
}
}
QtTestModel::QtTestModel(const QVector<QVector<QString> > tbl, QObject *parent)
QtTestModel::QtTestModel(const QList<QList<QString> > tbl, QObject *parent)
: QAbstractItemModel(parent), wrongIndex(false)
{
table = tbl;
@ -201,7 +201,7 @@ bool QtTestModel::insertRows(int row, int count, const QModelIndex &parent)
{
QAbstractItemModel::beginInsertRows(parent, row, row + count - 1);
int cc = columnCount(parent);
table.insert(row, count, QVector<QString>(cc));
table.insert(row, count, QList<QString>(cc));
rCount = table.count();
QAbstractItemModel::endInsertRows();
return true;
@ -256,7 +256,7 @@ bool QtTestModel::moveRows(const QModelIndex &sourceParent, int src, int cnt,
destinationParent, dst))
return false;
QVector<QString> buf;
QList<QString> buf;
if (dst < src) {
for (int i = 0; i < cnt; ++i) {
buf.swap(table[src + i]);
@ -489,9 +489,9 @@ void tst_QAbstractItemModel::match()
}
typedef QPair<int, int> Position;
typedef QVector<QPair<int, int> > Selection;
typedef QVector<QVector<QString> > StringTable;
typedef QVector<QString> StringTableRow;
typedef QList<QPair<int, int> > Selection;
typedef QList<QList<QString> > StringTable;
typedef QList<QString> StringTableRow;
static StringTableRow qStringTableRow(const QString &s1, const QString &s2, const QString &s3)
{
@ -1940,8 +1940,8 @@ public:
const QModelIndex bottom = index(2, 0);
emit dataChanged(top, bottom);
emit dataChanged(top, bottom, QVector<int>() << Qt::ToolTipRole);
emit dataChanged(top, bottom, QVector<int>() << Qt::ToolTipRole << Custom1);
emit dataChanged(top, bottom, QList<int>() << Qt::ToolTipRole);
emit dataChanged(top, bottom, QList<int>() << Qt::ToolTipRole << Custom1);
}
};
@ -1963,8 +1963,8 @@ void tst_QAbstractItemModel::testDataChanged()
const QVariantList secondEmission = withRoles.at(1);
const QVariantList thirdEmission = withRoles.at(2);
const QVector<int> secondRoles = secondEmission.at(2).value<QVector<int> >();
const QVector<int> thirdRoles = thirdEmission.at(2).value<QVector<int> >();
const QList<int> secondRoles = secondEmission.at(2).value<QList<int> >();
const QList<int> thirdRoles = thirdEmission.at(2).value<QList<int> >();
QCOMPARE(secondRoles.size(), 1);
QVERIFY(secondRoles.contains(Qt::ToolTipRole));

View File

@ -50,7 +50,7 @@ public:
void changeData()
{
const QModelIndex idx = index(0, 0, QModelIndex());
Q_EMIT dataChanged(idx, idx, QVector<int>() << 1);
Q_EMIT dataChanged(idx, idx, QList<int>() << 1);
}
};
@ -94,7 +94,7 @@ tst_QIdentityProxyModel::tst_QIdentityProxyModel()
void tst_QIdentityProxyModel::initTestCase()
{
qRegisterMetaType<QVector<int> >();
qRegisterMetaType<QList<int> >();
m_model = new QStandardItemModel(0, 1);
m_proxy = new QIdentityProxyModel();
m_modelTest = new QAbstractItemModelTester(m_proxy, this);
@ -389,7 +389,7 @@ void tst_QIdentityProxyModel::dataChanged()
model.changeData();
QCOMPARE(modelSpy.first().at(2).value<QVector<int> >(), QVector<int>() << 1);
QCOMPARE(modelSpy.first().at(2).value<QList<int> >(), QList<int>() << 1);
QCOMPARE(modelSpy.first().at(2), proxySpy.first().at(2));
verifyIdentity(&model);

View File

@ -41,8 +41,8 @@
Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels")
using IntPair = QPair<int, int>;
using IntList = QVector<int>;
using IntPairList = QVector<IntPair>;
using IntList = QList<int>;
using IntPairList = QList<IntPair>;
// Testing get/set functions
void tst_QSortFilterProxyModel::getSetCheck()
@ -1462,8 +1462,8 @@ void tst_QSortFilterProxyModel::changeSourceLayout()
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
QVector<QPersistentModelIndex> persistentSourceIndexes;
QVector<QPersistentModelIndex> persistentProxyIndexes;
QList<QPersistentModelIndex> persistentSourceIndexes;
QList<QPersistentModelIndex> persistentProxyIndexes;
for (int row = 0; row < model.rowCount(); ++row) {
persistentSourceIndexes.append(model.index(row, 0));
persistentProxyIndexes.append(proxy.index(row, 0));
@ -2146,7 +2146,7 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
// QStringListModel doesn't distinguish between edit and display roles,
// so changing one always changes the other, too.
QVector<int> expectedChangedRoles;
QList<int> expectedChangedRoles;
expectedChangedRoles.append(Qt::DisplayRole);
expectedChangedRoles.append(Qt::EditRole);
@ -2154,13 +2154,13 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring"), Qt::DisplayRole);
QCOMPARE(spy.length(), 1);
QCOMPARE(spy.at(0).at(2).value<QVector<int> >(), expectedChangedRoles);
QCOMPARE(spy.at(0).at(2).value<QList<int> >(), expectedChangedRoles);
index = model.index(1, 0);
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring2"), Qt::EditRole);
QCOMPARE(spy.length(), 2);
QCOMPARE(spy.at(1).at(2).value<QVector<int> >(), expectedChangedRoles);
QCOMPARE(spy.at(1).at(2).value<QList<int> >(), expectedChangedRoles);
}
void tst_QSortFilterProxyModel::sortFilterRole()
@ -2170,12 +2170,12 @@ void tst_QSortFilterProxyModel::sortFilterRole()
proxy.setSourceModel(&model);
model.insertColumns(0, 1);
const QVector<QPair<QVariant, QVariant>>
const QList<QPair<QVariant, QVariant>>
sourceItems({QPair<QVariant, QVariant>("b", 3),
QPair<QVariant, QVariant>("c", 2),
QPair<QVariant, QVariant>("a", 1)});
const QVector<int> orderedItems({2, 1});
const QList<int> orderedItems({2, 1});
model.insertRows(0, sourceItems.count());
for (int i = 0; i < sourceItems.count(); ++i) {
@ -4947,7 +4947,7 @@ public:
return QVariant();
return m_data[index.row()][index.column()];
}
QVector<QVector<QVariant>> m_data;
QList<QList<QVariant>> m_data;
};
class SortFilterProxyModel final : public QSortFilterProxyModel

View File

@ -340,7 +340,7 @@ void tst_QStringListModel::setData_emits_both_roles()
QFETCH(int, role);
QStringListModel model(QStringList() << "one" << "two");
QVector<int> expected;
QList<int> expected;
expected.reserve(2);
expected.append(Qt::DisplayRole);
expected.append(Qt::EditRole);
@ -349,7 +349,7 @@ void tst_QStringListModel::setData_emits_both_roles()
QVERIFY(spy.isValid());
model.setData(model.index(row, 0), data, role);
QCOMPARE(spy.size(), 1);
QCOMPARE(sorted(spy.at(0).at(2).value<QVector<int> >()),
QCOMPARE(sorted(spy.at(0).at(2).value<QList<int> >()),
expected);
}
@ -380,7 +380,7 @@ void tst_QStringListModel::setItemData()
}};
QSignalSpy dataChangedSpy(&testModel, &QAbstractItemModel::dataChanged);
QModelIndex changeIndex = testModel.index(1, 0);
const QVector<int> changeRoles{Qt::DisplayRole, Qt::EditRole};
const QList<int> changeRoles{Qt::DisplayRole, Qt::EditRole};
const QString changedString("Changed");
QMap<int, QVariant> newItemData{std::make_pair<int>(Qt::DisplayRole, changedString)};
// invalid index does nothing and returns false
@ -393,7 +393,7 @@ void tst_QStringListModel::setItemData()
QVariantList dataChangedArguments = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex);
QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex);
QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles);
QCOMPARE(dataChangedArguments.at(2).value<QList<int> >(), changeRoles);
// Unsupported roles do nothing return false
newItemData.clear();
newItemData.insert(Qt::UserRole, changedString);
@ -418,7 +418,7 @@ void tst_QStringListModel::setItemData()
dataChangedArguments = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex);
QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex);
QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles);
QCOMPARE(dataChangedArguments.at(2).value<QList<int> >(), changeRoles);
}
void tst_QStringListModel::setData_emits_on_change_only()
@ -433,8 +433,8 @@ void tst_QStringListModel::setData_emits_on_change_only()
const QList<QVariant> spyList = dataChangedSpy.takeFirst();
QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
const QVector<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
QCOMPARE(spyList.at(2).value<QVector<int> >(), expectedRoles);
const QList<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
QCOMPARE(spyList.at(2).value<QList<int> >(), expectedRoles);
QVERIFY(model.setData(modelIdx, newStringData));
QVERIFY(dataChangedSpy.isEmpty());
}

View File

@ -769,15 +769,15 @@ void tst_QTransposeProxyModel::setItemData()
auto signalData = proxyDataChangeSpy.takeFirst();
QCOMPARE(signalData.at(0).value<QModelIndex>(), idx);
QCOMPARE(signalData.at(1).value<QModelIndex>(), idx);
const QVector<int> expectedRoles{Qt::DisplayRole, Qt::UserRole, Qt::EditRole, Qt::UserRole + 1};
QVector<int> receivedRoles = signalData.at(2).value<QVector<int> >();
const QList<int> expectedRoles{Qt::DisplayRole, Qt::UserRole, Qt::EditRole, Qt::UserRole + 1};
QList<int> receivedRoles = signalData.at(2).value<QList<int> >();
QCOMPARE(receivedRoles.size(), expectedRoles.size());
for (int role : expectedRoles)
QVERIFY(receivedRoles.contains(role));
signalData = sourceDataChangeSpy.takeFirst();
QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx));
QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx));
receivedRoles = signalData.at(2).value<QVector<int> >();
receivedRoles = signalData.at(2).value<QList<int> >();
QCOMPARE(receivedRoles.size(), expectedRoles.size());
for (int role : expectedRoles)
QVERIFY(receivedRoles.contains(role));
@ -793,14 +793,14 @@ void tst_QTransposeProxyModel::setItemData()
signalData = proxyDataChangeSpy.takeFirst();
QCOMPARE(signalData.at(0).value<QModelIndex>(), idx);
QCOMPARE(signalData.at(1).value<QModelIndex>(), idx);
receivedRoles = signalData.at(2).value<QVector<int> >();
receivedRoles = signalData.at(2).value<QList<int> >();
QCOMPARE(receivedRoles.size(), expectedRoles.size());
for (int role : expectedRoles)
QVERIFY(receivedRoles.contains(role));
signalData = sourceDataChangeSpy.takeFirst();
QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx));
QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx));
receivedRoles = signalData.at(2).value<QVector<int> >();
receivedRoles = signalData.at(2).value<QList<int> >();
QCOMPARE(receivedRoles.size(), expectedRoles.size());
for (int role : expectedRoles)
QVERIFY(receivedRoles.contains(role));

View File

@ -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));

View File

@ -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);

View File

@ -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)>()

View File

@ -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);
}

View File

@ -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) {

View File

@ -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};

View File

@ -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"} };

View File

@ -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()
{

View File

@ -388,7 +388,7 @@ public:
void tst_QUuid::threadUniqueness()
{
QVector<UuidThread *> threads(qMax(2, QThread::idealThreadCount()));
QList<UuidThread *> threads(qMax(2, QThread::idealThreadCount()));
for (int i = 0; i < threads.count(); ++i)
threads[i] = new UuidThread;
for (int i = 0; i < threads.count(); ++i)

View File

@ -2013,7 +2013,7 @@ void tst_QCborValue::validation_data()
// error. QCborValue internally uses 16 bytes per element, so we get to 2
// GB at 2^27 elements (32-bit) or, theoretically, 2^63 bytes at 2^59
// elements (64-bit).
if (sizeof(QVector<int>::size_type) == sizeof(int)) {
if (sizeof(QList<int>::size_type) == sizeof(int)) {
// 32-bit sizes (Qt 5 and 32-bit platforms)
QTest::addRow("very-large-array-no-overflow") << raw("\x9a\x07\xff\xff\xff" "\0\0") << 0 << CborErrorUnexpectedEOF;
QTest::addRow("very-large-array-overflow1") << raw("\x9a\x40\0\0\0" "\0\0") << 0 << CborErrorUnexpectedEOF;

View File

@ -3128,7 +3128,7 @@ void tst_QDataStream::status_QHash_QMap()
void tst_QDataStream::status_QList_QVector()
{
typedef QList<QString> List;
typedef QVector<QString> Vector;
typedef QList<QString> Vector;
List list;
Vector vector;
@ -3292,7 +3292,7 @@ void tst_QDataStream::streamRealDataTypes()
stream >> rect;
QCOMPARE(rect, QRectF(-1, -2, 3, 4));
stream >> polygon;
QCOMPARE((QVector<QPointF> &)polygon, (QPolygonF() << QPointF(0, 0) << QPointF(1, 2)));
QCOMPARE((QList<QPointF> &)polygon, (QPolygonF() << QPointF(0, 0) << QPointF(1, 2)));
auto matrix = transform.asAffineMatrix();
stream >> matrix;
QCOMPARE(transform, QTransform().rotate(90).scale(2, 2));

View File

@ -241,7 +241,7 @@ public:
class MissedBaseline
{
friend class QList<MissedBaseline>;
MissedBaseline() {} // for QVector, don't use
MissedBaseline() {} // for QList, don't use
public:
MissedBaseline(const QString &aId,
const QByteArray &aExpected,
@ -265,8 +265,8 @@ public:
QByteArray output;
};
QVector<GeneralFailure> failures;
QVector<MissedBaseline> missedBaselines;
QList<GeneralFailure> failures;
QList<MissedBaseline> missedBaselines;
/**
* The count of how many tests that were run.

View File

@ -272,7 +272,7 @@ public:
TestState(ChildMode mode, const QString &objectName = QString())
: QState(mode)
{ setObjectName(objectName); }
QVector<QPair<int, Event> > events;
QList<QPair<int, Event> > events;
protected:
virtual void onEntry(QEvent *) {
events.append(qMakePair(globalTick++, Entry));
@ -288,7 +288,7 @@ public:
TestTransition(QAbstractState *target, const QString &objectName = QString())
: QAbstractTransition()
{ setTargetState(target); setObjectName(objectName); }
QVector<int> triggers;
QList<int> triggers;
protected:
virtual bool eventTest(QEvent *) {
return true;
@ -4876,7 +4876,7 @@ public:
signalList.append(signal);
}
QVector<QMetaMethod> signalList;
QList<QMetaMethod> signalList;
};
void tst_QStateMachine::testIncrementReceivers()

View File

@ -167,7 +167,7 @@ bool operator!=(const Match &m, const QRegularExpressionMatch &rem)
}
bool operator==(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList)
bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList)
{
QRegularExpressionMatchIterator i = iterator;
@ -186,17 +186,17 @@ bool operator==(const QRegularExpressionMatchIterator &iterator, const QVector<M
return true;
}
bool operator==(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator)
bool operator==(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator)
{
return operator==(iterator, expectedMatchList);
}
bool operator!=(const QRegularExpressionMatchIterator &iterator, const QVector<Match> &expectedMatchList)
bool operator!=(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList)
{
return !operator==(iterator, expectedMatchList);
}
bool operator!=(const QVector<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator)
bool operator!=(const QList<Match> &expectedMatchList, const QRegularExpressionMatchIterator &iterator)
{
return !operator==(expectedMatchList, iterator);
}
@ -1150,9 +1150,9 @@ void tst_QRegularExpression::globalMatch_data()
QTest::addColumn<int>("offset");
QTest::addColumn<QRegularExpression::MatchType>("matchType");
QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions");
QTest::addColumn<QVector<Match> >("matchList");
QTest::addColumn<QList<Match> >("matchList");
QVector<Match> matchList;
QList<Match> matchList;
Match m;
matchList.clear();
@ -1408,7 +1408,7 @@ void tst_QRegularExpression::globalMatch()
QFETCH(int, offset);
QFETCH(QRegularExpression::MatchType, matchType);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(QVector<Match>, matchList);
QFETCH(QList<Match>, matchList);
testMatch<QRegularExpressionMatchIterator>(regexp,
static_cast<QREGlobalMatchStringPMF>(&QRegularExpression::globalMatch),
@ -2136,7 +2136,7 @@ void tst_QRegularExpression::threadSafety()
for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS && time.elapsed() < 2000; ++threadSafetyIteration) {
QRegularExpression re(pattern);
QVector<MatcherThread *> threads;
QList<MatcherThread *> threads;
for (int i = 0; i < threadCount; ++i) {
MatcherThread *thread = new MatcherThread(re, subject);
thread->start();

View File

@ -667,7 +667,7 @@ QString verifyZeroTermination(const QString &str)
} while (0) \
/**/
typedef QVector<int> IntList;
typedef QList<int> IntList;
tst_QString::tst_QString()
{
@ -4627,7 +4627,7 @@ void tst_QString::fromUcs4()
void tst_QString::toUcs4()
{
QString s;
QVector<uint> ucs4;
QList<uint> ucs4;
QCOMPARE( s.toUcs4().size(), 0 );
static const QChar bmp = QLatin1Char('a');
@ -5683,9 +5683,9 @@ template<> struct StringSplitWrapper<QString>
template<> struct StringSplitWrapper<QStringRef>
{
const QString &string;
QVector<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
QVector<QStringRef> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
QVector<QStringRef> split(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const { return string.splitRef(sep, behavior); }
QList<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
QList<QStringRef> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return string.splitRef(sep, behavior, cs); }
QList<QStringRef> split(const QRegularExpression &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const { return string.splitRef(sep, behavior); }
};
template<> struct StringSplitWrapper<QStringView>
@ -5710,20 +5710,14 @@ static bool operator==(const QList<QStringView> &result, const QStringList &expe
}
static bool operator ==(const QStringList &left, const QVector<QStringRef> &right)
static bool operator ==(const QStringList &left, const QList<QStringRef> &right)
{
if (left.size() != right.size())
return false;
QStringList::const_iterator iLeft = left.constBegin();
QVector<QStringRef>::const_iterator iRight = right.constBegin();
for (; iLeft != left.end(); ++iLeft, ++iRight) {
if (*iLeft != *iRight)
return false;
}
return true;
return std::equal(left.constBegin(), left.constEnd(), right.constBegin());
}
static inline bool operator ==(const QVector<QStringRef> &left, const QStringList &right) { return right == left; }
static inline bool operator ==(const QList<QStringRef> &left, const QStringList &right) { return right == left; }
template<class List>
void tst_QString::split(const QString &string, const QString &sep, QStringList result)
@ -5771,7 +5765,7 @@ void tst_QString::split()
QFETCH(QString, sep);
QFETCH(QStringList, result);
split<QStringList>(str, sep, result);
split<QVector<QStringView>>(str, sep, result);
split<QList<QStringView>>(str, sep, result);
}
void tst_QString::splitRef_data()
@ -5784,7 +5778,7 @@ void tst_QString::splitRef()
QFETCH(QString, str);
QFETCH(QString, sep);
QFETCH(QStringList, result);
split<QVector<QStringRef> >(str, sep, result);
split<QList<QStringRef> >(str, sep, result);
}
void tst_QString::split_regularexpression_data()
@ -5840,7 +5834,7 @@ void tst_QString::splitRef_regularexpression()
QFETCH(QString, string);
QFETCH(QString, pattern);
QFETCH(QStringList, result);
split_regexp<QVector<QStringRef>, QRegularExpression>(string, pattern, result);
split_regexp<QList<QStringRef>, QRegularExpression>(string, pattern, result);
}
void tst_QString::fromUtf16_data()

View File

@ -31,15 +31,14 @@
#undef QT_NO_CAST_TO_ASCII
#undef QT_ASCII_CAST_WARNINGS
#include <QString>
#include <QStringView>
#include <QStringTokenizer>
#include <QChar>
#include <QScopedArrayPointer>
#include <QStringRef>
#include <QLatin1String>
#include <QVector>
#include <QList>
#include <QScopedArrayPointer>
#include <QString>
#include <QStringRef>
#include <QStringTokenizer>
#include <QStringView>
#include <QTest>
Q_DECLARE_METATYPE(QLatin1String)
@ -2304,12 +2303,12 @@ void tst_QStringApiSymmetry::toUtf8_impl()
void tst_QStringApiSymmetry::toUcs4_data()
{
QTest::addColumn<QString>("unicode");
QTest::addColumn<QVector<uint>>("ucs4");
QTest::addColumn<QList<uint>>("ucs4");
auto add = [](const char *l1) {
const QByteArray ba(l1);
QString s;
QVector<uint> ucs4;
QList<uint> ucs4;
for (char c : ba) {
s += QLatin1Char(c);
ucs4.append(uint(uchar(c)));
@ -2317,8 +2316,8 @@ void tst_QStringApiSymmetry::toUcs4_data()
QTest::newRow(rowName(ba).constData()) << s << ucs4;
};
QTest::addRow("null") << QString() << QVector<uint>();
QTest::addRow("empty") << QString("") << QVector<uint>();
QTest::addRow("null") << QString() << QList<uint>();
QTest::addRow("empty") << QString("") << QList<uint>();
add("M\xF6" "bius");
add(LONG_STRING_256);
@ -2328,7 +2327,7 @@ template <typename String>
void tst_QStringApiSymmetry::toUcs4_impl()
{
QFETCH(const QString, unicode);
QFETCH(const QVector<uint>, ucs4);
QFETCH(const QList<uint>, ucs4);
const auto str = make<String>(unicode);

View File

@ -1839,7 +1839,7 @@ void tst_QStringConverter::threadSafety()
{
QThreadPool::globalInstance()->setMaxThreadCount(12);
QVector<QString> res;
QList<QString> res;
res.resize(QStringConverter::LastEncoding + 1);
for (int i = 0; i < QStringConverter::LastEncoding + 1; ++i) {
QThreadPool::globalInstance()->start(new LoadAndConvert(QStringConverter::Encoding(i), &res[i]));

View File

@ -27,9 +27,9 @@
****************************************************************************/
#include <QtTest/QtTest>
#include <qlist.h>
#include <qregularexpression.h>
#include <qstringlist.h>
#include <qvector.h>
#include <locale.h>
@ -88,7 +88,7 @@ void tst_QStringList::constructors()
QCOMPARE(list.at(2), "c");
}
{
const QVector<QString> reference{ "a", "b", "c" };
const QList<QString> reference{ "a", "b", "c" };
QCOMPARE(reference.size(), 3);
QStringList list(reference.cbegin(), reference.cend());

View File

@ -2081,20 +2081,14 @@ void tst_QStringRef::mid()
QVERIFY(emptyRef.mid(-10, 3).isEmpty());
}
static bool operator ==(const QStringList &left, const QVector<QStringRef> &right)
static bool operator ==(const QStringList &left, const QList<QStringRef> &right)
{
if (left.size() != right.size())
return false;
QStringList::const_iterator iLeft = left.constBegin();
QVector<QStringRef>::const_iterator iRight = right.constBegin();
for (; iLeft != left.end(); ++iLeft, ++iRight) {
if (*iLeft != *iRight)
return false;
}
return true;
return std::equal(left.constBegin(), left.constEnd(), right.constBegin());
}
static inline bool operator ==(const QVector<QStringRef> &left, const QStringList &right) { return right == left; }
static inline bool operator ==(const QList<QStringRef> &left, const QStringList &right) { return right == left; }
void tst_QStringRef::split_data()
{
@ -2124,7 +2118,7 @@ void tst_QStringRef::split()
QFETCH(QString, sep);
QFETCH(QStringList, result);
QVector<QStringRef> list;
QList<QStringRef> list;
// we construct a bigger valid string to check
// if ref.split is using the right size
QString source = str + str + str;

View File

@ -137,13 +137,13 @@ void tst_QStringTokenizer::toContainer() const
{
auto tok = qTokenize(u"a,b,c", u',');
auto v = tok.toContainer();
QVERIFY((std::is_same_v<decltype(v), QVector<QStringView>>));
QVERIFY((std::is_same_v<decltype(v), QList<QStringView>>));
}
// QLatin1String value_type
{
auto tok = qTokenize(QLatin1String{"a,b,c"}, u',');
auto v = tok.toContainer();
QVERIFY((std::is_same_v<decltype(v), QVector<QLatin1String>>));
QVERIFY((std::is_same_v<decltype(v), QList<QLatin1String>>));
}
}

View File

@ -32,7 +32,7 @@
#include <QChar>
#include <QStringRef>
#include <QVarLengthArray>
#include <QVector>
#include <QList>
#include <QTest>
@ -89,7 +89,7 @@ static_assert(CanConvert<ushort[123]>::value);
static_assert(CanConvert< ushort*>::value);
static_assert(CanConvert<const ushort*>::value);
static_assert(CanConvert<QVector<ushort>>::value);
static_assert(CanConvert<QList<ushort>>::value);
static_assert(CanConvert<QVarLengthArray<ushort>>::value);
static_assert(CanConvert<std::vector<ushort>>::value);
static_assert(CanConvert<std::array<ushort, 123>>::value);
@ -115,7 +115,7 @@ static_assert(CanConvert<const std::u16string_view >::value);
static_assert(CanConvert< std::u16string_view&>::value);
static_assert(CanConvert<const std::u16string_view&>::value);
static_assert(CanConvert<QVector<char16_t>>::value);
static_assert(CanConvert<QList<char16_t>>::value);
static_assert(CanConvert<QVarLengthArray<char16_t>>::value);
static_assert(CanConvert<std::vector<char16_t>>::value);
static_assert(CanConvert<std::array<char16_t, 123>>::value);
@ -149,7 +149,7 @@ static_assert(CanConvert<const std::wstring_view >::value == CanConvertFromWChar
static_assert(CanConvert< std::wstring_view&>::value == CanConvertFromWCharT);
static_assert(CanConvert<const std::wstring_view&>::value == CanConvertFromWCharT);
static_assert(CanConvert<QVector<wchar_t>>::value == CanConvertFromWCharT);
static_assert(CanConvert<QList<wchar_t>>::value == CanConvertFromWCharT);
static_assert(CanConvert<QVarLengthArray<wchar_t>>::value == CanConvertFromWCharT);
static_assert(CanConvert<std::vector<wchar_t>>::value == CanConvertFromWCharT);
static_assert(CanConvert<std::array<wchar_t, 123>>::value == CanConvertFromWCharT);
@ -732,7 +732,7 @@ void tst_QStringView::fromContainer() const
template <typename Char>
void tst_QStringView::fromContainers() const
{
fromContainer<Char, QVector<Char>>();
fromContainer<Char, QList<Char>>();
fromContainer<Char, QVarLengthArray<Char>>();
fromContainer<Char, std::vector<Char>>();
}

View File

@ -191,8 +191,8 @@ void tst_QFuture::resultStore()
QVERIFY(it == store.end());
}
QVector<int> vec0 = QVector<int>() << 2 << 3;
QVector<int> vec1 = QVector<int>() << 4 << 5;
QList<int> vec0 = QList<int>() << 2 << 3;
QList<int> vec1 = QList<int>() << 4 << 5;
{
ResultStoreInt store;
@ -1728,7 +1728,7 @@ void tst_QFuture::nonGlobalThreadPool()
const int numTasks = QThread::idealThreadCount();
QVector<QFuture<int> > futures;
QList<QFuture<int>> futures;
futures.reserve(numTasks);
for (int i = 0; i < numTasks; ++i)

View File

@ -194,7 +194,7 @@ void snippet_QPromise::suspendExample()
thread->wait();
QCOMPARE(future.resultCount(), 100);
QVector<int> expected(100);
QList<int> expected(100);
std::iota(expected.begin(), expected.end(), 0);
QCOMPARE(future.results(), expected);
}

View File

@ -57,8 +57,8 @@ private:
int int0;
int int1;
int int2;
QVector<int> vec0;
QVector<int> vec1;
QList<int> vec0;
QList<int> vec1;
};
void tst_QtConcurrentResultStore::init()
@ -66,8 +66,8 @@ void tst_QtConcurrentResultStore::init()
int0 = 0;
int1 = 1;
int2 = 2;
vec0 = QVector<int>() << 2 << 3;
vec1 = QVector<int>() << 4 << 5;
vec0 = QList<int> { 2, 3 };
vec1 = QList<int> { 4, 5 };
}
void tst_QtConcurrentResultStore::construction()

View File

@ -166,7 +166,7 @@ void tst_QSemaphore::multiRelease()
};
QSemaphore sem;
QVector<Thread *> threads;
QList<Thread *> threads;
threads.resize(4);
for (Thread *&t : threads)
@ -200,7 +200,7 @@ void tst_QSemaphore::multiAcquireRelease()
};
QSemaphore sem;
QVector<Thread *> threads;
QList<Thread *> threads;
threads.resize(4);
for (Thread *&t : threads)

View File

@ -883,7 +883,7 @@ void tst_QThread::adoptMultipleThreads()
#else
const int numThreads = 5;
#endif
QVector<NativeThreadWrapper*> nativeThreads;
QList<NativeThreadWrapper*> nativeThreads;
SignalRecorder recorder;
@ -915,7 +915,7 @@ void tst_QThread::adoptMultipleThreadsOverlap()
#else
const int numThreads = 5;
#endif
QVector<NativeThreadWrapper*> nativeThreads;
QList<NativeThreadWrapper*> nativeThreads;
SignalRecorder recorder;

View File

@ -42,7 +42,7 @@ static QSet<int> *setX;
static QStack<int> *stackX;
static QVarLengthArray<int> *varLengthArrayX;
static QVarLengthArray<int, 512> *varLengthArrayY;
static QVector<int> *vectorX;
static QList<int> *vectorX;
void foo()
{
@ -78,7 +78,6 @@ void foo()
#include "qstring.h"
#include "qstringlist.h"
#include "qvarlengtharray.h"
#include "qvector.h"
#include "qqueue.h"
class tst_Collections : public QObject
@ -470,7 +469,7 @@ void tst_Collections::list()
}
{
QVector<QString> vector(5);
QList<QString> vector(5);
vector[0] = "99";
vector[4] ="100";
QList<QString> list = vector.toList();
@ -726,7 +725,7 @@ void tst_Collections::list()
void tst_Collections::vector()
{
QVector<int> v1;
QList<int> v1;
v1 << 1 << 2 << 3;
QVector<int> v2;
v2 << 4 << 5;
@ -2495,13 +2494,12 @@ void testMapLikeStlIterators()
void tst_Collections::constAndNonConstStlIterators()
{
testListLikeStlIterators<QList<int> >();
testListLikeStlIterators<QStringList >();
testListLikeStlIterators<QVector<int> >();
testMapLikeStlIterators<QMap<QString, QString> >();
testMapLikeStlIterators<QMultiMap<QString, QString> >();
testMapLikeStlIterators<QHash<QString, QString> >();
testMapLikeStlIterators<QMultiHash<QString, QString> >();
testListLikeStlIterators<QList<int>>();
testListLikeStlIterators<QStringList>();
testMapLikeStlIterators<QMap<QString, QString>>();
testMapLikeStlIterators<QMultiMap<QString, QString>>();
testMapLikeStlIterators<QHash<QString, QString>>();
testMapLikeStlIterators<QMultiHash<QString, QString>>();
}
void tst_Collections::vector_stl_data()
@ -2518,7 +2516,7 @@ void tst_Collections::vector_stl()
{
QFETCH(QStringList, elements);
QVector<QString> vector;
QList<QString> vector;
for (int i = 0; i < elements.count(); ++i)
vector << elements.at(i);
@ -2534,9 +2532,9 @@ void tst_Collections::vector_stl()
QCOMPARE(*it, vector[j]);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
QCOMPARE(QVector<QString>::fromStdVector(stdVector), vector);
QCOMPARE(QList<QString>::fromStdVector(stdVector), vector);
#endif
QCOMPARE(QVector<QString>(stdVector.begin(), stdVector.end()), vector);
QCOMPARE(QList<QString>(stdVector.begin(), stdVector.end()), vector);
}
void tst_Collections::list_stl_data()
@ -2789,10 +2787,6 @@ void tst_Collections::containerInstantiation()
list.removeAll(value);
}
//Instantiate QVector member functions.
typedef QVector<EqualsComparable> Vector;
instantiateRandomAccess<Vector, EqualsComparable>();
//Instantiate QQueue member functions.
typedef QQueue<EqualsComparable> Queue;
instantiateRandomAccess<Queue, EqualsComparable>();
@ -2883,7 +2877,6 @@ void testSetContainerTypedefs(Container container)
*/
void tst_Collections::containerTypedefs()
{
testContainerTypedefs(QVector<int>());
testContainerTypedefs(QStack<int>());
testContainerTypedefs(QList<int>());
testContainerTypedefs(QQueue<int>());
@ -3032,18 +3025,18 @@ void testAssociativeContainerAlignment()
void tst_Collections::alignment()
{
testVectorAlignment<QVector<Aligned4> >();
testVectorAlignment<QVector<AlignedBiggest> >();
testContiguousCacheAlignment<QContiguousCache<Aligned4> >();
testContiguousCacheAlignment<QContiguousCache<AlignedBiggest> >();
testAssociativeContainerAlignment<QMap<Aligned4, Aligned4> >();
testAssociativeContainerAlignment<QMap<Aligned4, AlignedBiggest> >();
testAssociativeContainerAlignment<QMap<AlignedBiggest, Aligned4> >();
testAssociativeContainerAlignment<QMap<AlignedBiggest, AlignedBiggest> >();
testAssociativeContainerAlignment<QHash<Aligned4, Aligned4> >();
testAssociativeContainerAlignment<QHash<Aligned4, AlignedBiggest> >();
testAssociativeContainerAlignment<QHash<AlignedBiggest, Aligned4> >();
testAssociativeContainerAlignment<QHash<AlignedBiggest, AlignedBiggest> >();
testVectorAlignment<QList<Aligned4>>();
testVectorAlignment<QList<AlignedBiggest>>();
testContiguousCacheAlignment<QContiguousCache<Aligned4>>();
testContiguousCacheAlignment<QContiguousCache<AlignedBiggest>>();
testAssociativeContainerAlignment<QMap<Aligned4, Aligned4>>();
testAssociativeContainerAlignment<QMap<Aligned4, AlignedBiggest>>();
testAssociativeContainerAlignment<QMap<AlignedBiggest, Aligned4>>();
testAssociativeContainerAlignment<QMap<AlignedBiggest, AlignedBiggest>>();
testAssociativeContainerAlignment<QHash<Aligned4, Aligned4>>();
testAssociativeContainerAlignment<QHash<Aligned4, AlignedBiggest>>();
testAssociativeContainerAlignment<QHash<AlignedBiggest, Aligned4>>();
testAssociativeContainerAlignment<QHash<AlignedBiggest, AlignedBiggest>>();
}
#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
@ -3327,25 +3320,25 @@ using ExtList = QList<T>;
void tst_Collections::insert_remove_loop()
{
insert_remove_loop_impl<ExtList<int> >();
insert_remove_loop_impl<ExtList<QString> >();
insert_remove_loop_impl<QVector<int> >();
insert_remove_loop_impl<QVector<QString> >();
insert_remove_loop_impl<QVarLengthArray<int> >();
insert_remove_loop_impl<QVarLengthArray<QString> >();
insert_remove_loop_impl<QVarLengthArray<int, 10> >();
insert_remove_loop_impl<QVarLengthArray<QString, 10> >();
insert_remove_loop_impl<QVarLengthArray<int, 3> >();
insert_remove_loop_impl<QVarLengthArray<QString, 3> >();
insert_remove_loop_impl<QVarLengthArray<int, 15> >();
insert_remove_loop_impl<QVarLengthArray<QString, 15> >();
insert_remove_loop_impl<ExtList<int>>();
insert_remove_loop_impl<ExtList<QString>>();
insert_remove_loop_impl<QList<int>>();
insert_remove_loop_impl<QList<QString>>();
insert_remove_loop_impl<QVarLengthArray<int>>();
insert_remove_loop_impl<QVarLengthArray<QString>>();
insert_remove_loop_impl<QVarLengthArray<int, 10>>();
insert_remove_loop_impl<QVarLengthArray<QString, 10>>();
insert_remove_loop_impl<QVarLengthArray<int, 3>>();
insert_remove_loop_impl<QVarLengthArray<QString, 3>>();
insert_remove_loop_impl<QVarLengthArray<int, 15>>();
insert_remove_loop_impl<QVarLengthArray<QString, 15>>();
insert_remove_loop_impl<ExtList<std::string> >();
insert_remove_loop_impl<QVector<std::string> >();
insert_remove_loop_impl<QVarLengthArray<std::string> >();
insert_remove_loop_impl<QVarLengthArray<std::string, 10> >();
insert_remove_loop_impl<QVarLengthArray<std::string, 3> >();
insert_remove_loop_impl<QVarLengthArray<std::string, 15> >();
insert_remove_loop_impl<ExtList<std::string>>();
insert_remove_loop_impl<QList<std::string>>();
insert_remove_loop_impl<QVarLengthArray<std::string>>();
insert_remove_loop_impl<QVarLengthArray<std::string, 10>>();
insert_remove_loop_impl<QVarLengthArray<std::string, 3>>();
insert_remove_loop_impl<QVarLengthArray<std::string, 15>>();
}

View File

@ -29,12 +29,11 @@
#include <QtTest/QtTest>
#include "qbytearray.h"
#include "qdebug.h"
#include "qhash.h"
#include "qlist.h"
#include "qstring.h"
#include "qvarlengtharray.h"
#include "qvector.h"
#include "qhash.h"
#include "qdebug.h"
#include <algorithm>
#include <functional>
@ -269,19 +268,14 @@ private Q_SLOTS:
void ranged_ctor_std_vector_Complex() { ranged_ctor_non_associative_impl<std::vector<Complex>>(); }
void ranged_ctor_std_vector_duplicates_strategy() { non_associative_container_duplicates_strategy<std::vector>(); }
void ranged_ctor_QVector_int() { ranged_ctor_non_associative_impl<QVector<int>>(); }
void ranged_ctor_QVector_char() { ranged_ctor_non_associative_impl<QVector<char>>(); }
void ranged_ctor_QVector_QChar() { ranged_ctor_non_associative_impl<QVector<QChar>>(); }
void ranged_ctor_QVector_Movable() { ranged_ctor_non_associative_impl<QVector<Movable>>(); }
void ranged_ctor_QVector_Complex() { ranged_ctor_non_associative_impl<QVector<Complex>>(); }
void ranged_ctor_QVector_duplicates_strategy() { non_associative_container_duplicates_strategy<QVector>(); }
void ranged_ctor_QVarLengthArray_int() { ranged_ctor_non_associative_impl<QVarLengthArray<int>>(); }
void ranged_ctor_QVarLengthArray_Movable() { ranged_ctor_non_associative_impl<QVarLengthArray<Movable>>(); }
void ranged_ctor_QVarLengthArray_Complex() { ranged_ctor_non_associative_impl<QVarLengthArray<Complex>>(); }
void ranged_ctor_QVarLengthArray_duplicates_strategy() { non_associative_container_duplicates_strategy<VarLengthArray>(); } // note the VarLengthArray passed
void ranged_ctor_QList_int() { ranged_ctor_non_associative_impl<QList<int>>(); }
void ranged_ctor_QList_char() { ranged_ctor_non_associative_impl<QList<char>>(); }
void ranged_ctor_QList_QChar() { ranged_ctor_non_associative_impl<QList<QChar>>(); }
void ranged_ctor_QList_Movable() { ranged_ctor_non_associative_impl<QList<Movable>>(); }
void ranged_ctor_QList_Complex() { ranged_ctor_non_associative_impl<QList<Complex>>(); }
void ranged_ctor_QList_duplicates_strategy() { non_associative_container_duplicates_strategy<QList>(); }
@ -474,7 +468,6 @@ private:
private Q_SLOTS:
void front_back_std_vector() { front_back_impl<std::vector<int>>(); }
void front_back_QVector() { front_back_impl<QVector<int>>(); }
void front_back_QList() { front_back_impl<QList<qintptr>>(); }
void front_back_QVarLengthArray() { front_back_impl<QVarLengthArray<int>>(); }
void front_back_QString() { front_back_impl<QString>(); }

View File

@ -35,10 +35,10 @@
#include <iterator>
#include <algorithm>
#include <qalgorithms.h>
#include <QStringList>
#include <QString>
#include <QList>
#include <QRandomGenerator>
#include <QVector>
#include <QString>
#include <QStringList>
#define Q_TEST_PERFORMANCE 0
@ -137,9 +137,9 @@ QStringList dataSetTypes = QStringList() << "Random" << "Ascending"
<< "Descending" << "Equal" << "Duplicates" << "Almost Sorted" ;
template <typename DataType>
QVector<DataType> generateData(QString dataSetType, const int length)
QList<DataType> generateData(QString dataSetType, const int length)
{
QVector<DataType> container;
QList<DataType> container;
if (dataSetType == "Random") {
for (int i = 0; i < length; ++i)
container.append(QRandomGenerator::global()->generate());
@ -236,7 +236,7 @@ QList<ResultSet> testAlgorithm(Algorithm &algorithm, QStringList dataSetTypes,
{
QList<ResultSet> results;
foreach(QString dataSetType, dataSetTypes) {
QVector<DataType> container = generateData<DataType>(dataSetType, size);
QList<DataType> container = generateData<DataType>(dataSetType, size);
results.append(testRun(container, algorithm, time));
if (!isSorted(container))
qWarning("%s: container is not sorted after test", Q_FUNC_INFO);
@ -534,22 +534,6 @@ void tst_QAlgorithms::qBinaryFindOneEntry()
void tst_QAlgorithms::sortAPItest()
{
QVector<int> testVector = generateData<int>("Random", 101);
qSort(testVector);
QVERIFY(isSorted(testVector));
qSort(testVector.begin(), testVector.end());
QVERIFY(isSorted(testVector));
qSort(testVector.begin(), testVector.end(), qLess<int>());
QVERIFY(isSorted(testVector));
testVector = generateData<int>("Random", 71);
qStableSort(testVector);
QVERIFY(isSorted(testVector));
qStableSort(testVector.begin(), testVector.end());
QVERIFY(isSorted(testVector));
qStableSort(testVector.begin(), testVector.end(), qLess<int>());
QVERIFY(isSorted(testVector));
QList<int> testList = generateData<int>("Random", 101).toList();
qSort(testList);
QVERIFY(isSorted(testList));
@ -582,15 +566,14 @@ int Minor;
ostream &operator<<(ostream &out, const StableSortTest& obj) { out << obj.Major << "-" << obj.Minor; return out; }
QVector<StableSortTest> createStableTestVector()
QList<StableSortTest> createStableTestList()
{
QVector<StableSortTest> stableTestVector;
for (int i=500; i>=0; --i) {
for (int j=0; j<10; ++j) {
stableTestVector.append(StableSortTest(i, j));
}
QList<StableSortTest> stableTestList;
for (int i = 500; i >= 0; --i) {
for (int j = 0; j < 10; ++j)
stableTestList.append(StableSortTest(i, j));
}
return stableTestVector;
return stableTestList;
}
template <typename ContainerType, typename LessThan>
@ -614,52 +597,52 @@ void tst_QAlgorithms::stableSortTest()
{
// Selftests:
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
qSort(stableTestVector.begin(), stableTestVector.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qLess<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestVector, qLess<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
qSort(stableTestList.begin(), stableTestList.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestList, qLess<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestList, qLess<StableSortTest>()));
}
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
qSort(stableTestVector.begin(), stableTestVector.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qGreater<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestVector, qGreater<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
qSort(stableTestList.begin(), stableTestList.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestList, qGreater<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestList, qGreater<StableSortTest>()));
}
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
qSort(stableTestVector.begin(), stableTestVector.end(), qGreater<StableSortTest>());
QVERIFY(!isSorted(stableTestVector, qLess<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestVector, qGreater<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
qSort(stableTestList.begin(), stableTestList.end(), qGreater<StableSortTest>());
QVERIFY(!isSorted(stableTestList, qLess<StableSortTest>()));
QVERIFY(!isStableSorted(stableTestList, qGreater<StableSortTest>()));
}
// Stable sort with qLess
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
std::stable_sort(stableTestVector.begin(), stableTestVector.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qLess<StableSortTest>()));
QVERIFY(isStableSorted(stableTestVector, qLess<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
std::stable_sort(stableTestList.begin(), stableTestList.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestList, qLess<StableSortTest>()));
QVERIFY(isStableSorted(stableTestList, qLess<StableSortTest>()));
}
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
qStableSort(stableTestVector.begin(), stableTestVector.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qLess<StableSortTest>()));
QVERIFY(isStableSorted(stableTestVector, qLess<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
qStableSort(stableTestList.begin(), stableTestList.end(), qLess<StableSortTest>());
QVERIFY(isSorted(stableTestList, qLess<StableSortTest>()));
QVERIFY(isStableSorted(stableTestList, qLess<StableSortTest>()));
}
// Stable sort with qGreater
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
std::stable_sort(stableTestVector.begin(), stableTestVector.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qGreater<StableSortTest>()));
QVERIFY(isStableSorted(stableTestVector, qGreater<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
std::stable_sort(stableTestList.begin(), stableTestList.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestList, qGreater<StableSortTest>()));
QVERIFY(isStableSorted(stableTestList, qGreater<StableSortTest>()));
}
{
QVector<StableSortTest> stableTestVector = createStableTestVector();
qStableSort(stableTestVector.begin(), stableTestVector.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestVector, qGreater<StableSortTest>()));
QVERIFY(isStableSorted(stableTestVector, qGreater<StableSortTest>()));
QList<StableSortTest> stableTestList = createStableTestList();
qStableSort(stableTestList.begin(), stableTestList.end(), qGreater<StableSortTest>());
QVERIFY(isSorted(stableTestList, qGreater<StableSortTest>()));
QVERIFY(isStableSorted(stableTestList, qGreater<StableSortTest>()));
}
}
@ -667,8 +650,8 @@ void tst_QAlgorithms::stableSortTest()
void tst_QAlgorithms::stableSortCorrectnessTest_data()
{
const int dataSize = 1000;
QTest::addColumn<QVector<int> >("unsorted");
QTest::newRow("From documentation") << (QVector<int>() << 33 << 12 << 68 << 6 << 12);
QTest::addColumn<QList<int>>("unsorted");
QTest::newRow("From documentation") << (QList<int>() << 33 << 12 << 68 << 6 << 12);
QTest::newRow("Equal") << (generateData<int>("Equal", dataSize));
QTest::newRow("Ascending") << (generateData<int>("Ascending", dataSize));
QTest::newRow("Descending") << (generateData<int>("Descending", dataSize));
@ -679,9 +662,9 @@ void tst_QAlgorithms::stableSortCorrectnessTest_data()
void tst_QAlgorithms::stableSortCorrectnessTest()
{
QFETCH(QVector<int>, unsorted);
QFETCH(QList<int>, unsorted);
QVector<int> sorted = unsorted;
QList<int> sorted = unsorted;
qStableSort(sorted.begin(), sorted.end());
// Verify that sorted contains the same numbers as unsorted.
@ -743,7 +726,7 @@ template <typename DataType>
class QuickSortHelper
{
public:
void operator()(QVector<DataType> list)
void operator()(QList<DataType> list)
{
::qSort(list);
}
@ -753,7 +736,7 @@ template <typename DataType>
class StableSortHelper
{
public:
void operator()(QVector<DataType> list)
void operator()(QList<DataType> list)
{
::qStableSort(list);
}
@ -763,7 +746,7 @@ template <typename DataType>
class StlSortHelper
{
public:
void operator()(QVector<DataType> list)
void operator()(QList<DataType> list)
{
std::sort(list.begin(), list.end());
}
@ -773,7 +756,7 @@ template <typename DataType>
class StlStableSortHelper
{
public:
void operator()(QVector<DataType> list)
void operator()(QList<DataType> list)
{
std::stable_sort(list.begin(), list.end());
}

View File

@ -417,7 +417,7 @@ struct Deallocator
size_t objectSize;
size_t alignment;
QVector<QArrayData *> headers;
QList<QArrayData *> headers;
};
Q_DECLARE_METATYPE(const QArrayData *)
@ -652,7 +652,7 @@ void tst_QArrayData::gccBug43247()
{
// This test tries to verify QArrayData is not affected by GCC optimizer
// bug #43247.
// Reported on GCC 4.4.3, Linux, affects QVector
// Reported on GCC 4.4.3, Linux, affects QList
QTest::ignoreMessage(QtDebugMsg, "GCC Optimization bug #43247 not triggered (3)");
QTest::ignoreMessage(QtDebugMsg, "GCC Optimization bug #43247 not triggered (4)");
@ -661,7 +661,7 @@ void tst_QArrayData::gccBug43247()
QTest::ignoreMessage(QtDebugMsg, "GCC Optimization bug #43247 not triggered (7)");
SimpleVector<int> array(10, 0);
// QVector<int> vector(10, 0);
// QList<int> list(10, 0);
for (int i = 0; i < 10; ++i) {
if (i >= 3 && i < 8)
@ -671,7 +671,7 @@ void tst_QArrayData::gccBug43247()
// line lets the compiler assume i == 0, and the conditional above is
// skipped.
QVERIFY(array.at(i) == 0);
// QVERIFY(vector.at(i) == 0);
// QVERIFY(list.at(i) == 0);
}
}
@ -1141,18 +1141,18 @@ void tst_QArrayData::literals()
}
{
QVector<char> v(Q_ARRAY_LITERAL(char, "ABCDEFGHIJ"));
QCOMPARE(v.size(), 11);
QCOMPARE(v.capacity(), 0);
QList<char> l(Q_ARRAY_LITERAL(char, "ABCDEFGHIJ"));
QCOMPARE(l.size(), 11);
QCOMPARE(l.capacity(), 0);
for (int i = 0; i < 10; ++i)
QCOMPARE(v.at(i), char('A' + i));
QCOMPARE(l.at(i), char('A' + i));
(void)v.begin(); // "detach"
(void)l.begin(); // "detach"
QCOMPARE(v.size(), 11);
QVERIFY(v.capacity() >= v.size());
QCOMPARE(l.size(), 11);
QVERIFY(l.capacity() >= l.size());
for (int i = 0; i < 10; ++i)
QCOMPARE(v[i], char('A' + i));
QCOMPARE(l[i], char('A' + i));
}
{
@ -1176,18 +1176,18 @@ void tst_QArrayData::literals()
}
{
QVector<LiteralType> v(Q_ARRAY_LITERAL(LiteralType, LiteralType(0), LiteralType(1), LiteralType(2)));
QCOMPARE(v.size(), 3);
QCOMPARE(v.capacity(), 0);
QList<LiteralType> l(Q_ARRAY_LITERAL(LiteralType, LiteralType(0), LiteralType(1), LiteralType(2)));
QCOMPARE(l.size(), 3);
QCOMPARE(l.capacity(), 0);
for (int i = 0; i < 3; ++i)
QCOMPARE(v.at(i).value, i);
QCOMPARE(l.at(i).value, i);
(void)v.begin(); // "detach"
(void)l.begin(); // "detach"
QCOMPARE(v.size(), 3);
QVERIFY(v.capacity() >= v.size());
QCOMPARE(l.size(), 3);
QVERIFY(l.capacity() >= l.size());
for (int i = 0; i < 3; ++i)
QCOMPARE(v[i].value, i);
QCOMPARE(l[i].value, i);
}
}

View File

@ -602,7 +602,7 @@ static inline void setupBezierSpline(QEasingCurve *easingCurve, const QString &s
{
QStringList pointStr = string.split(QLatin1Char(' '));
QVector<QPointF> points;
QList<QPointF> points;
foreach (const QString &str, pointStr) {
QStringList coordStr = str.split(QLatin1Char(','));
QPointF point(coordStr.first().toDouble(), coordStr.last().toDouble());

View File

@ -33,7 +33,6 @@
#include <qstring.h>
#include <qstringview.h>
#include <qvarlengtharray.h>
#include <qvector.h>
#include <algorithm>
#include <list>

View File

@ -2826,7 +2826,7 @@ void tst_QList::emplaceConsistentWithStdVectorImpl() const
vecEq(qVec, stdVec);
T t;
// while QVector is safe with regards to emplacing elements moved form itself, it's UB
// while QList is safe with regards to emplacing elements moved form itself, it's UB
// for std::vector, so do the moving in two steps there.
qVec.emplaceBack(std::move(qVec[0]));
stdVec.emplace_back(std::move(t = std::move(stdVec[0])));

View File

@ -29,7 +29,7 @@
#include <QtTest/QtTest>
#include <private/qringbuffer_p.h>
#include <qvector.h>
#include <qlist.h>
class tst_QRingBuffer : public QObject
{
@ -82,7 +82,7 @@ void tst_QRingBuffer::constructing()
void tst_QRingBuffer::usingInVector()
{
QRingBuffer ringBuffer;
QVector<QRingBuffer> buffers;
QList<QRingBuffer> buffers;
ringBuffer.reserve(5);
buffers.append(ringBuffer);

View File

@ -31,9 +31,9 @@
#include "qsharedpointer.h"
#include <QtTest/QtTest>
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QThread>
#include <QtCore/QVector>
#include "externaltests.h"
#include "forwarddeclared.h"
@ -2114,7 +2114,7 @@ void tst_QSharedPointer::threadStressTest()
memset(guard2, 0, sizeof guard2);
for (int r = 0; r < 5; ++r) {
QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0);
QList<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0);
QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter));
counter.storeRelaxed(0);

View File

@ -89,56 +89,56 @@ private slots:
void tst_QVersionNumber::singleInstanceData()
{
QTest::addColumn<QVector<int> >("segments");
QTest::addColumn<QList<int>>("segments");
QTest::addColumn<QVersionNumber>("expectedVersion");
QTest::addColumn<QString>("expectedString");
QTest::addColumn<QString>("constructionString");
QTest::addColumn<int>("suffixIndex");
QTest::addColumn<bool>("isNull");
// segments expectedVersion expectedString constructionString suffixIndex null
QTest::newRow("null") << QVector<int>() << QVersionNumber(QVector<int>()) << QString() << QString() << 0 << true;
QTest::newRow("text") << QVector<int>() << QVersionNumber(QVector<int>()) << QString() << QStringLiteral("text") << 0 << true;
QTest::newRow(" text") << QVector<int>() << QVersionNumber(QVector<int>()) << QString() << QStringLiteral(" text") << 0 << true;
QTest::newRow("Empty String") << QVector<int>() << QVersionNumber(QVector<int>()) << QString() << QStringLiteral("Empty String") << 0 << true;
QTest::newRow("-1.-2") << (QVector<int>()) << QVersionNumber() << QStringLiteral("") << QStringLiteral("-1.-2") << 0 << true;
QTest::newRow("1.-2-3") << (QVector<int>() << 1) << QVersionNumber(QVector<int>() << 1) << QStringLiteral("1") << QStringLiteral("1.-2-3") << 1 << false;
QTest::newRow("1.2-3") << (QVector<int>() << 1 << 2) << QVersionNumber(QVector<int>() << 1 << 2) << QStringLiteral("1.2") << QStringLiteral("1.2-3") << 3 << false;
QTest::newRow("0") << (QVector<int>() << 0) << QVersionNumber(QVector<int>() << 0) << QStringLiteral("0") << QStringLiteral("0") << 1 << false;
QTest::newRow("0.1") << (QVector<int>() << 0 << 1) << QVersionNumber(QVector<int>() << 0 << 1) << QStringLiteral("0.1") << QStringLiteral("0.1") << 3 << false;
QTest::newRow("0.1.2") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2") << 5 << false;
QTest::newRow("0.1.2alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2alpha") << 5 << false;
QTest::newRow("0.1.2-alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2-alpha") << 5 << false;
QTest::newRow("0.1.2.alpha") << (QVector<int>() << 0 << 1 << 2) << QVersionNumber(0, 1, 2) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2.alpha") << 5 << false;
QTest::newRow("0.1.2.3alpha") << (QVector<int>() << 0 << 1 << 2 << 3) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3alpha") << 7 << false;
QTest::newRow("0.1.2.3.alpha") << (QVector<int>() << 0 << 1 << 2 << 3) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3.alpha") << 7 << false;
QTest::newRow("0.1.2.3.4.alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4.alpha") << 9 << false;
QTest::newRow("0.1.2.3.4 alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alpha") << 9 << false;
QTest::newRow("0.1.2.3.4 alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alp ha") << 9 << false;
QTest::newRow("0.1.2.3.4alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alp ha") << 9 << false;
QTest::newRow("0.1.2.3.4alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alpha ") << 9 << false;
QTest::newRow("0.1.2.3.4.5alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5) << QStringLiteral("0.1.2.3.4.5") << QStringLiteral("0.1.2.3.4.5alpha ") << 11 << false;
QTest::newRow("0.1.2.3.4.5.6alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6) << QStringLiteral("0.1.2.3.4.5.6") << QStringLiteral("0.1.2.3.4.5.6alpha ") << 13 << false;
QTest::newRow("0.1.2.3.4.5.6.7alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7) << QStringLiteral("0.1.2.3.4.5.6.7") << QStringLiteral("0.1.2.3.4.5.6.7alpha ") << 15 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8alpha ") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alpha ") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8.alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8.alpha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8 alpha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alpha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8 alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alp ha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8alp ha") << (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QVersionNumber(QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alp ha") << 17 << false;
QTest::newRow("10.09") << (QVector<int>() << 10 << 9) << QVersionNumber(QVector<int>() << 10 << 9) << QStringLiteral("10.9") << QStringLiteral("10.09") << 5 << false;
QTest::newRow("10.0x") << (QVector<int>() << 10 << 0) << QVersionNumber(QVector<int>() << 10 << 0) << QStringLiteral("10.0") << QStringLiteral("10.0x") << 4 << false;
QTest::newRow("10.0xTest") << (QVector<int>() << 10 << 0) << QVersionNumber(QVector<int>() << 10 << 0) << QStringLiteral("10.0") << QStringLiteral("10.0xTest") << 4 << false;
QTest::newRow("127.09") << (QVector<int>() << 127 << 9) << QVersionNumber(QVector<int>() << 127 << 9) << QStringLiteral("127.9") << QStringLiteral("127.09") << 6 << false;
QTest::newRow("127.0x") << (QVector<int>() << 127 << 0) << QVersionNumber(QVector<int>() << 127 << 0) << QStringLiteral("127.0") << QStringLiteral("127.0x") << 5 << false;
QTest::newRow("127.0xTest") << (QVector<int>() << 127 << 0) << QVersionNumber(QVector<int>() << 127 << 0) << QStringLiteral("127.0") << QStringLiteral("127.0xTest") << 5 << false;
QTest::newRow("128.09") << (QVector<int>() << 128 << 9) << QVersionNumber(QVector<int>() << 128 << 9) << QStringLiteral("128.9") << QStringLiteral("128.09") << 6 << false;
QTest::newRow("128.0x") << (QVector<int>() << 128 << 0) << QVersionNumber(QVector<int>() << 128 << 0) << QStringLiteral("128.0") << QStringLiteral("128.0x") << 5 << false;
QTest::newRow("128.0xTest") << (QVector<int>() << 128 << 0) << QVersionNumber(QVector<int>() << 128 << 0) << QStringLiteral("128.0") << QStringLiteral("128.0xTest") << 5 << false;
// segments expectedVersion expectedString constructionString suffixIndex null
QTest::newRow("null") << QList<int>() << QVersionNumber() << QString() << QString() << 0 << true;
QTest::newRow("text") << QList<int>() << QVersionNumber() << QString() << QStringLiteral("text") << 0 << true;
QTest::newRow(" text") << QList<int>() << QVersionNumber() << QString() << QStringLiteral(" text") << 0 << true;
QTest::newRow("Empty String") << QList<int>() << QVersionNumber() << QString() << QStringLiteral("Empty String") << 0 << true;
QTest::newRow("-1.-2") << QList<int>() << QVersionNumber() << QStringLiteral("") << QStringLiteral("-1.-2") << 0 << true;
QTest::newRow("1.-2-3") << QList<int> { 1 } << QVersionNumber(QList<int> { 1 }) << QStringLiteral("1") << QStringLiteral("1.-2-3") << 1 << false;
QTest::newRow("1.2-3") << QList<int> { 1, 2 } << QVersionNumber(QList<int> { 1, 2 }) << QStringLiteral("1.2") << QStringLiteral("1.2-3") << 3 << false;
QTest::newRow("0") << QList<int> { 0 } << QVersionNumber(QList<int> { 0 }) << QStringLiteral("0") << QStringLiteral("0") << 1 << false;
QTest::newRow("0.1") << QList<int> { 0, 1 } << QVersionNumber(QList<int> { 0, 1 }) << QStringLiteral("0.1") << QStringLiteral("0.1") << 3 << false;
QTest::newRow("0.1.2") << QList<int> { 0, 1, 2 } << QVersionNumber(QList<int> { 0, 1, 2 }) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2") << 5 << false;
QTest::newRow("0.1.2alpha") << QList<int> { 0, 1, 2 } << QVersionNumber(QList<int> { 0, 1, 2 }) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2alpha") << 5 << false;
QTest::newRow("0.1.2-alpha") << QList<int> { 0, 1, 2 } << QVersionNumber(QList<int> { 0, 1, 2 }) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2-alpha") << 5 << false;
QTest::newRow("0.1.2.alpha") << QList<int> { 0, 1, 2 } << QVersionNumber(QList<int> { 0, 1, 2 }) << QStringLiteral("0.1.2") << QStringLiteral("0.1.2.alpha") << 5 << false;
QTest::newRow("0.1.2.3alpha") << QList<int> { 0, 1, 2, 3 } << QVersionNumber(QList<int> { 0, 1, 2, 3 }) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3alpha") << 7 << false;
QTest::newRow("0.1.2.3.alpha") << QList<int> { 0, 1, 2, 3 } << QVersionNumber(QList<int> { 0, 1, 2, 3 }) << QStringLiteral("0.1.2.3") << QStringLiteral("0.1.2.3.alpha") << 7 << false;
QTest::newRow("0.1.2.3.4.alpha") << QList<int> { 0, 1, 2, 3, 4 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4 }) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4.alpha") << 9 << false;
QTest::newRow("0.1.2.3.4 alpha") << QList<int> { 0, 1, 2, 3, 4 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4 }) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alpha") << 9 << false;
QTest::newRow("0.1.2.3.4 alp ha") << QList<int> { 0, 1, 2, 3, 4 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4 }) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4 alp ha") << 9 << false;
QTest::newRow("0.1.2.3.4alp ha") << QList<int> { 0, 1, 2, 3, 4 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4 }) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alp ha") << 9 << false;
QTest::newRow("0.1.2.3.4alpha ") << QList<int> { 0, 1, 2, 3, 4 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4 }) << QStringLiteral("0.1.2.3.4") << QStringLiteral("0.1.2.3.4alpha ") << 9 << false;
QTest::newRow("0.1.2.3.4.5alpha ") << QList<int> { 0, 1, 2, 3, 4, 5 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5 }) << QStringLiteral("0.1.2.3.4.5") << QStringLiteral("0.1.2.3.4.5alpha ") << 11 << false;
QTest::newRow("0.1.2.3.4.5.6alpha ") << QList<int> { 0, 1, 2, 3, 4, 5, 6 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6 }) << QStringLiteral("0.1.2.3.4.5.6") << QStringLiteral("0.1.2.3.4.5.6alpha ") << 13 << false;
QTest::newRow("0.1.2.3.4.5.6.7alpha ") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7 }) << QStringLiteral("0.1.2.3.4.5.6.7") << QStringLiteral("0.1.2.3.4.5.6.7alpha ") << 15 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8alpha ") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alpha ") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8.alpha") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8.alpha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8 alpha") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alpha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8 alp ha") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8 alp ha") << 17 << false;
QTest::newRow("0.1.2.3.4.5.6.7.8alp ha") << QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 } << QVersionNumber(QList<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) << QStringLiteral("0.1.2.3.4.5.6.7.8") << QStringLiteral("0.1.2.3.4.5.6.7.8alp ha") << 17 << false;
QTest::newRow("10.09") << QList<int> { 10, 9 } << QVersionNumber(QList<int> { 10, 9 }) << QStringLiteral("10.9") << QStringLiteral("10.09") << 5 << false;
QTest::newRow("10.0x") << QList<int> { 10, 0 } << QVersionNumber(QList<int> { 10, 0 }) << QStringLiteral("10.0") << QStringLiteral("10.0x") << 4 << false;
QTest::newRow("10.0xTest") << QList<int> { 10, 0 } << QVersionNumber(QList<int> { 10, 0 }) << QStringLiteral("10.0") << QStringLiteral("10.0xTest") << 4 << false;
QTest::newRow("127.09") << QList<int> { 127, 9 } << QVersionNumber(QList<int> { 127, 9 }) << QStringLiteral("127.9") << QStringLiteral("127.09") << 6 << false;
QTest::newRow("127.0x") << QList<int> { 127, 0 } << QVersionNumber(QList<int> { 127, 0 }) << QStringLiteral("127.0") << QStringLiteral("127.0x") << 5 << false;
QTest::newRow("127.0xTest") << QList<int> { 127, 0 } << QVersionNumber(QList<int> { 127, 0 }) << QStringLiteral("127.0") << QStringLiteral("127.0xTest") << 5 << false;
QTest::newRow("128.09") << QList<int> { 128, 9 } << QVersionNumber(QList<int> { 128, 9 }) << QStringLiteral("128.9") << QStringLiteral("128.09") << 6 << false;
QTest::newRow("128.0x") << QList<int> { 128, 0 } << QVersionNumber(QList<int> { 128, 0 }) << QStringLiteral("128.0") << QStringLiteral("128.0x") << 5 << false;
QTest::newRow("128.0xTest") << QList<int> { 128, 0 } << QVersionNumber(QList<int> { 128, 0 }) << QStringLiteral("128.0") << QStringLiteral("128.0xTest") << 5 << false;
}
namespace UglyOperator {
// ugh, but the alternative (operator <<) is even worse...
static inline QVector<int> operator+(QVector<int> v, int i) { v.push_back(i); return v; }
static inline QList<int> operator+(QList<int> v, int i) { v.push_back(i); return v; }
}
void tst_QVersionNumber::comparisonData()
@ -200,7 +200,7 @@ void tst_QVersionNumber::comparisonData()
QTest::newRow("0.-129, 0") << QVersionNumber(0, -129) << QVersionNumber(0) << false << true << true << true << false << false << -129 << false << QVersionNumber(0);
QTest::newRow("0, 0.-129") << QVersionNumber(0) << QVersionNumber(0, -129) << false << true << false << false << true << true << 129 << true << QVersionNumber(0);
const QVector<int> common = QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6;
const QList<int> common = QList<int>({ 0, 1, 2, 3, 4, 5, 6 });
using namespace UglyOperator;
QTest::newRow("0.1.2.3.4.5.6.0.1.2, 0.1.2.3.4.5.6.0.1") << QVersionNumber(common + 0 + 1 + 2) << QVersionNumber(common + 0 + 1) << false << true << false << false << true << true << 2 << false << QVersionNumber(common + 0 + 1);
QTest::newRow("0.1.2.3.4.5.6.0.1, 0.1.2.3.4.5.6.0.1.2") << QVersionNumber(common + 0 + 1) << QVersionNumber(common + 0 + 1 + 2) << false << true << true << true << false << false << -2 << true << QVersionNumber(common + 0 + 1);
@ -217,7 +217,7 @@ void tst_QVersionNumber::comparisonData()
void tst_QVersionNumber::initTestCase()
{
qRegisterMetaType<QVector<int> >();
qRegisterMetaType<QList<int>>();
}
void tst_QVersionNumber::constructorDefault()
@ -227,7 +227,7 @@ void tst_QVersionNumber::constructorDefault()
QCOMPARE(version.majorVersion(), 0);
QCOMPARE(version.minorVersion(), 0);
QCOMPARE(version.microVersion(), 0);
QCOMPARE(version.segments(), QVector<int>());
QCOMPARE(version.segments(), QList<int>());
}
void tst_QVersionNumber::constructorVersioned_data()
@ -237,7 +237,7 @@ void tst_QVersionNumber::constructorVersioned_data()
void tst_QVersionNumber::constructorVersioned()
{
QFETCH(QVector<int>, segments);
QFETCH(QList<int>, segments);
QFETCH(QVersionNumber, expectedVersion);
QVersionNumber version(segments);
@ -250,17 +250,17 @@ void tst_QVersionNumber::constructorVersioned()
void tst_QVersionNumber::constructorExplicit()
{
QVersionNumber v1(1);
QVersionNumber v2(QVector<int>() << 1);
QVersionNumber v2(QList<int>({ 1 }));
QCOMPARE(v1.segments(), v2.segments());
QVersionNumber v3(1, 2);
QVersionNumber v4(QVector<int>() << 1 << 2);
QVersionNumber v4(QList<int>({ 1, 2 }));
QCOMPARE(v3.segments(), v4.segments());
QVersionNumber v5(1, 2, 3);
QVersionNumber v6(QVector<int>() << 1 << 2 << 3);
QVersionNumber v6(QList<int>({ 1, 2, 3 }));
QCOMPARE(v5.segments(), v6.segments());
@ -277,7 +277,7 @@ void tst_QVersionNumber::constructorCopy_data()
void tst_QVersionNumber::constructorCopy()
{
QFETCH(QVector<int>, segments);
QFETCH(QList<int>, segments);
QFETCH(QVersionNumber, expectedVersion);
QVersionNumber original(segments);
@ -422,14 +422,14 @@ void tst_QVersionNumber::normalized_data()
QTest::addColumn<QVersionNumber>("version");
QTest::addColumn<QVersionNumber>("expected");
QTest::newRow("0") << QVersionNumber(0) << QVersionNumber();
QTest::newRow("1") << QVersionNumber(1) << QVersionNumber(1);
QTest::newRow("1.2") << QVersionNumber(1, 2) << QVersionNumber(1, 2);
QTest::newRow("1.0") << QVersionNumber(1, 0) << QVersionNumber(1);
QTest::newRow("1.0.0") << QVersionNumber(1, 0, 0) << QVersionNumber(1);
QTest::newRow("1.0.1") << QVersionNumber(1, 0, 1) << QVersionNumber(1, 0, 1);
QTest::newRow("1.0.1.0") << QVersionNumber(QVector<int>() << 1 << 0 << 1 << 0) << QVersionNumber(1, 0, 1);
QTest::newRow("0.0.1.0") << QVersionNumber(QVector<int>() << 0 << 0 << 1 << 0) << QVersionNumber(0, 0, 1);
QTest::newRow("0") << QVersionNumber(0) << QVersionNumber();
QTest::newRow("1") << QVersionNumber(1) << QVersionNumber(1);
QTest::newRow("1.2") << QVersionNumber(1, 2) << QVersionNumber(1, 2);
QTest::newRow("1.0") << QVersionNumber(1, 0) << QVersionNumber(1);
QTest::newRow("1.0.0") << QVersionNumber(1, 0, 0) << QVersionNumber(1);
QTest::newRow("1.0.1") << QVersionNumber(1, 0, 1) << QVersionNumber(1, 0, 1);
QTest::newRow("1.0.1.0") << QVersionNumber(QList<int>({ 1, 0, 1, 0 })) << QVersionNumber(1, 0, 1);
QTest::newRow("0.0.1.0") << QVersionNumber(QList<int>({ 0, 0, 1, 0 })) << QVersionNumber(0, 0, 1);
}
void tst_QVersionNumber::normalized()
@ -446,13 +446,13 @@ void tst_QVersionNumber::isNormalized_data()
QTest::addColumn<QVersionNumber>("version");
QTest::addColumn<bool>("expected");
QTest::newRow("null") << QVersionNumber() << true;
QTest::newRow("0") << QVersionNumber(0) << false;
QTest::newRow("1") << QVersionNumber(1) << true;
QTest::newRow("1.2") << QVersionNumber(1, 2) << true;
QTest::newRow("1.0") << QVersionNumber(1, 0) << false;
QTest::newRow("1.0.0") << QVersionNumber(1, 0, 0) << false;
QTest::newRow("1.0.1") << QVersionNumber(1, 0, 1) << true;
QTest::newRow("null") << QVersionNumber() << true;
QTest::newRow("0") << QVersionNumber(0) << false;
QTest::newRow("1") << QVersionNumber(1) << true;
QTest::newRow("1.2") << QVersionNumber(1, 2) << true;
QTest::newRow("1.0") << QVersionNumber(1, 0) << false;
QTest::newRow("1.0.0") << QVersionNumber(1, 0, 0) << false;
QTest::newRow("1.0.1") << QVersionNumber(1, 0, 1) << true;
}
void tst_QVersionNumber::isNormalized()
@ -470,7 +470,7 @@ void tst_QVersionNumber::assignment_data()
void tst_QVersionNumber::assignment()
{
QFETCH(QVector<int>, segments);
QFETCH(QList<int>, segments);
QFETCH(QVersionNumber, expectedVersion);
QVersionNumber original(segments);
@ -492,17 +492,17 @@ void tst_QVersionNumber::fromString_data()
const QString largerThanIntCanHoldString1 = "0." + QString::number(largerThanIntCanHold);
QTest::newRow(qPrintable(largerThanIntCanHoldString0))
<< QVector<int>() << QVersionNumber() << QString() << largerThanIntCanHoldString0 << 0 << true;
<< QList<int>() << QVersionNumber() << QString() << largerThanIntCanHoldString0 << 0 << true;
QTest::newRow(qPrintable(largerThanIntCanHoldString1))
<< QVector<int>(0) << QVersionNumber(0) << QStringLiteral("0") << largerThanIntCanHoldString1 << 1 << true;
<< QList<int>(0) << QVersionNumber(0) << QStringLiteral("0") << largerThanIntCanHoldString1 << 1 << true;
const QString largerThanULongLongCanHoldString0 = QString::number(std::numeric_limits<qulonglong>::max()) + "0.0"; // 10x ULLONG_MAX
const QString largerThanULongLongCanHoldString1 = "0." + QString::number(std::numeric_limits<qulonglong>::max()) + '0'; // 10x ULLONG_MAX
QTest::newRow(qPrintable(largerThanULongLongCanHoldString0))
<< QVector<int>() << QVersionNumber() << QString() << largerThanULongLongCanHoldString0 << 0 << true;
<< QList<int>() << QVersionNumber() << QString() << largerThanULongLongCanHoldString0 << 0 << true;
QTest::newRow(qPrintable(largerThanULongLongCanHoldString1))
<< QVector<int>(0) << QVersionNumber(0) << QStringLiteral("0") << largerThanULongLongCanHoldString1 << 1 << true;
<< QList<int>(0) << QVersionNumber(0) << QStringLiteral("0") << largerThanULongLongCanHoldString1 << 1 << true;
}
void tst_QVersionNumber::fromString()
@ -529,10 +529,10 @@ void tst_QVersionNumber::toString_data()
{
singleInstanceData();
// segments expectedVersion expectedString constructionString suffixIndex null
QTest::newRow("-1") << (QVector<int>() << -1) << QVersionNumber(-1) << QString("-1") << QString() << 0 << true;
QTest::newRow("-1.0") << (QVector<int>() << -1 << 0) << QVersionNumber(-1, 0) << QString("-1.0") << QString() << 0 << true;
QTest::newRow("1.-2") << (QVector<int>() << 1 << -2) << QVersionNumber(1, -2) << QString("1.-2") << QString() << 0 << true;
// segments expectedVersion expectedString constructionString suffixIndex null
QTest::newRow("-1") << (QList<int>({ -1 })) << QVersionNumber(-1) << QString("-1") << QString() << 0 << true;
QTest::newRow("-1.0") << (QList<int>({ -1, 0 })) << QVersionNumber(-1, 0) << QString("-1.0") << QString() << 0 << true;
QTest::newRow("1.-2") << (QList<int>({ 1, -2 })) << QVersionNumber(1, -2) << QString("1.-2") << QString() << 0 << true;
}
void tst_QVersionNumber::toString()
@ -550,7 +550,7 @@ void tst_QVersionNumber::isNull_data()
void tst_QVersionNumber::isNull()
{
QFETCH(QVector<int>, segments);
QFETCH(QList<int>, segments);
QFETCH(bool, isNull);
QVersionNumber version(segments);
@ -565,7 +565,7 @@ void tst_QVersionNumber::serialize_data()
void tst_QVersionNumber::serialize()
{
QFETCH(QVector<int>, segments);
QFETCH(QList<int>, segments);
QVersionNumber original(segments);
QVersionNumber version;
@ -601,9 +601,9 @@ void tst_QVersionNumber::moveSemantics()
v2 = std::move(v1);
QCOMPARE(v2, QVersionNumber(1, 2, 3));
}
// QVersionNumber(QVector<int> &&)
// QVersionNumber(QList<int> &&)
{
QVector<int> segments = QVector<int>() << 1 << 2 << 3;
QList<int> segments = QList<int>({ 1, 2, 3});
QVersionNumber v1(segments);
QVersionNumber v2(std::move(segments));
QVERIFY(!v1.isNull());
@ -628,7 +628,7 @@ void tst_QVersionNumber::moveSemantics()
{
QVersionNumber v(1, 2, 3);
QVERIFY(!v.isNull());
QVector<int> segments;
QList<int> segments;
segments = v.segments();
QVERIFY(!v.isNull());
QVERIFY(!segments.empty());