summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-08-20 18:31:06 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-26 01:03:22 +0200
commitacbf9a858b6b389103b7f43f4f4892a142ec56c6 (patch)
tree1c5e7feae0cd6999e37fca0644d152c76d29a790 /tests
parentdb21bad936a761f475145886f1e06dfcfa11eb80 (diff)
Cleanup QTypeInfo
Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp4
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp11
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp4
-rw-r--r--tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp9
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp12
-rw-r--r--tests/auto/corelib/tools/qpair/tst_qpair.cpp20
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp6
-rw-r--r--tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp2
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h4
10 files changed, 41 insertions, 33 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 64afdaf352..521e134767 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -152,7 +152,7 @@ enum class MyStrictNoOpEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
Q_DECLARE_FLAGS( MyStrictNoOpFlags, MyStrictNoOpEnum )
static_assert( !QTypeInfo<MyStrictFlags>::isComplex );
-static_assert( !QTypeInfo<MyStrictFlags>::isStatic );
+static_assert( QTypeInfo<MyStrictFlags>::isRelocatable );
static_assert( !QTypeInfo<MyStrictFlags>::isPointer );
void tst_QFlags::classEnum()
@@ -322,7 +322,7 @@ Q_DECLARE_FLAGS( MyFlags, MyEnum )
Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags )
static_assert( !QTypeInfo<MyFlags>::isComplex );
-static_assert( !QTypeInfo<MyFlags>::isStatic );
+static_assert( QTypeInfo<MyFlags>::isRelocatable );
static_assert( !QTypeInfo<MyFlags>::isPointer );
QTEST_MAIN(tst_QFlags)
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 42d8d37583..e97dacea5f 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -919,6 +919,11 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_COPY_FUNCTION)
TypeTestFunctionGetter::get(type)();
}
+template<typename T>
+constexpr size_t getSize = sizeof(T);
+template<>
+constexpr size_t getSize<void> = 0;
+
void tst_QMetaType::sizeOf_data()
{
QTest::addColumn<int>("type");
@@ -926,7 +931,7 @@ void tst_QMetaType::sizeOf_data()
QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << size_t(0);
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
- QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << size_t(QTypeInfo<RealType>::sizeOf);
+ QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << getSize<RealType>;
FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW)
#undef ADD_METATYPE_TEST_ROW
@@ -1074,8 +1079,8 @@ void tst_QMetaType::flags_data()
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
QTest::newRow(#RealType) << MetaTypeId \
- << bool(QTypeInfoQuery<RealType>::isRelocatable) \
- << bool(QTypeInfoQuery<RealType>::isComplex) \
+ << bool(QTypeInfo<RealType>::isRelocatable) \
+ << bool(QTypeInfo<RealType>::isComplex) \
<< bool(QtPrivate::IsPointerToTypeDerivedFromQObject<RealType>::Value) \
<< bool(std::is_enum<RealType>::value);
QT_FOR_EACH_STATIC_CORE_CLASS(ADD_METATYPE_TEST_ROW)
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index b871bfcac9..5fa06c4f46 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -3187,7 +3187,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString
{
QVariant v2 = v;
- if (!(QTypeInfo<T>::isStatic && QTypeInfo<T>::isComplex)) {
+ if (QTypeInfo<T>::isRelocatable) {
// Type is movable so standard comparison algorithm in QVariant should work
// In a custom type QVariant is not aware of ==operator so it won't be called,
// which may cause problems especially visible when using a not-movable type
@@ -3204,7 +3204,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString
v = QVariant();
QCOMPARE(v3, v);
v = v2;
- if (!(QTypeInfo<T>::isStatic && QTypeInfo<T>::isComplex)) {
+ if (QTypeInfo<T>::isRelocatable) {
// Type is movable so standard comparison algorithm in QVariant should work
// In a custom type QVariant is not aware of ==operator so it won't be called,
// which may cause problems especially visible when using a not-movable type
diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
index 0d467cc364..308b60d83b 100644
--- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp
@@ -1880,7 +1880,7 @@ void tst_QByteArray::movablity()
{
QFETCH(QByteArray, array);
- static_assert(!QTypeInfo<QByteArray>::isStatic);
+ static_assert(QTypeInfo<QByteArray>::isRelocatable);
const int size = array.size();
const bool isEmpty = array.isEmpty();
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index efec562ba9..0172927042 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -800,9 +800,12 @@ void tst_QArrayData::arrayOps()
};
const CountedObject objArray[5];
- QVERIFY(!QTypeInfo<int>::isComplex && !QTypeInfo<int>::isStatic);
- QVERIFY(QTypeInfo<QString>::isComplex && !QTypeInfo<QString>::isStatic);
- QVERIFY(QTypeInfo<CountedObject>::isComplex && QTypeInfo<CountedObject>::isStatic);
+ static_assert(!QTypeInfo<int>::isComplex);
+ static_assert(QTypeInfo<int>::isRelocatable);
+ static_assert(QTypeInfo<QString>::isComplex);
+ static_assert(QTypeInfo<QString>::isRelocatable);
+ static_assert(QTypeInfo<CountedObject>::isComplex);
+ static_assert(!QTypeInfo<CountedObject>::isRelocatable);
QCOMPARE(CountedObject::liveCount, size_t(5));
for (size_t i = 0; i < 5; ++i)
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index 56651ae474..f37633b64c 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -184,11 +184,11 @@ inline size_t qHash(const Custom &key, size_t seed = 0) { return qHash(key.i, se
Q_DECLARE_METATYPE(Custom);
// tests depends on the fact that:
-static_assert(!QTypeInfo<int>::isStatic);
+static_assert(QTypeInfo<int>::isRelocatable);
static_assert(!QTypeInfo<int>::isComplex);
-static_assert(!QTypeInfo<Movable>::isStatic);
+static_assert(QTypeInfo<Movable>::isRelocatable);
static_assert(QTypeInfo<Movable>::isComplex);
-static_assert(QTypeInfo<Custom>::isStatic);
+static_assert(!QTypeInfo<Custom>::isRelocatable);
static_assert(QTypeInfo<Custom>::isComplex);
@@ -2144,7 +2144,7 @@ void tst_QList::resizePOD_data() const
QTest::addColumn<int>("size");
QVERIFY(!QTypeInfo<int>::isComplex);
- QVERIFY(!QTypeInfo<int>::isStatic);
+ QVERIFY(QTypeInfo<int>::isRelocatable);
QList<int> null;
QList<int> empty(0, 5);
@@ -2192,7 +2192,7 @@ void tst_QList::resizeComplexMovable_data() const
QTest::addColumn<int>("size");
QVERIFY(QTypeInfo<Movable>::isComplex);
- QVERIFY(!QTypeInfo<Movable>::isStatic);
+ QVERIFY(QTypeInfo<Movable>::isRelocatable);
QList<Movable> null;
QList<Movable> empty(0, 'Q');
@@ -2244,7 +2244,7 @@ void tst_QList::resizeComplex_data() const
QTest::addColumn<int>("size");
QVERIFY(QTypeInfo<Custom>::isComplex);
- QVERIFY(QTypeInfo<Custom>::isStatic);
+ QVERIFY(!QTypeInfo<Custom>::isRelocatable);
QList<Custom> null;
QList<Custom> empty(0, '0');
diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
index 70caa055b6..70808e3e48 100644
--- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp
+++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
@@ -43,7 +43,7 @@ private Q_SLOTS:
void testDeductionRules();
};
-class C { C() {} Q_DECL_UNUSED_MEMBER char _[4]; };
+class C { C() {} ~C() {} Q_DECL_UNUSED_MEMBER char _[4]; };
class M { M() {} Q_DECL_UNUSED_MEMBER char _[4]; };
class P { Q_DECL_UNUSED_MEMBER char _[4]; };
@@ -64,31 +64,31 @@ typedef QPair<P,M> QPairPM;
typedef QPair<P,P> QPairPP;
static_assert( QTypeInfo<QPairCC>::isComplex);
-static_assert( QTypeInfo<QPairCC>::isStatic );
+static_assert( !QTypeInfo<QPairCC>::isRelocatable );
static_assert( QTypeInfo<QPairCM>::isComplex);
-static_assert( QTypeInfo<QPairCM>::isStatic );
+static_assert( !QTypeInfo<QPairCM>::isRelocatable );
static_assert( QTypeInfo<QPairCP>::isComplex);
-static_assert( QTypeInfo<QPairCP>::isStatic );
+static_assert( !QTypeInfo<QPairCP>::isRelocatable );
static_assert( QTypeInfo<QPairMC>::isComplex);
-static_assert( QTypeInfo<QPairMC>::isStatic );
+static_assert( !QTypeInfo<QPairMC>::isRelocatable );
static_assert( QTypeInfo<QPairMM>::isComplex);
-static_assert(!QTypeInfo<QPairMM>::isStatic );
+static_assert( QTypeInfo<QPairMM>::isRelocatable );
static_assert( QTypeInfo<QPairMP>::isComplex);
-static_assert(!QTypeInfo<QPairMP>::isStatic );
+static_assert( QTypeInfo<QPairMP>::isRelocatable );
static_assert( QTypeInfo<QPairPC>::isComplex);
-static_assert( QTypeInfo<QPairPC>::isStatic );
+static_assert( !QTypeInfo<QPairPC>::isRelocatable );
static_assert( QTypeInfo<QPairPM>::isComplex);
-static_assert(!QTypeInfo<QPairPM>::isStatic );
+static_assert( QTypeInfo<QPairPM>::isRelocatable );
static_assert(!QTypeInfo<QPairPP>::isComplex);
-static_assert(!QTypeInfo<QPairPP>::isStatic );
+static_assert( QTypeInfo<QPairPP>::isRelocatable );
static_assert(!QTypeInfo<QPairPP>::isPointer);
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 3a504177db..5c5ccf0a21 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -528,11 +528,11 @@ void reallocTest()
typedef QVarLengthArray<T, 16> Container;
enum {
- isStatic = QTypeInfo<T>::isStatic,
+ isRelocatable = QTypeInfo<T>::isRelocatable,
isComplex = QTypeInfo<T>::isComplex,
- isPrimitive = !isComplex && !isStatic,
- isMovable = !isStatic
+ isPrimitive = !isComplex && isRelocatable,
+ isMovable = isRelocatable
};
// Constructors
diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index 670b271d54..be34fa7639 100644
--- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -325,7 +325,7 @@ void tst_QGuiMetaType::flags_data()
QTest::addColumn<bool>("isComplex");
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
- QTest::newRow(#RealType) << MetaTypeId << bool(QTypeInfoQuery<RealType>::isRelocatable) << bool(QTypeInfoQuery<RealType>::isComplex);
+ QTest::newRow(#RealType) << MetaTypeId << bool(QTypeInfo<RealType>::isRelocatable) << bool(QTypeInfo<RealType>::isComplex);
QT_FOR_EACH_STATIC_GUI_CLASS(ADD_METATYPE_TEST_ROW)
#undef ADD_METATYPE_TEST_ROW
}
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index ce718b69ea..1f615f6e69 100644
--- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
@@ -361,7 +361,7 @@ void QRawVector<T>::realloc(int asize, int aalloc, bool ref)
T *xbegin = m_begin;
if (aalloc != xalloc || ref) {
// (re)allocate memory
- if (QTypeInfo<T>::isStatic) {
+ if (!QTypeInfo<T>::isRelocatable) {
xbegin = allocate(aalloc);
xsize = 0;
changed = true;
@@ -462,7 +462,7 @@ typename QRawVector<T>::iterator QRawVector<T>::insert(iterator before, size_typ
const T copy(t);
if (m_size + n > m_alloc)
realloc(m_size, QVectorData::grow(offsetOfTypedData(), m_size + n, sizeof(T)), false);
- if (QTypeInfo<T>::isStatic) {
+ if (!QTypeInfo<T>::isRelocatable) {
T *b = m_begin + m_size;
T *i = m_begin + m_size + n;
while (i != b)