diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-17 09:45:45 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-19 20:57:17 -0800 |
commit | 541253fcd601022870ab3a55ccb9fd52e4e1cc29 (patch) | |
tree | ad0d862d5c56afd1e4a15f04b91ec7bdc140ed74 /tests | |
parent | 26f02d0bb727a81006a4a24e104f56a47affca15 (diff) |
tst_QMetaType: remove the IsInitialized check
All primitive types are initialized and have been since at least commit
33cd680ddbaccf6139e215d851a39e657ae36394 ("New QMetaType
representation").
Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1fe22dc5c8f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 27 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qmetatype/tst_qmetatype_common.h | 12 |
2 files changed, 11 insertions, 28 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 8c14278e1d..cfd023f439 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -741,12 +741,11 @@ static void testCreateHelper() QMetaType info(ID); void *actual1 = QMetaType::create(ID); void *actual2 = info.create(); - if (DefaultValueTraits<ID>::IsInitialized) { - Type *expected = DefaultValueFactory<ID>::create(); - QCOMPARE(*static_cast<Type *>(actual1), *expected); - QCOMPARE(*static_cast<Type *>(actual2), *expected); - delete expected; - } + Type *expected = DefaultValueFactory<ID>::create(); + QCOMPARE(*static_cast<Type *>(actual1), *expected); + QCOMPARE(*static_cast<Type *>(actual2), *expected); + delete expected; + QMetaType::destroy(ID, actual1); info.destroy(actual2); } @@ -755,9 +754,6 @@ template<> void testCreateHelper<QMetaType::Void>() { void *actual = QMetaType::create(QMetaType::Void); - if (DefaultValueTraits<QMetaType::Void>::IsInitialized) { - QVERIFY(DefaultValueFactory<QMetaType::Void>::create()); - } QMetaType::destroy(QMetaType::Void, actual); } @@ -1138,12 +1134,10 @@ static void testConstructHelper() void *actual2 = info.construct(storage2, /*copy=*/0); QCOMPARE(actual1, storage1); QCOMPARE(actual2, storage2); - if (DefaultValueTraits<ID>::IsInitialized) { - Type *expected = DefaultValueFactory<ID>::create(); - QCOMPARE(*static_cast<Type *>(actual1), *expected); - QCOMPARE(*static_cast<Type *>(actual2), *expected); - delete expected; - } + Type *expected = DefaultValueFactory<ID>::create(); + QCOMPARE(*static_cast<Type *>(actual1), *expected); + QCOMPARE(*static_cast<Type *>(actual2), *expected); + delete expected; QMetaType::destruct(ID, actual1); qFreeAligned(storage1); info.destruct(actual2); @@ -1163,9 +1157,6 @@ void testConstructHelper<QMetaType::Void>() void *storage = 0; void *actual = QMetaType::construct(QMetaType::Void, storage, /*copy=*/0); QCOMPARE(actual, storage); - if (DefaultValueTraits<QMetaType::Void>::IsInitialized) { - QVERIFY(DefaultValueFactory<QMetaType::Void>::create()); - } QMetaType::destruct(QMetaType::Void, actual); qFreeAligned(storage); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_common.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_common.h index 6193ca93b8..1ba9c47fa8 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_common.h +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype_common.h @@ -61,14 +61,14 @@ template <int ID> struct DefaultValueFactory { typedef typename MetaEnumToType<ID>::Type Type; - static Type *create() { return new Type; } + static Type *create() { return new Type(); } }; template <> struct DefaultValueFactory<QMetaType::Void> { typedef MetaEnumToType<QMetaType::Void>::Type Type; - static Type *create() { return 0; } + static Type *create() { return nullptr; } }; template <int ID> @@ -79,14 +79,6 @@ struct DefaultValueTraits enum { IsInitialized = true }; }; -#define DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS(MetaTypeName, MetaTypeId, RealType) \ -template<> struct DefaultValueTraits<QMetaType::MetaTypeName> { \ - enum { IsInitialized = false }; \ -}; -// Primitive types (int et al) aren't initialized -FOR_EACH_PRIMITIVE_METATYPE(DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS) -#undef DEFINE_NON_INITIALIZED_DEFAULT_VALUE_TRAITS - template <int ID> struct TestValueFactory {}; |