From b20da0ba2844b1ecbb7b128f3075f7285673b604 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 21 Mar 2024 10:22:17 +0100 Subject: tst_qglobal: add a few tests for QTypeInfo Change-Id: Iff4d8d9488d5b414d4504bc700b3191c799bf86c Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests/auto/corelib/global/qglobal/tst_qglobal.cpp') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index c2f2912144..1a19048bbe 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -883,5 +883,54 @@ void tst_QGlobal::nodiscard() QCOMPARE(t2.get(), 42); } +QT_BEGIN_NAMESPACE + +// Compile-time typeinfo tests +struct Complex1 +{ + ~Complex1(); +}; +static_assert(QTypeInfo::isComplex); +static_assert(!QTypeInfo::isRelocatable); + +struct Complex2 +{ + Complex2(Complex2 &&); +}; +static_assert(QTypeInfo::isComplex); +static_assert(!QTypeInfo::isRelocatable); + +struct Complex3 +{ + Complex3(int); +}; +static_assert(QTypeInfo::isComplex); +static_assert(QTypeInfo::isRelocatable); + +struct Relocatable1 +{ + ~Relocatable1(); +}; +Q_DECLARE_TYPEINFO(Relocatable1, Q_RELOCATABLE_TYPE); +static_assert(QTypeInfo::isComplex); +static_assert(QTypeInfo::isRelocatable); + +struct Relocatable2 +{ + Relocatable2(int); +}; +Q_DECLARE_TYPEINFO(Relocatable2, Q_RELOCATABLE_TYPE); +static_assert(QTypeInfo::isComplex); +static_assert(QTypeInfo::isRelocatable); + +struct Trivial1 +{ + int x[42]; +}; +static_assert(!QTypeInfo::isComplex); +static_assert(QTypeInfo::isRelocatable); + +QT_END_NAMESPACE + QTEST_APPLESS_MAIN(tst_QGlobal) #include "tst_qglobal.moc" -- cgit v1.2.3