summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-06-04 21:06:49 +0200
committerLars Knoll <lars.knoll@qt.io>2019-12-07 14:17:55 +0100
commitbf0b4f332a2f1ec9860c610d98cd27e483869bec (patch)
tree0593f49cd79fea6986fcbcc05ab098e36c6494bb /tests/auto/corelib/tools
parent41287d355b9571db0fbdf5841b31595705af0102 (diff)
Rename QArrayData::AllocateOptions enum and update some flags
Rename to QArrayData::ArrayOptions in preparation for these flags being in the array itself, instead of used just for allocating new ones. For that reason, rename QArrayData::Default to DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean the flags needed for creating a raw (static) QArrayData. Also rename QArrayData::Grow to GrowsForward, so we may add GrowsBackward in the future. Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qarraydata/simplevector.h8
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp30
2 files changed, 19 insertions, 19 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h
index e587ad27b5..ffc8ba770c 100644
--- a/tests/auto/corelib/tools/qarraydata/simplevector.h
+++ b/tests/auto/corelib/tools/qarraydata/simplevector.h
@@ -199,7 +199,7 @@ public:
|| capacity() - size() < size_t(last - first)) {
SimpleVector detached(Data::allocate(
d->detachCapacity(size() + (last - first)),
- d->detachFlags() | Data::Grow));
+ d->detachFlags() | Data::GrowsForward));
detached.d->copyAppend(first, last);
detached.d->copyAppend(begin, begin + d->size);
@@ -220,7 +220,7 @@ public:
|| capacity() - size() < size_t(last - first)) {
SimpleVector detached(Data::allocate(
d->detachCapacity(size() + (last - first)),
- d->detachFlags() | Data::Grow));
+ d->detachFlags() | Data::GrowsForward));
if (d->size) {
const T *const begin = constBegin();
@@ -260,7 +260,7 @@ public:
|| capacity() - size() < size_t(last - first)) {
SimpleVector detached(Data::allocate(
d->detachCapacity(size() + (last - first)),
- d->detachFlags() | Data::Grow));
+ d->detachFlags() | Data::GrowsForward));
if (position)
detached.d->copyAppend(begin, where);
@@ -328,7 +328,7 @@ public:
}
static SimpleVector fromRawData(const T *data, size_t size,
- QArrayData::AllocationOptions options = Data::Default)
+ QArrayData::ArrayOptions options = Data::DefaultRawFlags)
{
return SimpleVector(Data::fromRawData(data, size, options));
}
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 47bdc2fd38..d3e071bb1b 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -528,13 +528,13 @@ struct Deallocator
};
Q_DECLARE_METATYPE(const QArrayData *)
-Q_DECLARE_METATYPE(QArrayData::AllocationOptions)
+Q_DECLARE_METATYPE(QArrayData::ArrayOptions)
void tst_QArrayData::allocate_data()
{
QTest::addColumn<size_t>("objectSize");
QTest::addColumn<size_t>("alignment");
- QTest::addColumn<QArrayData::AllocationOptions>("allocateOptions");
+ QTest::addColumn<QArrayData::ArrayOptions>("allocateOptions");
QTest::addColumn<bool>("isCapacityReserved");
QTest::addColumn<const QArrayData *>("commonEmpty");
@@ -553,13 +553,13 @@ void tst_QArrayData::allocate_data()
struct {
char const *description;
- QArrayData::AllocationOptions allocateOptions;
+ QArrayData::ArrayOptions allocateOptions;
bool isCapacityReserved;
const QArrayData *commonEmpty;
} options[] = {
- { "Default", QArrayData::Default, false, shared_empty },
+ { "Default", QArrayData::DefaultAllocationFlags, false, shared_empty },
{ "Reserved", QArrayData::CapacityReserved, true, shared_empty },
- { "Grow", QArrayData::Grow, false, shared_empty }
+ { "Grow", QArrayData::GrowsForward, false, shared_empty }
};
for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); ++i)
@@ -577,7 +577,7 @@ void tst_QArrayData::allocate()
{
QFETCH(size_t, objectSize);
QFETCH(size_t, alignment);
- QFETCH(QArrayData::AllocationOptions, allocateOptions);
+ QFETCH(QArrayData::ArrayOptions, allocateOptions);
QFETCH(bool, isCapacityReserved);
QFETCH(const QArrayData *, commonEmpty);
@@ -587,18 +587,18 @@ void tst_QArrayData::allocate()
// Shared Empty
QCOMPARE(QArrayData::allocate(objectSize, minAlignment, 0,
- QArrayData::AllocationOptions(allocateOptions)), commonEmpty);
+ QArrayData::ArrayOptions(allocateOptions)), commonEmpty);
Deallocator keeper(objectSize, minAlignment);
keeper.headers.reserve(1024);
for (int capacity = 1; capacity <= 1024; capacity <<= 1) {
QArrayData *data = QArrayData::allocate(objectSize, minAlignment,
- capacity, QArrayData::AllocationOptions(allocateOptions));
+ capacity, QArrayData::ArrayOptions(allocateOptions));
keeper.headers.append(data);
QCOMPARE(data->size, 0);
- if (allocateOptions & QArrayData::Grow)
+ if (allocateOptions & QArrayData::GrowsForward)
QVERIFY(data->alloc > uint(capacity));
else
QCOMPARE(data->alloc, uint(capacity));
@@ -614,7 +614,7 @@ void tst_QArrayData::reallocate()
{
QFETCH(size_t, objectSize);
QFETCH(size_t, alignment);
- QFETCH(QArrayData::AllocationOptions, allocateOptions);
+ QFETCH(QArrayData::ArrayOptions, allocateOptions);
QFETCH(bool, isCapacityReserved);
// Maximum alignment that can be requested is that of QArrayData,
@@ -628,7 +628,7 @@ void tst_QArrayData::reallocate()
int capacity = 10;
Deallocator keeper(objectSize, minAlignment);
QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity,
- QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow);
+ QArrayData::ArrayOptions(allocateOptions) & ~QArrayData::GrowsForward);
keeper.headers.append(data);
memset(data->data(), 'A', objectSize * capacity);
@@ -637,13 +637,13 @@ void tst_QArrayData::reallocate()
// now try to reallocate
int newCapacity = 40;
data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity,
- QArrayData::AllocationOptions(allocateOptions));
+ QArrayData::ArrayOptions(allocateOptions));
QVERIFY(data);
keeper.headers.clear();
keeper.headers.append(data);
QCOMPARE(data->size, capacity);
- if (allocateOptions & QArrayData::Grow)
+ if (allocateOptions & QArrayData::GrowsForward)
QVERIFY(data->alloc > uint(newCapacity));
else
QCOMPARE(data->alloc, uint(newCapacity));
@@ -681,7 +681,7 @@ void tst_QArrayData::alignment()
for (int i = 0; i < 100; ++i) {
QArrayData *data = QArrayData::allocate(sizeof(Unaligned),
- minAlignment, 8, QArrayData::Default);
+ minAlignment, 8, QArrayData::DefaultAllocationFlags);
keeper.headers.append(data);
QVERIFY(data);
@@ -1253,7 +1253,7 @@ void fromRawData_impl()
{
// Default: Immutable, sharable
SimpleVector<T> raw = SimpleVector<T>::fromRawData(array,
- sizeof(array)/sizeof(array[0]), QArrayData::Default);
+ sizeof(array)/sizeof(array[0]), QArrayData::DefaultAllocationFlags);
QCOMPARE(raw.size(), size_t(11));
QCOMPARE((const T *)raw.constBegin(), array);