aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp')
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 7e1dc2f3e5..14af747024 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -572,10 +572,28 @@ class TestClassWithClassInfo : public QObject
#define ARRAY_SIZE(arr) \
int(sizeof(arr) / sizeof(arr[0]))
+template <typename T, typename = void>
+struct SizeofOffsetsAndSizes_helper
+{
+ static constexpr size_t value = sizeof(T::offsetsAndSize); // old moc
+};
+
+template <typename T>
+struct SizeofOffsetsAndSizes_helper<T, std::void_t<decltype(T::offsetsAndSizes)>>
+{
+ static constexpr size_t value = sizeof(T::offsetsAndSizes); // new moc
+};
+
+template <typename T>
+constexpr size_t sizeofOffsetsAndSizes(const T &)
+{
+ return SizeofOffsetsAndSizes_helper<T>::value;
+}
+
#define TEST_CLASS(Class) \
QTest::newRow(#Class) \
<< &Class::staticMetaObject << ARRAY_SIZE(qt_meta_data_##Class) \
- << int(sizeof(qt_meta_stringdata_##Class.offsetsAndSize) / (sizeof(uint) * 2))
+ << int(sizeofOffsetsAndSizes(qt_meta_stringdata_##Class) / (sizeof(uint) * 2))
Q_DECLARE_METATYPE(const QMetaObject*);