summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2020-10-07 15:32:57 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2020-10-08 16:52:28 +0200
commit6c7ed4c013393ce414f02fe4c9a88ebebeb3e47d (patch)
treef43c4567312b87a03e3e227f9c2a5fe565041f9b /tests
parent6443c2215ee5c7d085fe84c7a271b70ea1185d3b (diff)
Make QADP capacity functions use qsizetype instead of size_t
Change types returned and accepted by capacity-related QArrayDataPointer functions to qsizetype: 1) QArrayData (underlying d-ptr) works with qsizetype 2) QArrayDataPointer::size is of type qsizetype 3) All higher level classes that use QADP (e.g. containers) cast capacity to qsizetype in their methods Additionally, fixed newly appeared warnings through qtbase Change-Id: I899408decfbf2ce9d527be7e8b7f6382875148fc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 288bc6e120..c9b5538ad5 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -1179,17 +1179,17 @@ void tst_QArrayData::arrayOpsExtra()
auto [intData, strData, objData] = setupDataPointers(inputSize);
QVERIFY(intData.size == 0);
QVERIFY(intData.d_ptr() != nullptr);
- QVERIFY(intData.constAllocatedCapacity() >= inputSize);
+ QVERIFY(size_t(intData.constAllocatedCapacity()) >= inputSize);
QVERIFY(intData.data() != nullptr);
QVERIFY(strData.size == 0);
QVERIFY(strData.d_ptr() != nullptr);
- QVERIFY(strData.constAllocatedCapacity() >= inputSize);
+ QVERIFY(size_t(strData.constAllocatedCapacity()) >= inputSize);
QVERIFY(strData.data() != nullptr);
QVERIFY(objData.size == 0);
QVERIFY(objData.d_ptr() != nullptr);
- QVERIFY(objData.constAllocatedCapacity() >= inputSize);
+ QVERIFY(size_t(objData.constAllocatedCapacity()) >= inputSize);
QVERIFY(objData.data() != nullptr);
}
@@ -1237,9 +1237,9 @@ void tst_QArrayData::arrayOpsExtra()
RUN_TEST_FUNC(testCopyAppend, intData, intVec.begin(), intVec.end());
RUN_TEST_FUNC(testCopyAppend, strData, strVec.begin(), strVec.end());
RUN_TEST_FUNC(testCopyAppend, objData, objVec.begin(), objVec.end());
- QCOMPARE(size_t(intData.size), intData.constAllocatedCapacity());
- QCOMPARE(size_t(strData.size), strData.constAllocatedCapacity());
- QCOMPARE(size_t(objData.size), objData.constAllocatedCapacity());
+ QCOMPARE(intData.size, intData.constAllocatedCapacity());
+ QCOMPARE(strData.size, strData.constAllocatedCapacity());
+ QCOMPARE(objData.size, objData.constAllocatedCapacity());
}
// copyAppend (iterator version) - special case of copying from self iterators
@@ -1337,9 +1337,9 @@ void tst_QArrayData::arrayOpsExtra()
RUN_TEST_FUNC(testCopyAppend, intData, intDataFreeSpace, int(-1));
RUN_TEST_FUNC(testCopyAppend, strData, strDataFreeSpace, QLatin1String("foo"));
RUN_TEST_FUNC(testCopyAppend, objData, objDataFreeSpace, CountedObject());
- QCOMPARE(size_t(intData.size), intData.constAllocatedCapacity());
- QCOMPARE(size_t(strData.size), strData.constAllocatedCapacity());
- QCOMPARE(size_t(objData.size), objData.constAllocatedCapacity());
+ QCOMPARE(intData.size, intData.constAllocatedCapacity());
+ QCOMPARE(strData.size, strData.constAllocatedCapacity());
+ QCOMPARE(objData.size, objData.constAllocatedCapacity());
}
// copyAppend (value version) - special case of copying self value
@@ -1431,9 +1431,9 @@ void tst_QArrayData::arrayOpsExtra()
std::vector<QString>(strDataFreeSpace, QLatin1String("barbaz")));
RUN_TEST_FUNC(testMoveAppend, objData,
std::vector<CountedObject>(objDataFreeSpace, CountedObject()));
- QCOMPARE(size_t(intData.size), intData.constAllocatedCapacity());
- QCOMPARE(size_t(strData.size), strData.constAllocatedCapacity());
- QCOMPARE(size_t(objData.size), objData.constAllocatedCapacity());
+ QCOMPARE(intData.size, intData.constAllocatedCapacity());
+ QCOMPARE(strData.size, strData.constAllocatedCapacity());
+ QCOMPARE(objData.size, objData.constAllocatedCapacity());
}
// moveAppend - special case of moving from self (this is legal yet rather useless)
@@ -2104,7 +2104,7 @@ void tst_QArrayData::dataPointerAllocate()
const auto freeAtEnd = newDataPointer.freeSpaceAtEnd();
QVERIFY(newAlloc > oldDataPointer.constAllocatedCapacity());
- QCOMPARE(size_t(freeAtBegin + freeAtEnd), newAlloc);
+ QCOMPARE(freeAtBegin + freeAtEnd, newAlloc);
// when not detached, the behavior is the same as of ::realloc
if (allocationOptions & (QArrayData::GrowsForward | QArrayData::GrowsBackwards))
QCOMPARE(freeAtBegin, oldDataPointer.freeSpaceAtBegin());
@@ -2136,9 +2136,9 @@ void tst_QArrayData::dataPointerAllocate()
const auto freeAtEnd = newDataPointer.freeSpaceAtEnd();
QVERIFY(newAlloc > oldDataPointer.constAllocatedCapacity());
- QCOMPARE(size_t(freeAtBegin + freeAtEnd), newAlloc);
+ QCOMPARE(freeAtBegin + freeAtEnd, newAlloc);
if (allocationOptions & QArrayData::GrowsBackwards) {
- QCOMPARE(size_t(freeAtBegin), (newAlloc - newSize) / 2);
+ QCOMPARE(freeAtBegin, (newAlloc - newSize) / 2);
} else {
QCOMPARE(freeAtBegin, 0);
}