From 3df316e9615027d9384cef81ac6cbfa2f9f81f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 22 May 2012 13:48:22 +0200 Subject: Avoid a type name normalization during auto-registration. Containers are auto-registered and use normalized names. Change-Id: Id65c3940401f69436929220e1f6a971135e147ed Reviewed-by: Stephen Kelly --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index d82f7560e3..da8c182f32 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -348,6 +348,13 @@ void tst_QMetaType::typeName_data() QTest::newRow("-1") << QMetaType::Type(-1) << QString(); QTest::newRow("-124125534") << QMetaType::Type(-124125534) << QString(); QTest::newRow("124125534") << QMetaType::Type(124125534) << QString(); + + // automatic registration + QTest::newRow("QList") << static_cast(::qMetaTypeId >()) << QString::fromLatin1("QList"); + QTest::newRow("QHash") << static_cast(::qMetaTypeId >()) << QString::fromLatin1("QHash"); + QTest::newRow("QMap") << static_cast(::qMetaTypeId >()) << QString::fromLatin1("QMap"); + QTest::newRow("QVector>") << static_cast(::qMetaTypeId > >()) << QString::fromLatin1("QVector >"); + QTest::newRow("QVector>") << static_cast(::qMetaTypeId > >()) << QString::fromLatin1("QVector >"); } void tst_QMetaType::typeName() @@ -355,7 +362,10 @@ void tst_QMetaType::typeName() QFETCH(QMetaType::Type, aType); QFETCH(QString, aTypeName); - QCOMPARE(QString::fromLatin1(QMetaType::typeName(aType)), aTypeName); + QString name = QString::fromLatin1(QMetaType::typeName(aType)); + + QCOMPARE(name, aTypeName); + QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData())); } #define FOR_EACH_PRIMITIVE_METATYPE(F) \ @@ -1392,6 +1402,8 @@ void tst_QMetaType::automaticTemplateRegistration() tn += it->trimmed(); \ } \ } \ + if (tn.endsWith('>')) \ + tn += ' '; \ tn += ">"; \ const int type = QMetaType::type(tn); \ const int expectedType = ::qMetaTypeId >(); \ -- cgit v1.2.3