From 5675334b6e22786195fe69a1fc1f40c49aaea37c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 8 Mar 2017 11:52:37 +0100 Subject: moc: Add support for C++17 nested namespaces (N4230) [ChangeLog][moc] Added Support for C++17 nested namespaces Change-Id: Ib83fc5bf48f66546fa97b49710582fbf9c984503 Reviewed-by: Simon Hausmann --- tests/auto/tools/moc/tst_moc.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 98429a1f0d..2d7ec2f0b5 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 @@ -700,6 +701,7 @@ private slots: void optionsFileError_data(); void optionsFileError(); void testQNamespace(); + void cxx17Namespaces(); signals: void sigWithUnsignedArg(unsigned foo); @@ -3803,6 +3805,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().name(), "NamEn"); + QCOMPARE(QMetaEnum::fromType().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType().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().name(), "GadEn"); + QCOMPARE(QMetaEnum::fromType().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType().value(0), 3); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS -- cgit v1.2.3