diff options
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index e746800c9f..5f1a0618ab 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -70,6 +70,7 @@ #include "non-gadget-parent-class.h" #include "grand-parent-gadget-class.h" #include "namespace.h" +#include "cxx17-namespaces.h" #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header @@ -521,6 +522,10 @@ public slots: private: myNS::Points m_points; +#ifdef Q_MOC_RUN + int xx = 11'11; // digit separator must not confuse moc (QTBUG-59351) +#endif + private slots: inline virtual void blub1() {} virtual inline void blub2() {} @@ -696,6 +701,7 @@ private slots: void optionsFileError_data(); void optionsFileError(); void testQNamespace(); + void cxx17Namespaces(); signals: void sigWithUnsignedArg(unsigned foo); @@ -2145,6 +2151,22 @@ void tst_Moc::warnings_data() << 0 << QString() << QString("standard input:1: Note: No relevant classes found. No output generated."); + + QTest::newRow("Q_PLUGIN_METADATA: invalid file") + << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \"does.not.exists\") \n };") + << QStringList() + << 1 + << QString() + << QString("standard input:2: Error: Plugin Metadata file \"does.not.exists\" does not exist. Declaration will be ignored"); + +#ifdef Q_OS_LINUX // Limit to Linux because the error message is platform-dependent + QTest::newRow("Q_PLUGIN_METADATA: unreadable file") + << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") + << QStringList() + << 1 + << QString() + << QString("standard input:2: Error: Plugin Metadata file \".\" could not be opened: file to open is a directory"); +#endif } void tst_Moc::warnings() @@ -3787,6 +3809,25 @@ void tst_Moc::testQNamespace() QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); } +void tst_Moc::cxx17Namespaces() +{ + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.className(), + "CXX17Namespace::A::B::C::D"); + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumeratorCount(), 1); + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumerator(0).name(), "NamEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().name(), "NamEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().value(0), 4); + + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.className(), + "CXX17Namespace::A::B::C::D::ClassInNamespace"); + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumeratorCount(), 1); + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumerator(0).name(), "GadEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().name(), "GadEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().value(0), 3); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS |