From 4dbac23e5354638224d8d99ba3342067c015a04b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Dec 2019 18:13:28 +0100 Subject: Normalize types at compile time This also fix the normalization algorithm: - Some 'const' after pointers were not removed as they should. - No need to keep the space in '> >' and '< :' in C++11 anymore - Fix normalization of 'long unsigned int' and similar Change-Id: I2b72f0fede96c1063e7b155d9f25a85fccfc7bf9 Reviewed-by: Simon Hausmann --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 52 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 04c4777e07..0d9dfc1c4c 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -124,6 +124,8 @@ private slots: void customDebugStream(); void unknownType(); void fromType(); + void operatorEq_data(); + void operatorEq(); }; struct BaseGenericType @@ -579,11 +581,11 @@ void tst_QMetaType::typeName_data() // automatic registration QTest::newRow("QHash") << ::qMetaTypeId >() << QString::fromLatin1("QHash"); QTest::newRow("QMap") << ::qMetaTypeId >() << QString::fromLatin1("QMap"); - QTest::newRow("QVector>") << ::qMetaTypeId > >() << QString::fromLatin1("QVector >"); + QTest::newRow("QVector>") << ::qMetaTypeId > >() << QString::fromLatin1("QVector>"); // automatic registration with automatic QList to QVector aliasing QTest::newRow("QList") << ::qMetaTypeId >() << QString::fromLatin1("QVector"); - QTest::newRow("QVector>") << ::qMetaTypeId > >() << QString::fromLatin1("QVector >"); + QTest::newRow("QVector>") << ::qMetaTypeId > >() << QString::fromLatin1("QVector>"); QTest::newRow("CustomQObject*") << ::qMetaTypeId() << QString::fromLatin1("CustomQObject*"); QTest::newRow("CustomGadget") << ::qMetaTypeId() << QString::fromLatin1("CustomGadget"); @@ -1745,7 +1747,7 @@ void tst_QMetaType::automaticTemplateRegistration() PRINT_2ARG_TEMPLATE ) - CREATE_AND_VERIFY_CONTAINER(QList, QList > >) + CREATE_AND_VERIFY_CONTAINER(QList, QList > > >) CREATE_AND_VERIFY_CONTAINER(QVector, void*) CREATE_AND_VERIFY_CONTAINER(QVector, const void*) CREATE_AND_VERIFY_CONTAINER(QList, void*) @@ -2527,6 +2529,50 @@ void tst_QMetaType::fromType() #undef FROMTYPE_CHECK } +template +struct CharTemplate +{ + struct + { + int a; + } x; +}; + +void tst_QMetaType::operatorEq_data() +{ + QTest::addColumn("typeA"); + QTest::addColumn("typeB"); + QTest::addColumn("eq"); + + QTest::newRow("String") << QMetaType(QMetaType::QString) + << QMetaType::fromType() << true; + QTest::newRow("void1") << QMetaType(QMetaType::UnknownType) << QMetaType::fromType() + << true; + QTest::newRow("void2") << QMetaType::fromType() << QMetaType::fromType() + << true; + QTest::newRow("vec1") << QMetaType::fromType>() + << QMetaType::fromType>() << true; + QTest::newRow("vec2") << QMetaType::fromType>() + << QMetaType::fromType>() << false; + QTest::newRow("char1") << QMetaType::fromType'>>() + << QMetaType::fromType', void>>() << true; + QTest::newRow("annon1") << QMetaType::fromType'>::x)>() + << QMetaType::fromType'>::x)>() << true; + QTest::newRow("annon2") << QMetaType::fromType'>::x)>() + << QMetaType::fromType::x)>() << false; +} + +void tst_QMetaType::operatorEq() +{ + QFETCH(QMetaType, typeA); + QFETCH(QMetaType, typeB); + QFETCH(bool, eq); + + QCOMPARE(typeA == typeB, eq); + QCOMPARE(typeB == typeA, eq); + QCOMPARE(typeA != typeB, !eq); + QCOMPARE(typeB != typeA, !eq); +} // Compile-time test, it should be possible to register function pointer types class Undefined; -- cgit v1.2.3