diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-02 11:08:13 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-04 11:48:09 +0200 |
| commit | b8814dfb364e1316e3ee049d5d7cda9e23537d93 (patch) | |
| tree | 094fc9d7bb1b88142b4aa8ca51edc4160497c77d /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 9a0fe2eddb1b3b37e43aec116278def48edd98ad (diff) | |
QmlCompiler: Do not crash when converting number literals to enums
Amends commit 2a21efb5f7a6cac6f6101f2f42fe38f16dc68149.
Change-Id: Id7d739b58c723eed9f165951b51ee2e5e55d7fe2
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 0814d92429..0cad3eb68e 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 The Qt Company Ltd. #include "data/druggeljug.h" +#include "data/enumProperty.h" #include "data/withlength.h" #include <data/birthdayparty.h> #include <data/cppbaseclass.h> @@ -185,6 +186,7 @@ private slots: void jsArrayMethodsWithParams(); void shadowedMethod(); void topLevelComponent(); + void intToEnum(); }; void tst_QmlCppCodegen::initTestCase() @@ -3793,6 +3795,18 @@ void tst_QmlCppCodegen::topLevelComponent() QCOMPARE(o2->objectName(), u"foo"_s); } +void tst_QmlCppCodegen::intToEnum() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/intToEnum.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + MyType *m = qobject_cast<MyType *>(o.data()); + QCOMPARE(m->a(), MyType::D); + QCOMPARE(m->property("b").toInt(), 24); +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
