aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/typedArray.qml9
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/valueTypeLists.qml3
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp18
3 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/typedArray.qml b/tests/auto/qml/qmlcppcodegen/data/typedArray.qml
index f9a40f5584..8d94d0832f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/typedArray.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/typedArray.qml
@@ -10,8 +10,17 @@ QtObject {
property list<date> values4: [aDate, aDate, aDate]
property list<real> values5: [1, 2, 3.4, "30", undefined, null]
property list<QtObject> values6: [self, self, self]
+ property string values7: "abcdef"
property int inIntList: values3[1]
property date inDateList: values4[2]
property real inRealList: values5[3]
+ property string inCharList: values7[5]
+
+ function stringAt10(s: string): int {
+ if (!s[10])
+ return 10;
+ else
+ return 20;
+ }
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/valueTypeLists.qml b/tests/auto/qml/qmlcppcodegen/data/valueTypeLists.qml
index 83325641ab..cf58ae68c5 100644
--- a/tests/auto/qml/qmlcppcodegen/data/valueTypeLists.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/valueTypeLists.qml
@@ -4,6 +4,7 @@ QtObject {
property list<rect> rectList: [ Qt.rect(1,2,3,4), Qt.rect(5,6,7,8), Qt.rect(9,10,11,12) ]
property list<string> stringList: ["aaa", "bbb", "ccc"]
property list<int> intList: [5, 6, 7, 8]
+ property string charList: "abcde"
property var rectInBounds: rectList[0]
property var rectOutOfBounds: rectList[32]
@@ -11,4 +12,6 @@ QtObject {
property var stringOutOfBounds: stringList[33]
property var intInBounds: intList[2]
property var intOutOfBounds: intList[34]
+ property var charInBounds: charList[3]
+ property var charOutOfBounds: charList[35]
}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index b4993d1752..84c5ad2deb 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -1955,6 +1955,20 @@ void tst_QmlCppCodegen::typedArray()
QCOMPARE(o->property("inIntList").toInt(), 2);
QCOMPARE(qvariant_cast<QDateTime>(o->property("inDateList")), date);
QCOMPARE(o->property("inRealList").toDouble(), 30.0);
+ QCOMPARE(o->property("inCharList").toString(), QStringLiteral("f"));
+
+ const QMetaObject *metaObject = o->metaObject();
+ QMetaMethod method = metaObject->method(metaObject->indexOfMethod("stringAt10(QString)"));
+ QVERIFY(method.isValid());
+
+ // If LoadElement threw an exception the function would certainly return neither 10 nor 20.
+ int result = 0;
+ method.invoke(
+ o.data(), Q_RETURN_ARG(int, result), Q_ARG(QString, QStringLiteral("a")));
+ QCOMPARE(result, 10);
+ method.invoke(
+ o.data(), Q_RETURN_ARG(int, result), Q_ARG(QString, QStringLiteral("aaaaaaaaaaa")));
+ QCOMPARE(result, 20);
}
void tst_QmlCppCodegen::prefixedType()
@@ -2126,6 +2140,10 @@ void tst_QmlCppCodegen::valueTypeLists()
QCOMPARE(qvariant_cast<int>(o->property("intInBounds")), 7);
QVERIFY(o->metaObject()->indexOfProperty("intOutOfBounds") > 0);
QVERIFY(!o->property("intOutOfBounds").isValid());
+
+ QCOMPARE(qvariant_cast<QString>(o->property("charInBounds")), QStringLiteral("d"));
+ QVERIFY(o->metaObject()->indexOfProperty("charOutOfBounds") > 0);
+ QVERIFY(!o->property("charOutOfBounds").isValid());
}
void tst_QmlCppCodegen::boundComponents()