summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-08-19 16:58:49 +0300
committerBogDan Vatra <bogdan@kdab.com>2016-09-15 08:55:32 +0000
commitbee70b24c1d6180465e9040a0f8bbff051405e0c (patch)
tree961865a486fc62fcc45b319ca670e5e7335cd843 /tests/auto/tools/moc
parent0a4d3a92184fce2cc0e92c19b5b1e834088122ea (diff)
Check the context of Q_ENUM[_NS] and Q_FLAG[_NS]
Change-Id: Ifc8cb50efe3b07a79c8afbb382fba12649b602b2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/tools/moc')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 56d6939102..a3648c95b6 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -2083,6 +2083,34 @@ void tst_Moc::warnings_data()
<< QString()
<< QString("standard input:1: Error: Namespace declaration lacks Q_NAMESPACE macro.");
+ QTest::newRow("Wrong Q_ENUM context.")
+ << QByteArray("namespace X {\nQ_NAMESPACE\n\nenum class MyEnum {Key1 = 1}\nQ_ENUM(MyEnum)\n}\n")
+ << QStringList()
+ << 1
+ << QString()
+ << QString("standard input:5: Error: Q_ENUM can't be used in a Q_NAMESPACE, use Q_ENUM_NS instead");
+
+ QTest::newRow("Wrong Q_FLAG context.")
+ << QByteArray("namespace X {\nQ_NAMESPACE\n\nenum class MyEnum {Key1 = 1}\nQ_FLAG(MyEnum)\n}\n")
+ << QStringList()
+ << 1
+ << QString()
+ << QString("standard input:5: Error: Q_FLAG can't be used in a Q_NAMESPACE, use Q_FLAG_NS instead");
+
+ QTest::newRow("Wrong Q_ENUM_NS context.")
+ << QByteArray("class X {\nQ_GADGET\n\nenum class MyEnum {Key1 = 1}\nQ_ENUM_NS(MyEnum)\n};\n")
+ << QStringList()
+ << 1
+ << QString()
+ << QString("standard input:5: Error: Q_ENUM_NS can't be used in a Q_OBJECT/Q_GADGET, use Q_ENUM instead");
+
+ QTest::newRow("Wrong Q_FLAG_NS context.")
+ << QByteArray("class X {\nQ_GADGET\n\nenum class MyEnum {Key1 = 1}\nQ_FLAG_NS(MyEnum)\n};\n")
+ << QStringList()
+ << 1
+ << QString()
+ << QString("standard input:5: Error: Q_FLAG_NS can't be used in a Q_OBJECT/Q_GADGET, use Q_FLAG instead");
+
QTest::newRow("Invalid macro definition")
<< QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45, 42, 39);")
<< QStringList()