summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-06-04 22:04:13 +0200
committerLars Knoll <lars.knoll@qt.io>2019-12-07 14:18:12 +0100
commit8fb45ae5b8b8ad276aeb9bc9e40f351f47523087 (patch)
treed6c3c40b59b9650f5ea6815afa06bac3cec78897 /tests/auto/corelib/tools
parent64db4861bfcacc8849e8452b73d5c940d97aefd0 (diff)
Introduce QArrayData::allocatedCapacity() and use it instead of d->alloc
In almost all cases, use d->allocatedCapacity() or d->constAllocatedCapacity() instead of d->alloc, since they do the same thing (right now). In the future, the functions will be changed. There is a separate const version because most const code should not need to know the allocation size -- only mutating code should need to know that There are a few cases where d->alloc was replaced with a better alternative, like d->size. The one case that remains in the code will be replaced by a different test when it's available. Change-Id: I48135469db4caf150f82df93fff42d2309b23719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qarraydata/simplevector.h2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp20
2 files changed, 11 insertions, 11 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h
index b5308e2231..f3e3a1bb50 100644
--- a/tests/auto/corelib/tools/qarraydata/simplevector.h
+++ b/tests/auto/corelib/tools/qarraydata/simplevector.h
@@ -90,7 +90,7 @@ public:
bool isSharedWith(const SimpleVector &other) const { return d == other.d; }
size_t size() const { return d->size; }
- size_t capacity() const { return d->alloc; }
+ size_t capacity() const { return d->allocatedCapacity(); }
iterator begin() { detach(); return d->begin(); }
iterator end() { detach(); return d->end(); }
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 1a043f7797..23ea417481 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -154,10 +154,10 @@ void tst_QArrayData::sharedNullEmpty()
QVERIFY(null != empty);
QCOMPARE(null->size, 0);
- QCOMPARE(null->alloc, 0u);
+ QCOMPARE(null->allocatedCapacity(), size_t(0));
QCOMPARE(empty->size, 0);
- QCOMPARE(empty->alloc, 0u);
+ QCOMPARE(empty->allocatedCapacity(), size_t(0));
}
void tst_QArrayData::staticData()
@@ -597,9 +597,9 @@ void tst_QArrayData::allocate()
QCOMPARE(data->size, 0);
if (allocateOptions & QArrayData::GrowsForward)
- QVERIFY(data->alloc > uint(capacity));
+ QVERIFY(data->allocatedCapacity() > uint(capacity));
else
- QCOMPARE(data->alloc, uint(capacity));
+ QCOMPARE(data->allocatedCapacity(), size_t(capacity));
QCOMPARE(bool(data->flags & QArrayData::CapacityReserved), isCapacityReserved);
// Check that the allocated array can be used. Best tested with a
@@ -642,9 +642,9 @@ void tst_QArrayData::reallocate()
QCOMPARE(data->size, capacity);
if (allocateOptions & QArrayData::GrowsForward)
- QVERIFY(data->alloc > uint(newCapacity));
+ QVERIFY(data->allocatedCapacity() > size_t(newCapacity));
else
- QCOMPARE(data->alloc, uint(newCapacity));
+ QCOMPARE(data->allocatedCapacity(), size_t(newCapacity));
QCOMPARE(!(data->flags & QArrayData::CapacityReserved), !isCapacityReserved);
for (int i = 0; i < capacity; ++i)
@@ -684,7 +684,7 @@ void tst_QArrayData::alignment()
QVERIFY(data);
QCOMPARE(data->size, 0);
- QVERIFY(data->alloc >= uint(8));
+ QVERIFY(data->allocatedCapacity() >= uint(8));
// These conditions should hold as long as header and array are
// allocated together
@@ -756,7 +756,7 @@ void tst_QArrayData::typedData()
QVERIFY(array);
QCOMPARE(array->size, 0);
- QCOMPARE(array->alloc, 10u);
+ QCOMPARE(array->allocatedCapacity(), size_t(10));
// Check that the allocated array can be used. Best tested with a
// memory checker, such as valgrind, running.
@@ -776,7 +776,7 @@ void tst_QArrayData::typedData()
QVERIFY(array);
QCOMPARE(array->size, 0);
- QCOMPARE(array->alloc, 10u);
+ QCOMPARE(array->allocatedCapacity(), size_t(10));
// Check that the allocated array can be used. Best tested with a
// memory checker, such as valgrind, running.
@@ -796,7 +796,7 @@ void tst_QArrayData::typedData()
QVERIFY(array);
QCOMPARE(array->size, 0);
- QCOMPARE(array->alloc, 10u);
+ QCOMPARE(array->allocatedCapacity(), size_t(10));
// Check that the allocated array can be used. Best tested with a
// memory checker, such as valgrind, running.